Package 'BTSPAS'

Title: Bayesian Time-Stratified Population Analysis
Description: Provides advanced Bayesian methods to estimate abundance and run-timing from temporally-stratified Petersen mark-recapture experiments. Methods include hierarchical modelling of the capture probabilities and spline smoothing of the daily run size. Theory described in Bonner and Schwarz (2011) <doi:10.1111/j.1541-0420.2011.01599.x>.
Authors: Carl J Schwarz [aut, cre], Simon J Bonner [aut]
Maintainer: Carl J Schwarz <[email protected]>
License: GPL (>= 2)
Version: 2024.11.1
Built: 2024-11-23 06:21:09 UTC
Source: CRAN

Help Index


Logit and anti-logit function.

Description

Compute the logit or anti-logit.

Usage

logit(p)

expit(theta)

Arguments

p

probability between 0 and 1.

theta

logit between -infinity and +infinity

Value

Computed logit or anti-logit

Author(s)

C.J.Schwarz [email protected]

Examples

##---- compute the logit and its inverse
logitp <- logit(.3)
p <- expit(-.84)

Compute percentiles of the run timing distribution.

Description

Take the posterior sample of U[1,...nstrata] and compute the percentiles of the run timing. This uses the quantile() function from the "actuar" package which is designed to compute quantiles of grouped data. It is assumed that there are no fish in the system prior to the first point

Usage

RunTime(time, U, prob = seq(0, 1, 0.1))

Arguments

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.

U

matrix of posterior samples. Each row is a sample from the posterior.

prob

Quantiles of the run timing to estimate.

Value

An MCMC object with samples from the posterior distribution. A series of graphs and text file are also created in the working directory. This information is now added to the fit object as well and so it is unlikely that you will use this function.

Author(s)

Bonner, S.J. [email protected] and Schwarz, C. J. [email protected].

References

Bonner, S. J., & Schwarz, C. J. (2011). Smoothing population size estimates for Time-Stratified Mark-Recapture experiments Using Bayesian P-Splines. Biometrics, 67, 1498-1507. doi:10.1111/j.1541-0420.2011.01599.x

Schwarz, C. J., & Dempson, J. B. (1994). Mark-recapture estimation of a salmon smolt population. Biometrics, 50, 98-108.

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.trrp.net/library/document/?id=369


Simple Petersen Estimator and test if pooling can be done

Description

Computes the Petersen estimator (Chapman correction applied) for the number of UNMARKED animals (U) and total population (N) given n1, m2, and u2.

Usage

SimplePetersen(n1, m2, u2)

Arguments

n1

Number of animals tagged and released. Can be a vector in which the estimate is formed for each element of the vector

m2

Number of animals from n1 that are recaptured.

u2

Number of unmarked animals in the second sample.

Value

Data frame with variables U.est, U.se, N.est, and N.se. .

Author(s)

Bonner, S.J. [email protected] and Schwarz, C. J. [email protected].

Examples

SimplePetersen( 200, 10, 300) 
SimplePetersen(c(200,400), c(10,20), c(300,600))

Wrapper (*_fit) to call the Time Stratified Petersen Estimator with Diagonal Entries function.

Description

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.

Usage

TimeStratPetersenDiagError_fit(
  title = "TSDPE",
  prefix = "TSPDE-",
  time,
  n1,
  m2,
  u2,
  sampfrac = rep(1, length(u2)),
  jump.after = NULL,
  bad.n1 = c(),
  bad.m2 = c(),
  bad.u2 = c(),
  logitP.cov = as.matrix(rep(1, length(n1))),
  logitP.fixed = NULL,
  logitP.fixed.values = NULL,
  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,
  set.browser = FALSE
)

Arguments

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 prefix-xxxxx.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.

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.

sampfrac

Deprecated because it really doesn't work as intended. You must remove all references to sampfrac from your code. Contact [email protected] for more information.

jump.after

A numeric vector with elements belonging to time. In some cases, the spline fitting the population numbers should be allowed to jump. For example, the population size could take a jump when hatchery released fish suddenly arrive at the trap. The jumps occur AFTER the strata listed in this argument.

bad.n1

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of marked fish releases should be discarded. The values of n1 and m2 will be set to 0 for these strata.

bad.m2

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of recovered marked fish should be ignored. For example, poor handling is suspected to induce handling induced mortality in the marked fish and so only very few are recovered. The values of n1 and m2 will be set to 0 for these strata.

bad.u2

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of unmarked fish captured should be ignored. The values of u2 in the entire row will be set to NA for these strata. DO NOT SET the value of u2 to 0 because this indicates that the trap was operating and captured no fish.

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

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.

n.chains

Number of parallel MCMC chains to fit.

n.iter

Total number of MCMC iterations in each chain.

n.burnin

Number of burn-in iterations.

n.sims

Number of simulated values to keeps for posterior distribution.

tauU.alpha

One of the parameters along with tauU.beta for the prior for the variance of the random noise for the smoothing spline.

tauU.beta

One of the parameters along with tauU.alpha for the prior for the variance of the random noise for the smoothing spline.

taueU.alpha

One of the parameters along with taueU.beta for the prior for the variance of noise around the spline.

taueU.beta

One of the parameters along with taueU.alpha for the prior for the variance of noise around the spline.

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 browser() calls to allow the user to peek into the internal variables. Not useful except to package developers.

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.

set.browser

Should the function enter browser model when called (useful for debugging)

Details

Normally, the wrapper (*_fit) function is called which then calls the fitting routine.

Use the TimeStratPetersenNonDiagError_fit function for cases where recaptures take place outside the stratum of release.

Value

An MCMC object with samples from the posterior distribution. A series of graphs and text file are also created in the working directory.

Author(s)

Bonner, S.J. [email protected] and Schwarz, C. J. [email protected].

References

Bonner, S. J., & Schwarz, C. J. (2011). Smoothing population size estimates for Time-Stratified Mark-Recapture experiments Using Bayesian P-Splines. Biometrics, 67, 1498-1507. doi:10.1111/j.1541-0420.2011.01599.x

Schwarz, C. J., & Dempson, J. B. (1994). Mark-recapture estimation of a salmon smolt population. Biometrics, 50, 98-108.

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.trrp.net/library/document/?id=369


Wrapper (*_fit) to fit the Time Stratified Petersen Estimator with Diagonal Entries and separating Wild from Hatchery Chinook function.

Description

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.

Usage

TimeStratPetersenDiagErrorWHChinook2_fit(
  title = "TSPDE-WHChinook2",
  prefix = "TSPDE-WHChinook2-",
  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 = "TSPDE-WHChinook",
  prefix = "TSPDE-WHChinook-",
  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
)

Arguments

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 prefix-xxxxx.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 TimeStratPetersenNonDiagError_fit function for cases where recaptures take place outside the stratum of release.

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 [email protected] for more information.

hatch.after.YoY

A numeric vector with elements belonging to time. At which point do YoY hatchery fish arrive? They arrive in the immediate stratum AFTER these entries.

bad.m2

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of recovered marked fish should be ignored. For example, poor handling is suspected to induce handling induced mortality in the marked fish and so only very few are recovered. The values of n1 and m2 will be set to 0 for these strata.

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 burn-in iterations.

n.sims

Number of simulated values to keeps for posterior distribution.

tauU.alpha

One of the parameters along with tauU.beta for the prior for the variance of the random noise for the smoothing spline.

tauU.beta

One of the parameters along with tauU.alpha for the prior for the variance of the random noise for the smoothing spline.

taueU.alpha

One of the parameters along with taueU.beta for the prior for the variance of noise around the spline.

taueU.beta

One of the parameters along with taueU.alpha for the prior for the variance of noise around the spline.

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 browser() calls to allow the user to peek into the internal variables. Not useful except to package developers.

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 NO-adipose 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 time. At which point do hatchery fish arrive? They arrive in the immediate stratum AFTER these entries.

bad.n1

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of marked fish releases should be discarded. The values of n1 and m2 will be set to 0 for these strata.

bad.u2.A

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of unmarked fish with an adipose fin clip should be ignored.

bad.u2.N

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of unmarked fish with NO adipose fin clip should be ignored.

Details

Normally use the *_fit to pass the data to the fitting function.

Value

An MCMC object with samples from the posterior distribution. A series of graphs and text file are also created in the working directory.

Author(s)

Bonner, S.J. [email protected] and Schwarz, C. J. [email protected].

References

Bonner, S. J., & Schwarz, C. J. (2011). Smoothing population size estimates for Time-Stratified Mark-Recapture experiments Using Bayesian P-Splines. Biometrics, 67, 1498-1507. doi:10.1111/j.1541-0420.2011.01599.x

Schwarz, C. J., & Dempson, J. B. (1994). Mark-recapture estimation of a salmon smolt population. Biometrics, 50, 98-108.

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.trrp.net/library/document/?id=369

Examples

##---- See the vignettes for examples on how to run this analysis.

Wrapper (*_fit) and function to call the Time Stratified Petersen Estimator with Diagonal Entries and separating Wild from Hatchery Steelhead function.

Description

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.

Usage

TimeStratPetersenDiagErrorWHSteel_fit(
  title = "TSPDE-WHSteel",
  prefix = "TSPDE-WHSteel-",
  time,
  n1,
  m2,
  u2.W.YoY,
  u2.W.1,
  u2.H.1,
  sampfrac = rep(1, length(u2.W.YoY)),
  hatch.after = NULL,
  bad.n1 = c(),
  bad.m2 = c(),
  bad.u2.W.YoY = c(),
  bad.u2.W.1 = c(),
  bad.u2.H.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
)

Arguments

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 prefix-xxxxx.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 TimeStratPetersenNonDiagError_fit function for cases where recaptures take place outside the stratum of release.

u2.W.YoY

A numeric vector of the number of unmarked wild Young-of-Year fish captured in each stratum.

u2.W.1

A numeric vector of the number of unmarked wild age 1+ fish captured in each stratum.

u2.H.1

A numeric vector of the number of unmarked hatchery age 1+ fish (i.e. adipose fin clipped) captured in each stratum.

sampfrac

Deprecated because it really doesn't work as intended. You must remove all references to sampfrac from your code. Contact [email protected] for more information.

hatch.after

A numeric vector with elements belonging to time. At which point do hatchery fish arrive? They arrive in the immediate stratum AFTER these entries.

bad.n1

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of marked fish releases should be discarded. The values of n1 and m2 will be set to 0 for these strata.

bad.m2

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of recovered marked fish should be ignored. For example, poor handling is suspected to induce handling induced mortality in the marked fish and so only very few are recovered. The values of n1 and m2 will be set to 0 for these strata.

bad.u2.W.YoY

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of wild unmarked Young-of-Year fish should be ignored.

bad.u2.W.1

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of wild unmarked age 1+ fish should be ignored.

bad.u2.H.1

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of hatchery unmarked (but adipose fin clipped) age 1+ fish should be ignored.

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 burn-in iterations.

n.sims

Number of simulated values to keeps for posterior distribution.

tauU.alpha

One of the parameters along with tauU.beta for the prior for the variance of the random noise for the smoothing spline.

tauU.beta

One of the parameters along with tauU.alpha for the prior for the variance of the random noise for the smoothing spline.

taueU.alpha

One of the parameters along with taueU.beta for the prior for the variance of noise around the spline.

taueU.beta

One of the parameters along with taueU.alpha for the prior for the variance of noise around the spline.

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 browser() calls to allow the user to peek into the internal variables. Not useful except to package developers.

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.

Details

Normally, data is passed to the wrapper which then calls the fitting function.

Value

An MCMC object with samples from the posterior distribution. A series of graphs and text file are also created in the working directory.

Author(s)

Bonner, S.J. [email protected] and Schwarz, C. J. [email protected].

References

Bonner, S. J., & Schwarz, C. J. (2011). Smoothing population size estimates for Time-Stratified Mark-Recapture experiments Using Bayesian P-Splines. Biometrics, 67, 1498-1507. doi:10.1111/j.1541-0420.2011.01599.x

Schwarz, C. J., & Dempson, J. B. (1994). Mark-recapture estimation of a salmon smolt population. Biometrics, 50, 98-108.

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.trrp.net/library/document/?id=369

Examples

##---- See the vignettes for example on how to use this package.

Wrapper (*_fit) to fit the Time Stratified Petersen Estimator with NON Diagonal Entries function.

Description

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.

Usage

TimeStratPetersenNonDiagError_fit(
  title = "TSPNDE",
  prefix = "TSPNDE-",
  time,
  n1,
  m2,
  u2,
  sampfrac = rep(1, length(u2)),
  jump.after = NULL,
  bad.n1 = c(),
  bad.m2 = c(),
  bad.u2 = c(),
  logitP.cov = as.matrix(rep(1, length(u2))),
  logitP.fixed = NULL,
  logitP.fixed.values = NULL,
  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,
  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
)

Arguments

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 prefix-xxxxx.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 [j-1] 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 TimeStratPetersenDiagError_fit function for cases where recaptures take place ONLY in the stratum of release, i.e. the diagonal case.

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 [email protected] for more information.

jump.after

A numeric vector with elements belonging to time. In some cases, the spline fitting the population numbers should be allowed to jump. For example, the population size could take a jump when hatchery released fish suddenly arrive at the trap. The jumps occur AFTER the strata listed in this argument.

bad.n1

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of marked fish releases should be discarded. The values of n1 and m2 will be set to 0 for these strata.

bad.m2

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of recovered marked fish should be ignored. For example, poor handling is suspected to induce handling induced mortality in the marked fish and so only very few are recovered. The values of n1 and m2 will be set to 0 for these strata.

bad.u2

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of unmarked fish captured should be ignored. The values of u2 in the entire row will be set to NA for these strata. DO NOT SET the value of u2 to 0 because this indicates that the trap was operating and captured no fish.

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

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.

n.chains

Number of parallel MCMC chains to fit.

n.iter

Total number of MCMC iterations in each chain.

n.burnin

Number of burn-in iterations.

n.sims

Number of simulated values to keeps for posterior distribution.

tauU.alpha

One of the parameters along with tauU.beta for the prior for the variance of the random noise for the smoothing spline.

tauU.beta

One of the parameters along with tauU.alpha for the prior for the variance of the random noise for the smoothing spline.

taueU.alpha

One of the parameters along with taueU.beta for the prior for the variance of noise around the spline.

taueU.beta

One of the parameters along with taueU.alpha for the prior for the variance of noise around the spline.

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 browser() calls to allow the user to peek into the internal variables. Not useful except to package developers.

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.

Details

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 non-diagonal case fits a log-normal distribution for the travel time. The *NP functions fit a non-parametric 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.

Value

An MCMC object with samples from the posterior distribution. A series of graphs and text file are also created in the working directory.

Author(s)

Bonner, S.J. [email protected] and Schwarz, C. J. [email protected].

References

Bonner, S. J., & Schwarz, C. J. (2011). Smoothing population size estimates for Time-Stratified Mark-Recapture experiments Using Bayesian P-Splines. Biometrics, 67, 1498-1507. doi:10.1111/j.1541-0420.2011.01599.x

Schwarz, C. J., & Dempson, J. B. (1994). Mark-recapture estimation of a salmon smolt population. Biometrics, 50, 98-108.

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.trrp.net/library/document/?id=369

Examples

##---- See the vignettes for examples of how to use this package

Wrapper (*_fit) to fit the Time Stratified Petersen Estimator with NON Diagonal Entries function and a non-parametric travel time estimator..

Description

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.

Usage

TimeStratPetersenNonDiagErrorNP_fit(
  title = "TSPNDENP",
  prefix = "TSPNDENP-",
  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,
  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,
  prior.muTT = 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, 1e+06)),
  save.output.to.files = TRUE,
  trunc.logitP = 15
)

Arguments

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 prefix-xxxxx.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 [j-1] 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 TimeStratPetersenDiagError_fit function for cases where recaptures take place ONLY in the stratum of release, i.e. the diagonal case.

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 [email protected] for more information.

jump.after

A numeric vector with elements belonging to time. In some cases, the spline fitting the population numbers should be allowed to jump. For example, the population size could take a jump when hatchery released fish suddenly arrive at the trap. The jumps occur AFTER the strata listed in this argument.

bad.n1

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of marked fish releases should be discarded. The values of n1 and m2 will be set to 0 for these strata.

bad.m2

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of recovered marked fish should be ignored. For example, poor handling is suspected to induce handling induced mortality in the marked fish and so only very few are recovered. The values of n1 and m2 will be set to 0 for these strata.

bad.u2

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of unmarked fish captured should be ignored. The values of u2 in the entire row will be set to NA for these strata. DO NOT SET the value of u2 to 0 because this indicates that the trap was operating and captured no fish.

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

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.

n.chains

Number of parallel MCMC chains to fit.

n.iter

Total number of MCMC iterations in each chain.

n.burnin

Number of burn-in iterations.

n.sims

Number of simulated values to keeps for posterior distribution.

tauU.alpha

One of the parameters along with tauU.beta for the prior for the variance of the random noise for the smoothing spline.

tauU.beta

One of the parameters along with tauU.alpha for the prior for the variance of the random noise for the smoothing spline.

taueU.alpha

One of the parameters along with taueU.beta for the prior for the variance of noise around the spline.

taueU.beta

One of the parameters along with taueU.alpha for the prior for the variance of noise around the spline.

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

prior.muTT

- prior for movement rates. These are like a Dirchelet type prior where x are values representing belief in the travel times. For example, x=c(1,4,3,2) represents a system where the maximum travel time is 3 strata after release with 1/10=.1 of the animals moving in the stratum of release 4/10=.4 of the animals taking 1 stratum to move etc So if x=c(10,40,30,20), this represent the same movement pattern but a strong degree of belief

tauTT.alpha

One of the parameters along with tauTT.beta for the prior on 1/var of logit continuation ratio for travel times

tauTT.beta

One of the parameters along with tauTT.alpha for the prior on 1/var of logit continuation ratio for travel times

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 browser() calls to allow the user to peek into the internal variables. Not useful except to package developers.

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.

Details

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 *NP functions fit a non-parametric distribution for the travel times.

Value

An MCMC object with samples from the posterior distribution. A series of graphs and text file are also created in the working directory.

Author(s)

Bonner, S.J. [email protected] and Schwarz, C. J. [email protected].

References

Bonner, S. J., & Schwarz, C. J. (2011). Smoothing population size estimates for Time-Stratified Mark-Recapture experiments Using Bayesian P-Splines. Biometrics, 67, 1498-1507. doi:10.1111/j.1541-0420.2011.01599.x

Schwarz, C. J., & Dempson, J. B. (1994). Mark-recapture estimation of a salmon smolt population. Biometrics, 50, 98-108.

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.trrp.net/library/document/?id=369

Examples

##---- See the vignette  for examples of how to use this package
##

Wrapper (*_fit) to call the function to fit a Time Stratified Petersen Estimator with NON Diagonal Entries with an non-parametric travel time and fall back

Description

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.

Usage

TimeStratPetersenNonDiagErrorNPMarkAvail_fit(
  title = "TSPNDENP-avail",
  prefix = "TSPNDENP-avail-",
  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
)

Arguments

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 prefix-xxxxx.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 [j-1] 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 TimeStratPetersenDiagError_fit function for cases where recaptures take place ONLY in the stratum of release, i.e. the diagonal case.

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 [email protected] for more information.

jump.after

A numeric vector with elements belonging to time. In some cases, the spline fitting the population numbers should be allowed to jump. For example, the population size could take a jump when hatchery released fish suddenly arrive at the trap. The jumps occur AFTER the strata listed in this argument.

bad.n1

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of marked fish releases should be discarded. The values of n1 and m2 will be set to 0 for these strata.

bad.m2

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of recovered marked fish should be ignored. For example, poor handling is suspected to induce handling induced mortality in the marked fish and so only very few are recovered. The values of n1 and m2 will be set to 0 for these strata.

bad.u2

A numeric vector with elements belonging to time. In some cases, something goes wrong in the stratum, and the number of unmarked fish captured should be ignored. The values of u2 in the entire row will be set to NA for these strata. DO NOT SET the value of u2 to 0 because this indicates that the trap was operating and captured no fish.

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

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 burn-in iterations.

n.sims

Number of simulated values to keeps for posterior distribution.

tauU.alpha

One of the parameters along with tauU.beta for the prior for the variance of the random noise for the smoothing spline.

tauU.beta

One of the parameters along with tauU.alpha for the prior for the variance of the random noise for the smoothing spline.

taueU.alpha

One of the parameters along with taueU.beta for the prior for the variance of noise around the spline.

taueU.beta

One of the parameters along with taueU.alpha for the prior for the variance of noise around the spline.

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 for the prior on 1/var of logit continuation ratio for travel times

tauTT.beta

One of the parameters along with tauTT.alpha for the prior on 1/var of logit continuation ratio for travel times

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 browser() calls to allow the user to peek into the internal variables. Not useful except to package developers.

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.

Details

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 non-diagonal case fits a log-normal distribution for the travel time. The *NP functions fit a non-parametric 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.

Value

An MCMC object with samples from the posterior distribution. A series of graphs and text file are also created in the working directory.

Author(s)

Bonner, S.J. [email protected] and Schwarz, C. J. [email protected].

References

Bonner, S. J., & Schwarz, C. J. (2011). Smoothing population size estimates for Time-Stratified Mark-Recapture experiments Using Bayesian P-Splines. Biometrics, 67, 1498-1507. doi:10.1111/j.1541-0420.2011.01599.x

Schwarz, C. J., & Dempson, J. B. (1994). Mark-recapture estimation of a salmon smolt population. Biometrics, 50, 98-108.

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.trrp.net/library/document/?id=369

Examples

##---- See the vignettes  for examples of how to use this package

Computes and plots posterior distribution of time to get target run size. For example, the time to reach a cumulative run of 10,000 fish.

Description

Takes a sim.list object from the MCMC runs, computes the posterior distribution of the time to the target runsize, plots the posterior #'

Usage

TimeToTargetRunSize(U, time, targetU, file_prefix, ci_prob = 0.95)

Arguments

U

Elements of sim.list from MCMC object for U - the estimate runsize in each stratum

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.

targetU

The targeted cumulative run size. E.g. 10,000

file_prefix

Character string giving prefix for plot. A plot will be produced of the posterior in the filename paste(file_prefix,"-target.pdf",sep="")).

ci_prob

What size of credible interval should be computed?

Value

A list with a sample of the posterior (index), quantiles (quantiles), mean (mean), median(median), and standard deviation (sd), and target value (targetU)

Author(s)

Bonner, S.J. [email protected] and Schwarz, C. J. [email protected].

Examples

## Not run: 
# Compute the posterior of time to reach 10,000 fish. Results contains the MCMC object
# 
results$TimeToTargetRunSize <- TimeToTargetRunSize( 
        U=results$sims.list$U,
        time=results$data$time,
        targetU=10000,
        file_prefix = 'Time10000')


## End(Not run) # end of dontrun