library(Rcapture)
data(hare)
desc<-descriptive(hare)
plot(desc)

closedp(hare)
##
## Number of captured units: 68
##
## Abundance estimations and model fits:
## abundance stderr deviance df AIC BIC infoFit
## M0 75.4 3.5 68.516 61 154.707 159.146 OK
## Mt 75.1 3.4 58.314 56 154.505 170.041 OK
## Mh Chao (LB) 79.8 6.4 58.023 58 150.214 161.311 OK
## Mh Poisson2 81.5 5.7 59.107 60 147.298 153.956 OK
## Mh Darroch 90.4 11.6 61.600 60 149.791 156.449 OK
## Mh Gamma3.5 100.6 21.7 62.771 60 150.961 157.619 OK
## Mth Chao (LB) 79.6 6.3 47.115 52 151.305 175.720 OK
## Mth Poisson2 81.1 5.6 48.137 55 146.327 164.083 OK
## Mth Darroch 90.5 11.7 50.706 55 148.896 166.652 OK
## Mth Gamma3.5 101.6 22.4 51.956 55 150.147 167.903 OK
## Mb 81.1 8.3 67.027 60 155.217 161.876 OK
## Mbh 74.2 14.6 63.257 59 153.447 162.325 OK
col<-rep(0,2^6-1)
mat<-histpos.t(6)
col[apply(mat,1,sum)==6]<-1
cp.m2<-closedp.mX(hare,mX=cbind(mat,col),mname="Mt without 111111")
cp.m2$results
## abundance stderr deviance df AIC
## Mt without 111111 76.77761 3.911153 47.89417 55 146.0846
CI1<-profileCI(hare,m="Mth",h="Poisson",a=2)

CI1$results
## abundance InfCL SupCL
## Mth Poisson2 80 71.84073 93.84254
CI2<-profileCI(hare,mX=cbind(mat,col),mname="Mt without 111111")

CI2$results
## abundance InfCL SupCL
## Mt without 111111 76 70.08663 85.41181
data(HIV)
descriptive(HIV,dfreq=TRUE)
##
## Number of captured units: 1896
##
## Frequency statistics:
## fi ui vi ni
## i = 1 1774 466 403 466
## i = 2 115 593 578 630
## i = 3 7 632 679 693
## i = 4 0 205 236 236
## fi: number of units captured i times
## ui: number of units captured for the first time on occasion i
## vi: number of units captured for the last time on occasion i
## ni: number of units captured on occasion i
mat<-histpos.t(4)
mX1<-cbind(mat,mat[,1]*mat[,2],mat[,1]*mat[,3],mat[,1]*mat[,4],mat[,2]*mat[,3],mat[,2]*mat[,4],mat[,3]*mat[,4])
cp.m1<-closedp.mX(HIV,dfreq=TRUE,mX=mX1,mname="Mt double interactions")
cp.m1$results
## abundance stderr deviance df AIC
## Mt double interactions 23443.54 9594.879 3.036804 4 92.07266
summary(cp.m1$glm)$coefficients
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 9.9780167 0.4452368 22.4105827 3.103499e-111
## mX1 -3.9758604 0.4438850 -8.9569599 3.337529e-19
## mX2 -3.6785194 0.4437085 -8.2903961 1.128719e-16
## mX3 -3.5469201 0.4440686 -7.9873239 1.378994e-15
## mX4 -4.6582017 0.4453831 -10.4588655 1.334439e-25
## mX5 1.1545857 0.4329136 2.6670119 7.652896e-03
## mX6 0.4810600 0.4305346 1.1173552 2.638425e-01
## mX7 0.3339371 0.5168483 0.6461027 5.182129e-01
## mX8 0.8266913 0.4291786 1.9262176 5.407721e-02
## mX9 0.7884198 0.4612659 1.7092522 8.740424e-02
## mX10 0.6951611 0.4705025 1.4774867 1.395452e-01
mX2<-cbind(mat,mat[,1]*mat[,2])
cp.m2<-closedp.mX(HIV,dfreq=TRUE,mX=mX2,mname="Mt interaction 1,2")
cp.m2$results
## abundance stderr deviance df AIC
## Mt interaction 1,2 12318.47 1188.722 7.613759 9 86.64962
CI<-profileCI(HIV,dfreq=TRUE,mX=mX2,mname="Mt interaction 1,2")

CI$results
## abundance InfCL SupCL
## Mt interaction 1,2 12308 10286.85 14977.69
data(mvole)
cp<-closedp(mvole[,11:15])
cp
##
## Number of captured units: 49
##
## Abundance estimations and model fits:
## abundance stderr deviance df AIC BIC infoFit
## M0 51.1 1.6 66.964 29 122.895 126.678 OK
## Mt 50.9 1.6 61.208 25 125.138 136.489 OK
## Mh Chao (LB) 71.9 14.2 33.556 26 95.486 104.945 OK
## Mh Poisson2 61.0 6.3 37.902 28 95.833 101.508 OK
## Mh Darroch 93.2 26.7 34.611 28 92.541 98.217 OK
## Mh Gamma3.5 203.2 119.1 33.984 28 91.915 97.590 warning #1
## Mth Chao (LB) 71.0 13.7 26.120 22 96.051 113.077 OK
## Mth Poisson2 60.5 6.1 30.652 24 96.582 109.825 OK
## Mth Darroch 93.1 26.6 27.178 24 93.108 106.351 OK
## Mth Gamma3.5 209.9 124.3 26.539 24 92.470 105.712 warning #1
## Mb 51.0 2.0 66.964 28 124.894 130.570 OK
## Mbh 52.6 9.1 66.256 27 126.187 133.754 OK
psi<-function(x){-log(3.5+x)+log(3.5)}
lgmodel<-closedp.h(mvole[,11:15],h=psi)
lgmodel$results
## abundance stderr deviance df AIC
## Mh psi 203.2393 119.0627 33.98449 28 91.91481
xx<-uifit(cp)
xx$predicted[,c(1,4,5,6)]
## observed Mh Chao (LB) Mh Poisson2 Mh Darroch
## u1 26 24.2 24.2000000 24.200000
## u2 12 9.9 10.1340984 9.900000
## u3 3 6.2 6.5764481 6.340635
## u4 6 4.7 4.6588525 4.747957
## u5 2 4.0 3.4306010 3.811407
## u6 NA NA 2.5849972 3.180338
## u7 NA NA 1.9785928 2.720707
## u8 NA NA 1.5319327 2.368835
## u9 NA NA 1.1965924 2.089944
## u10 NA NA 0.9411818 1.863153