目前我正在尝试找到一个最适合我的正偏数据集(n = 70)的众所周知的分布。首先,我使用fitdistrplusR 包来估计 Gamma、Weibull、对数正态和指数分布的参数(使用最大似然估计,尽管我不确定 MLE 是否是 70 个观测值的最佳选择(更好的一个?))。
在第二步中,我选择了 AIC 最小的模型。但当然,模型也应该通过拟合优度测试。第一个想法是简单地使用带有估计参数的 Kolmogorv-Smirnov 检验,但这似乎不是一个好主意,因为带有估计参数的 KS 检验会导致或多或少无用的 p 值。
在网上搜索期间,我偶然发现了Greg Snows 的建议,除了这个页面,它描述了一种有趣的蒙特卡罗方法(来自Clauset 等人)。使用包进行对数范数分布的最大似然估计的示例性改编 R 代码示例fitdistrplus如下所示:
lognormal = function(d, limit=2500) {
# MLE for lognormal distribution
fit <- fitdist(d,"lnorm", method="mle")
# compute KS statistic
t = ks.test(d, "plnorm", meanlog = fit$estimate["meanlog"], sdlog = fit$estimate["sdlog"]);
# compute p-value
count = 0;
for (i in 1:limit) {
syn = rlnorm(length(d), meanlog = fit$estimate["meanlog"], sdlog = fit$estimate["sdlog"]);
fit2 <- fitdist(syn, "lnorm", method="mle")
t2 = ks.test(syn, "plnorm", meanlog = fit2$estimate["meanlog"], sdlog = fit2$estimate["sdlog"]);
if(t2$stat >= t$stat) {count = count + 1};
}
return(list(meanlog = fit$estimate["meanlog"], sdlog = fit$estimate["sdlog"], stat = t$stat, p = count/limit, KSp = t$p));
}
我目前问我(和你)的是,这种方法对于小样本量是否有意义(或者我应该使用矩/...估计器还是 MLE 可以)并且是测试拟合优度的方式合适的?