knitr::opts_chunk$set(collapse = T, comment = "#>") library(bootylator)
The CSS/FPC bootstrap program (i.e. the BT series) was first developed by FPC biometrician Tom Berggren and programmer Henry Franzoni in the early 2000's. The BT programs were initially written in the FoxPro programming language, and later translated into C# by FPC programmer Sergei Rassk. Began in 2011, with the increasing popularity of R statistical software, FPC biometrician Jack Tuomikoski started developing a new version of bootstrap program to run simulations and process results using a suite of R functions (i.e. bootstrapper
, release
, and DoCalcs
). As of 2018 CSS annual report, CSS/FPC had been conducting bootstrap simulations using both BT and Tuomikoski's bootstrap programs.
FPC continued to develop bootstrap program with two goals in mind. First, FPC would like to migrate all bootstrap programs to a single platform. Second, the bootstrap programs would preferably be written in R, so future updates and improvements could be done by FPC biologists or biometrician. In 2017, FPC developed bootylator
package that bundled R functions to run CSS bootstraps and export results. bootylator
retained all functionalities of BT and Tuomikoski's bootstrap programs, including weighted bootstrap. And bootylator
added new capabilities such as finite population correction that would allow a more robust estimation with small sample size and avoid getting results with NA's. bootylator
also included a function to simulate fake mark-recapture data for research purpose.
A basic workflow for bootylator
to estimate CSS survivals:
Loading and formatting data.
Run bootstrap simulation.
Output results.
Additional functionalities of bootylator
:
Calculate point estimates for survivals and detection without bootstrap.
Generate fake mark-recapture data for simulation studies.
format_dat()
formats the designated csv file before bootstrapping. The csv file has a standard format and is set by the FPC biologists.
dat_in<- format_dat(file_name='SR HCH 2016 CLWH_SU_new_format.csv', mig_yr=2016, wgt='n')
bootystrapper()
is the function that automates the bootstrap simulation. It takes the estimation function, surv_cal()
or mark_calc()
, and run it through the iteration process. User specifies number of iterations, options for incorporating weighted bootstrap, and finite population correction. Users can also specify to only get estimates for reach survival and detection (and omit other metrics). surv_cal()
estimates using closed-form CJS, and mark_calc()
calls package RMARK or marked to estimate survivals using logit link.
booty<- bootystrapper(dat_in, surv_calc, iter=10, wgt='n', wgt_init='n', fpc='y', phi_p_only='n')
To save bootstrap results in the SQL server (CSSOUTPUT), specify file name in "save_name." for example, bootystrapper(dat_in, surv_calc, iter=10, save_name='SR HCH 2016 CLWH_SU')
indicates saving results under a string that includes "SR HCH 2016 CLWH_SU". Notice that there is no extension (.csv) in "save_name". Nothing would be save if "save_name" is not specified.
To summarize and export the results, use doCalcs()
for Snake River or doCalcs_uc()
for upper Columbia. Parameter outputs are appended in CSSREPORT in the SQL server and in csv file in current working directory. Exporting results is suppressed for the example below.
ans<- doCalcs(booty, species='CH', makefile='n') print(format(ans[,c(2,5,3)], scientific = F))
Point Estimates for Survivals and Detection
surv_calc()
(or mark_calc()
) can be used as a stand-alone function to calculate reach survivals and detection. Capture histories are the only information needed for an input file. Each capture event, including release, should have its own column. Specified number of occasions should match the number of columns of capture history input file. Options for weighting (wt and wt_i) are not applicable, and should be specified as "n". phi_p_only enables calculations only for survivals and detection.
dat_in[1:5, 1:8] pt_est<- surv_calc(dat_in, i=1, nocc=8, wt='n', wt_i='n', phi_p_only='y', fpc='y') print(pt_est)
marray()
can be used to extract m-array table.
m_ij<- marray(dat_in, n_occ=8) print(m_ij)
Simulation Study
siml_cjs()
creates a fake detection history based on user specifications.
n_occ<- 8 mrkd<- 10 phi_real<- rep(0.9, n_occ-1) # set survival p_real<- rep(0.45, n_occ-1) # set detection remv<- 0.01 # portion removed at occ 2 and 3 intgr<- 0.23 surv_diff<- 0.07 grp_t<- 0.7 adu_rtn<- 0.05 big_phi<- matrix(phi_real, ncol= n_occ-1, nrow= mrkd) big_p<- matrix(p_real, ncol= n_occ-1, nrow= mrkd) ch<- siml_cjs(big_phi, big_p, mrkd, remv, n_occ, intgr, surv_diff, grp_t, adu_rtn) ch
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.