Sunzhuowei789 发表于 2018-4-1 18:30 
请问如果函数是r中没有的 就是自己定义的那种该怎么办呢
密度函数是:p(i)=p(i-1)(a+b/i)
> LL<-function(params,data)
+ {
+ theta<-params[1]
+ a<-params[2]
+ b<-params[3]
+ n<-1000
+ ll<-log(1-theta+theta/sum(prod(a+b/i)))+n*log(1-theta+theta/sum(prod(a+b/i))-1+theta)+sum((n-i+1)*(a+b/i))
+ #log-likelihood函数
+ return(-ll)
+
+ }
>
> geyser.res<-nlminb(c(0.5,0.5,0.2),LL,data=1:100,lower=c(-1,-1,0),upper=c(1,1,1))
There were 50 or more warnings (use warnings() to see the first 50)
> geyser.res$par
[1] 0.758887894 -0.000199301 0.199500293
这个该怎么修改呢?