Displaying 1 result from an estimated 1 matches for "poisnll".
2011 Apr 12
1
2-parameter MLE problems
...ds. I have included my code below:
summary=read.delim('summary.txt',header=T)
summary
Year N SeroPos SeroNeg
1 1 75 1 74
2 2 12 3 9
3 3 139 11 128
4 4 178 22 156
5 5 203 18 185
6 6 244 37 207
attach(summary)
poisNLL=function(P){
lambda=P[1]*SeroNeg*0.001*SeroPos-0.35*0.999*SeroPos-P[2]*SeroPos
v=-sum(dpois(SeroNeg,lambda=lambda,log=TRUE))
if (!is.finite(v)) v<- -2000000
v
}
opt1=optim(poisNLL,start=c(10,.1),method='BFGS')
I receive the following error from this code: "Error in optim(poisNLL, s...