R source code ######################################################################### ## Part A > rm(list=ls()) > library(Rcapture) # Load the Rcapture library > > # A matrix of capture histories and their frequencies > ( red.back <- data.frame(w1=c(0,0,0,1,1,1,1), w2=c(0,1,1,0,0,1,1), w3=c(1,0,1,0,1,0,1), freq=c(33,32,5,15,4,7,9)) ) w1 w2 w3 freq 1 0 0 1 33 2 0 1 0 32 3 0 1 1 5 4 1 0 0 15 5 1 0 1 4 6 1 1 0 7 7 1 1 1 9 > > # Run the closed-population model > # dfreq=TRUE indicates that red.back is a matrix of capture histories and frequencies > ( cp1 <- closedp(red.back, dfreq=TRUE) ) Number of captured units: 105 Abundance estimations and model fits: abundance stderr deviance df AIC M0 172.5 19.5 21.771 5 55.584 Mt 170.2 19.0 15.833 3 53.646 Mh Chao (LB) 238.3 46.2 9.332 4 45.145 Mh Poisson2 492.3 231.9 9.332 4 45.145 Mh Darroch 1230.0 998.0 9.332 4 45.145 Mh Gamma3.5 3418.5 3938.3 9.332 4 45.145 Mth Chao (LB) 234.4 44.9 2.939 2 42.752 Mth Poisson2 489.1 230.0 2.939 2 42.752 Mth Darroch 1245.3 1011.8 2.939 2 42.752 Mth Gamma3.5 3538.8 4083.2 2.939 2 42.752 Mb 1278.1 5122.5 14.901 4 50.714 Mbh 377.2 640.1 14.730 3 52.542 ######################################################################### ## Part B > rm(list=ls()) # Clear workspace > library(Rcapture) # Load the Rcapture library > > # Read in the matrix of capture histories > ( duck4 <- read.csv("duck4.csv") ) t1 t2 t3 t4 freq 1 1 1 1 1 40 2 1 1 1 0 9 3 1 1 0 1 36 4 1 1 0 0 56 5 1 0 1 1 42 6 1 0 1 0 13 7 1 0 0 1 44 8 1 0 0 0 405 9 0 1 1 1 12 10 0 1 1 0 3 11 0 1 0 1 28 12 0 1 0 0 27 13 0 0 1 1 24 14 0 0 1 0 16 15 0 0 0 1 141 > > # Run the open-population Jolly-Seber model > # dfreq=TRUE indicates that duck4 is a matrix of capture histories and frequencies > # m="up" allows unequal capture probabilities in the model > # neg=TRUE does not bound the gamma parameters to prevent survival probabilities outside [0-1], not that that matters here > ( op.duck4 <- openp(duck4, dfreq=TRUE, m="up", neg=TRUE) ) Model fit: deviance df AIC fitted model 12.478 6 108.894 Test for trap effect: deviance df AIC model with homogenous trap effect 11.787 5 110.202 Capture probabilities: estimate stderr period 1 -- -- period 2 0.4635 0.0354 period 3 0.4499 0.0349 period 4 -- -- Survival probabilities: estimate stderr period 1 -> 2 0.4716 0.0289 period 2 -> 3 0.7069 0.0438 period 3 -> 4 -- -- Abundances: estimate stderr period 1 -- -- period 2 455.2 26.1 period 3 353.4 17.8 period 4 -- -- Number of new arrivals: estimate stderr period 1 -> 2 -- -- period 2 -> 3 31.6 18.4 period 3 -> 4 -- -- Total number of units who ever inhabited the survey area: estimate stderr all periods 932.4 9 Total number of captured units: 896