`panel5pt4.fn` <- function(){ ## double observer model for estimating population size for the ## aerial waterfowl survey data described in Section 5.5.3 y<-c(64,19,79) # order of counts is: (seen by both, seen by 2nd only, seen by 1st only) nind<-sum(y) lik<-function(parms){ p<- expit(parms[1:2]) n0<- exp(parms[3]) N<-nind + n0 pvec<-c(p[1]*p[2],(1-p[1])*p[2],p[1]*(1-p[2]),(1-p[1])*(1-p[2])) -1*(lgamma(N+1)-lgamma(n0+1) + sum(c(y,n0)*log(pvec))) } nlm(lik,c(0,0,1),hessian=TRUE) }