## Leslie model examples
# no Ricker modification
l1 <- depletion(SMBassLS$catch,SMBassLS$effort,method="Leslie")
summary(l1)
summary(l1,verbose=TRUE)
summary(l1,parm="No")
rSquared(l1)
rSquared(l1,digits=1,percent=TRUE)
coef(l1)
confint(l1)
confint(l1,incl.est=TRUE)
confint(l1,incl.est=TRUE,parm="No")
confint(l1,incl.est=TRUE,parm="q")
confint(l1,incl.est=TRUE,parm="lm")
plot(l1)
# with Ricker modification
l2 <- depletion(SMBassLS$catch,SMBassLS$effort,method="Leslie",Ricker.mod=TRUE)
summary(l2)
confint(l1,incl.est=TRUE)
plot(l2)
## DeLury model examples with no Ricker modification
d1 <- depletion(SMBassLS$catch,SMBassLS$effort,method="DeLury")
summary(d1)
rSquared(d1)
confint(d1,incl.est=TRUE)
plot(d1)
# Leslie model using formula notation
l3 <- depletion(catch~effort,data=SMBassLS)
summary(l3)
# Leslie model by group (requires dplyr package)
# Dummy example data (lake=="A" is SMBassLS example ... just FYI)
tmpdf <- data.frame(ct=c(131,69,99,78,56,76,49,42,63,47,
117,75,87,67,58,67,42),
ft=c(7,7,7,7,7,7,7,7,7,7,
5,7,5,5,4,6,5),
lake=as.factor(c(rep("A",10),rep("B",7))))
if (require(dplyr)) {
res <- tmpdf %>%
dplyr::group_by(lake) %>%
dplyr::group_modify(~confint(depletion(ct~ft,data=.x),
incl.est=TRUE,as.df=TRUE)) %>%
as.data.frame() # removes tibble and grouping structure
res
}
Run the code above in your browser using DataLab