我要用极大似然方法对收入的分布进行估计,假定服从gamma分布
di=read.table("di.txt",header=TRUE)
attach(di) #di中有变量dio2和di03
library(stats4)
ll=function(lambda,alfa){n=500
x=di02
-n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa-1)*sum(log(x))+lambda*sum(x)}
est=mle(minuslog=ll,start=list(lambda=2,alfa=1))
summary(est)
运行后提示大量出错信息:
Error in optim(start, f, method = method, hessian = TRUE, ...) :
non-finite finite-difference value [1]
In addition: There were 50 or more warnings (use warnings() to see the first 50)
估计结果也不对,麻烦高手给看看问题出在哪,谢谢。
[此贴子已经被作者于2009-3-30 13:47:35编辑过]