Description Usage Arguments Details Value Author(s) References Examples
View source: R/TimeStratPetersenDiagErrorWHChinook_fit.R
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79  TimeStratPetersenDiagErrorWHChinook2_fit(
title = "TSPDEWHChinook2",
prefix = "TSPDEWHChinook2",
time,
n1,
m2,
u2.A.YoY,
u2.N.YoY,
u2.A.1,
u2.N.1,
clip.frac.H.YoY,
clip.frac.H.1,
sampfrac = rep(1, length(u2.A.YoY)),
hatch.after.YoY = NULL,
bad.m2 = c(),
bad.u2.A.YoY = c(),
bad.u2.N.YoY = c(),
bad.u2.A.1 = c(),
bad.u2.N.1 = c(),
logitP.cov = as.matrix(rep(1, length(n1))),
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(stats::sd(logit((m2 + 0.5)/(n1 + 1)), na.rm = TRUE), rep(10,
ncol(as.matrix(logitP.cov))  1)),
tauP.alpha = 0.001,
tauP.beta = 0.001,
run.prob = seq(0, 1, 0.1),
debug = FALSE,
debug2 = FALSE,
InitialSeed = ceiling(stats::runif(1, min = 0, 1e+06)),
save.output.to.files = TRUE,
trunc.logitP = 15
)
TimeStratPetersenDiagErrorWHChinook_fit(
title = "TSPDEWHChinook",
prefix = "TSPDEWHChinook",
time,
n1,
m2,
u2.A,
u2.N,
clip.frac.H,
sampfrac = rep(1, length(u2.A)),
hatch.after = NULL,
bad.n1 = c(),
bad.m2 = c(),
bad.u2.A = c(),
bad.u2.N = c(),
logitP.cov = as.matrix(rep(1, length(n1))),
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(stats::sd(logit((m2 + 0.5)/(n1 + 1)), na.rm = TRUE), rep(10,
ncol(as.matrix(logitP.cov))  1)),
tauP.alpha = 0.001,
tauP.beta = 0.001,
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 vector of the number of marked fish from n1 that are
recaptured in each time stratum. All recaptures take place within the
stratum of release. Use the 
u2.A.YoY, u2.N.YoY 
Number of YoY unmarked fish with/without adipose fin clips All YoY wild fish have NO adipose fin clips; however, hatchery fish are a mixture of fish with adipose fin clips (a known percentage are marked) and unmarked fish. So u2.A.YoY MUST be hatchery fish. u2.N.YoY is a mixture of wild and hatchery fish. 
u2.A.1, u2.N.1 
Number of Age1 unmarked fish with/with out adipose fin clips All Age1 wild fish have NO adipose fin clips; however, hatchery fish are a mixture of fish with adipose fin clips (a known percentage are marked) and unmarked fish. So u2.A.1 MUST be hatchery fish. u2.N.1 is a mixture of wild and hatchery fish. 
clip.frac.H.YoY, clip.frac.H.1 
Fraction of the YoY hatchery/Age1 (from last year's releases) hatchery fish are clipped?\ (between 0 and 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. 
hatch.after.YoY 
A numeric vector with elements belonging to

bad.m2 
A numeric vector with elements belonging to 
bad.u2.A.YoY, bad.u2.N.YoY 
List of julian weeks where the value of u2.A.YoY/u2.N.YoY is suspect. These are set to NA prior to the fit. 
bad.u2.A.1, bad.u2.N.1 
List of julian weeks where the value of u2.A.1/u2.N.1 is suspect. These are set to NA prior to the fit. 
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). 
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 
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. 
u2.A 
A numeric vector of the number of unmarked fish with adipose clips captured in each stratum. 
u2.N 
A numeric vector of the number of unmarked fish with NOadipose clips captured in each stratum. 
clip.frac.H 
A numeric value for the fraction of the hatchery fish that have the adipose fin clipped (between 0 and 1). 
hatch.after 
A numeric vector with elements belonging to 
bad.n1 
A numeric vector with elements belonging to 
bad.u2.A 
A numeric vector with elements belonging to 
bad.u2.N 
A numeric vector with elements belonging to 
Normally use the *_fit to pass the data to the fitting function.
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
1 2 
## See the vignettes for examples on how to run this analysis.

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.