使用mle2时指定固定参数会导致错误。当我用公式指定可能性时会发生这种情况。
library(ggplot2)
mle2(carat ~ dnorm(mean = a * x + b, sd = 1), start = list(a = 1), fixed = list(b = 1), data = diamonds)
Error in mle2(carat ~ dnorm(mean = a * x + b, sd = 1), start = list(a = 1), :
some named arguments in 'fixed' are not arguments to the specified log-likelihood function
答案 0 :(得分:2)
您可以通过在起始猜测的规范中包含'b = 1'来解决错误,例如:
mle2(carat ~ dnorm(mean = a * x + b, sd = 1), start = list(a = 1, b = 1), fixed = list(b = 1), data = diamonds)
即使在起始猜测中列出'b',因为它也在固定参数列表中指定,mle2将不会修改其值。