在 中mle2
,我使用“optimx”作为优化器。我想对参数使用下限和上限。我怎样才能做到这一点?
例如:
library("bbmle"); library("optimx")
y <- c(0.654, 0.613, 0.315, 0.449, 0.297, 0.402, 0.379,
0.423, 0.379, 0.3235, 0.269, 0.740, 0.418, 0.412,
0.494, 0.416, 0.338, 0.392, 0.484, 0.265)
gamma4 <- function(shape, scale) {
-sum(dgamma(y, shape = shape, scale = scale,log = TRUE))
}
gm <- mean(y)
cv <- var(y)/mean(y)
m5 <- mle2(gamma4,start = list(shape = gm/cv, scale = cv),
optimizer="optimx")
m5
或者:
mle2(gengamma3,start = list(shape = ci,
scale = bet, k=alp),
optimizer="optimx")
谢谢