TimeStratPetersenNonDiagErrorNPMarkAvail_fit {BTSPAS}  R Documentation 
Takes the number of marked fish released, the number of recaptures, and the number of unmarked fish and uses Bayesian methods to fit a fit a spline through the population numbers and a hierarchical model for the trap efficiencies over time. The output is written to files and an MCMC object is also created with samples from the posterior.
TimeStratPetersenNonDiagErrorNPMarkAvail_fit( title = "TSPNDENPavail", prefix = "TSPNDENPavail", time, n1, m2, u2, sampfrac = rep(1, length(u2)), jump.after = NULL, bad.n1 = c(), bad.m2 = c(), bad.u2 = c(), logitP.cov = rep(1, length(u2)), logitP.fixed = NULL, logitP.fixed.values = NULL, marked_available_n, marked_available_x, n.chains = 3, n.iter = 2e+05, n.burnin = 1e+05, n.sims = 2000, tauU.alpha = 1, tauU.beta = 0.05, taueU.alpha = 1, taueU.beta = 0.05, prior.beta.logitP.mean = c(logit(sum(m2, na.rm = TRUE)/sum(n1, na.rm = TRUE)), rep(0, ncol(as.matrix(logitP.cov))  1)), prior.beta.logitP.sd = c(2, rep(10, ncol(as.matrix(logitP.cov))  1)), tauP.alpha = 0.001, tauP.beta = 0.001, Delta.max = NULL, tauTT.alpha = 0.1, tauTT.beta = 0.1, run.prob = seq(0, 1, 0.1), debug = FALSE, debug2 = FALSE, InitialSeed = ceiling(stats::runif(1, min = 0, max = 1e+06)), save.output.to.files = TRUE, trunc.logitP = 15 )
title 
A character string used for a title on reports and graphs 
prefix 
A character string used as the prefix for created files. All created graph files are of the form prefixxxxxx.pdf. 
time 
A numeric vector of time used to label the strata. For example, this could be julian week for data stratified at a weekly level. 
n1 
A numeric vector of the number of marked fish released in each time stratum. 
m2 
A numeric matrix of the number of fish released in stratum [i] and
recovered in [j1] strata later. For example m2[3,5] is the number of
marked fish released in stratum 3 and recovered 4 strata later in stratum 7.
The first column is the number of marked fish recovered in the stratum of
release, i.e. 0 strata later. Use the

u2 
A numeric vector of the number of unmarked fish captured in each stratum. These will be expanded by the capture efficiency to estimate the population size in each stratum. The length of u2 should be between the length of n1 and length n1 + number of columns in m2 1 
sampfrac 
Deprecated because it really doesn't work as intended. You must remove all references to sampfrac from your code. Contact cschwarz.stat.sfu.ca@gmail.com for more information. 
jump.after 
A numeric vector with elements belonging to 
bad.n1 
A numeric vector with elements belonging to 
bad.m2 
A numeric vector with elements belonging to 
bad.u2 
A numeric vector with elements belonging to 
logitP.cov 
A numeric matrix for covariates to fit the logit(catchability). Default is a single intercept, i.e. all strata have the same mean logit(catchability). 
logitP.fixed 
A numeric vector (could be null) of the time strata
where the logit(P) would be fixed. Typically, this is used when the capture
rates for some strata are 0 and logit(P) is set to 10 for these strata. The
fixed values are given in 
logitP.fixed.values 
A numerical vector (could be null) of the fixed values for logit(P) at strata given by logitP.fixed. Typically this is used when certain strata have a 0 capture rate and the fixed value is set to 10 which on the logit scale gives p[i] essentially 0. Don't specify values such as 50 because numerical problems could occur in JAGS. 
marked_available_n 
Information, usually from prior studies, on the fraction of marks that will be available. The *_n and *_x are used to create a "binomial" distribution for information on the marked availability. For example, if *_n=66 and *_x=40, then you estimate that about 40/66=61% of marks are available and 39% have dropped out or fallen back. 
marked_available_x 
See marked_available_n 
n.chains 
Number of parallel MCMC chains to fit. 
n.iter 
Total number of MCMC iterations in each chain. 
n.burnin 
Number of burnin iterations. 
n.sims 
Number of simulated values to keeps for posterior distribution. 
tauU.alpha 
One of the parameters along with 
tauU.beta 
One of the parameters along with 
taueU.alpha 
One of the parameters along with 
taueU.beta 
One of the parameters along with 
prior.beta.logitP.mean 
Mean of the prior normal distribution for logit(catchability) across strata 
prior.beta.logitP.sd 
SD of the prior normal distribution for logit(catchability) across strata 
tauP.alpha 
One of the parameters for the prior for the variance in logit(catchability) among strata 
tauP.beta 
One of the parameters for the prior for the variance in logit(catchability) among strata 
Delta.max 
Maximum transition time for marked fish, i.e. all fish assumed to have moved by Delta.max unit of time 
tauTT.alpha 
One of the parameters along with 
tauTT.beta 
One of the parameters along with 
run.prob 
Numeric vector indicating percentiles of run timing should be computed. 
debug 
Logical flag indicating if a debugging run should be made. In the debugging run, the number of samples in the posterior is reduced considerably for a quick turn around. 
debug2 
Logical flag indicated if additional debugging information is
produced. Normally the functions will halt at 
InitialSeed 
Numeric value used to initialize the random numbers used in the MCMC iterations. 
save.output.to.files 
Should the plots and text output be save to the files in addition to being stored in the MCMC object? 
trunc.logitP 
Truncate logit(P) between c(=trunc.logitP, trunc.logitP) when plotting the logitP over time. Actual values of logit(P) are not affected. 
Normally the user makes a call to the *_fit function which then calls the fitting function.
Use the TimeStratPetersenDiagError_fit
function for cases
where recaptures take place ONLY in the stratum of release, i.e. the
diagonal case.
The nondiagonal case fits a lognormal distribution for the travel time. The *NP functions fit a nonparametric distribution for the travel times. The *MarkAvail functions extend the *NP functions to allow for reductions in mark availability because of fall back, immediate tagging mortality, etc.
An MCMC object with samples from the posterior distribution. A series of graphs and text file are also created in the working directory.
Bonner, S.J. sbonner6@uwo.ca and Schwarz, C. J. cschwarz.stat.sfu.ca@gmail.com.
Bonner, S. J., & Schwarz, C. J. (2011). Smoothing population size estimates for TimeStratified MarkRecapture experiments Using Bayesian PSplines. Biometrics, 67, 14981507. doi: 10.1111/j.15410420.2011.01599.x
Schwarz, C. J., & Dempson, J. B. (1994). Markrecapture estimation of a salmon smolt population. Biometrics, 50, 98108.
Schwarz, C.J., D. Pickard, K. Marine and S.J. Bonner. 2009. Juvenile Salmonid Outmigrant Monitoring Evaluation, Phase II  December 2009. Final Technical Memorandum for the Trinity River Restoration Program, Weaverville, CA. 155 pp. + appendices available at https://www.fws.gov/arcata/fisheries/reports/technical/TR_Final_Report.pdf
## See the vignettes for examples of how to use this package