plot(catch~age,data=BrookTroutTH,pch=19)
## demonstration of formula notation
cr1 <- chapmanRobson(catch~age,data=BrookTroutTH,ages2use=2:6)
summary(cr1)
summary(cr1,verbose=TRUE)
coef(cr1)
confint(cr1)
confint(cr1,incl.est=TRUE)
plot(cr1)
plot(cr1,axis.age="age")
plot(cr1,axis.age="recoded age")
summary(cr1,parm="Z")
coef(cr1,parm="Z")
confint(cr1,parm="Z",incl.est=TRUE)
## demonstration of excluding ages2use
cr2 <- chapmanRobson(catch~age,data=BrookTroutTH,ages2use=-c(0,1))
summary(cr2)
plot(cr2)
## demonstration of ability to work with missing age classes
age <- c( 2, 3, 4, 5, 7, 9,12)
ct <- c(100,92,83,71,56,35, 1)
cr3 <- chapmanRobson(age,ct,4:12)
summary(cr3)
plot(cr3)
## Demonstration of computation for multiple groups
## only ages on the descending limb for each group are in the data.frame
# Get example data
data(FHCatfish,package="FSAdata")
FHCatfish
# Note use of incl.est=TRUE and as.df=TRUE
if (require(dplyr)) {
res <- FHCatfish %>%
dplyr::group_by(river) %>%
dplyr::group_modify(~confint(chapmanRobson(abundance~age,data=.x),
incl.est=TRUE,as.df=TRUE)) %>%
as.data.frame() # removes tibble and grouping structure
res
}
## Demonstration of computation for multiple groups
## ages not on descending limb are in the data.frame, but use same
## ages.use= for each group
# Get example data
data(WalleyeKS,package="FSAdata")
# Note use of incl.est=TRUE and as.df=TRUE
if (require(dplyr)) {
res <- WalleyeKS %>%
dplyr::group_by(reservoir) %>%
dplyr::group_modify(~confint(chapmanRobson(catch~age,data=.x,ages2use=2:10),
incl.est=TRUE,as.df=TRUE)) %>%
as.data.frame() # removes tibble and grouping structure
res
}
Run the code above in your browser using DataLab