[英]maximize log likelihood function with R
So I wanted to maximize a likelihood function in order to get the estimation of four variables (a, b, c, sigma^2) with R
but it doesnt work I dont know why.所以我想,为了得到四个变量(A,B,C,西格马^ 2)的估计,以最大化似然函数
R
但它不工作,我不知道为什么。 Here I am estimating for age 30,60, and 90. And for each age I truncate it with 30, so as you can see for age 30 the x become 0, for 60 it become 30 and so on.在这里,我估计了 30、60 和 90 岁。对于每个年龄,我将其截断为 30,因此您可以看到,30 岁的 x 变为 0,60 岁的 x 变为 30,依此类推。 But the optimization wont work I dont know why;
但是优化不起作用我不知道为什么; can somebody kindly help me?
有人可以帮助我吗?
d30 <- 2975.1
d60 <- 11456.38
d90 <- 2977.08
r30 <- 1531956.05
r60 <- 650404.58
r90 <- 9728.47
Logg <- function(a,b,c,s)
{
(d30*log((((a*exp(b*0))/(1+((s*a/b)*(exp(b*0)-1))))+c)*r30)-log(factorial(d30))-((((a*exp(b*0))/(1+((s*a/b)*(exp(b*0)-1))))+c)*r30))+
(d60*log((((a*exp(b*30))/(1+((s*a/b)*(exp(b*30)-1))))+c)*r60)-log(factorial(d60))-((((a*exp(b*30))/(1+((s*a/b)*(exp(b*30)-1))))+c)*r60))+
(d90*log((((a*exp(b*60))/(1+((s*a/b)*(exp(b*60)-1))))+c)*r90)-log(factorial(d90))-((((a*exp(b*60))/(1+((s*a/b)*(exp(b*60)-1))))+c)*r90))
}
Logg(1,1,1,1)
optim(c(0,0,0,0),Logg,control = list(fnscale=-1))
log-likelihood function对数似然函数
lambda definition lambda 定义
mu definition亩定义
maybe this is because you try to numerically compute the factorial of very high number?也许这是因为你试图用数值计算非常高的阶乘? For such high number R will just return infinty:
对于如此高的数字,R 只会返回无穷大:
> d30<-2975.1
> factorial(d30)
[1] Inf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.