fitDeltaGLM: This function writes, and optionally runs the model in the...

Description Usage Arguments Value

View source: R/fitDeltaGLM.R

Description

This function writes, and optionally runs the model in the BUGS/JAGS framework

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
fitDeltaGLM(datalist = NULL, modelStructure = list(StrataYear.positiveTows =
  "random", VesselYear.positiveTows = "random", StrataYear.zeroTows = "random",
  VesselYear.zeroTows = "random", Vessel.positiveTows = "zero", Vessel.zeroTows
  = "zero", Catchability.positiveTows = "one", Catchability.zeroTows = "zero",
  year.deviations = "uncorrelated", strata.deviations = "uncorrelated"),
  covariates = list(positive = FALSE, binomial = FALSE),
  likelihood = "gamma", model.name = "deltaGLM.txt", fit.model = TRUE,
  write.model = TRUE, mcmc.control = list(chains = 5, thin = 1, burn = 5000,
  iterToSave = 2000), Parallel = TRUE, Species = "NULL",
  logitBounds = c(-20, 20), logBounds = c(-20, 20), prior.scale = rep(25,
  6), dgammaNum = 0.001)

Arguments

datalist

List of data passed in

modelStructure

list controlling mdoel components

StrataYear.positiveTows

Effects for strata:year interactions in positive model. Character string that is one of the following: "zero", "fixed", random", "random2", "randomExpanded", or "correlated". The "random", "random2" and "randomExpanded" treatments of normally distributed random effects differ in that "random" assigns a uniform prior on the random effects standard deviation, "random2" assigns an Inverse Gamma prior on the random effects precision, while "randomExpanded" assigns the folded non-central t-distribution as a prior on the random effect SD (Gelman 2006, Gelman et al. 2007). Specifying the effects as "correlated" also models deviations as random effects, but treats them as multivariate normal, with a correlation between the presence-absence model estimated. Defaults to "random".

VesselYear.positiveTows

Effects for vessel:year interactions in positive model. Character string that is one of the following: "zero", "fixed", random", "random2", "randomExpanded", or "correlated". The "random", "random2" and "randomExpanded" treatments of normally distributed random effects differ in that "random" assigns a uniform prior on the random effects standard deviation, "random2" assigns an Inverse Gamma prior on the random effects precision, while "randomExpanded" assigns the folded non-central t-distribution as a prior on the random effect SD (Gelman 2006, Gelman et al. 2007). Specifying the effects as "correlated" also models deviations as random effects, but treats them as multivariate normal, with a correlation between the presence-absence model estimated. Defaults to "random".

StrataYear.zeroTows

Effects for strata:year interactions in binomial model. Character string that is one of the following: "zero", "fixed", random", "random2", "randomExpanded", or "correlated". The "random", "random2" and "randomExpanded" treatments of normally distributed random effects differ in that "random" assigns a uniform prior on the random effects standard deviation, "random2" assigns an Inverse Gamma prior on the random effects precision, while "randomExpanded" assigns the folded non-central t-distribution as a prior on the random effect SD (Gelman 2006, Gelman et al. 2007). Specifying the effects as "correlated" also models deviations as random effects, but treats them as multivariate normal, with a correlation between the presence-absence model estimated. Defaults to "random".

VesselYear.zeroTows

Effects for vessel:year interactions in binomial model. Character string that is one of the following: "zero", "fixed", random", "random2", "randomExpanded", or "correlated". The "random", "random2" and "randomExpanded" treatments of normally distributed random effects differ in that "random" assigns a uniform prior on the random effects standard deviation, "random2" assigns an Inverse Gamma prior on the random effects precision, while "randomExpanded" assigns the folded non-central t-distribution as a prior on the random effect SD (Gelman 2006, Gelman et al. 2007). Specifying the effects as "correlated" also models deviations as random effects, but treats them as multivariate normal, with a correlation between the presence-absence model estimated. Defaults to "random".

Vessel.positiveTows

Effects for vessel interactions in positive model. Character string that is one of the following: "zero", "fixed", random", "random2", "randomExpanded", or "correlated". The "random", "random2" and "randomExpanded" treatments of normally distributed random effects differ in that "random" assigns a uniform prior on the random effects standard deviation, "random2" assigns an Inverse Gamma prior on the random effects precision, while "randomExpanded" assigns the folded non-central t-distribution as a prior on the random effect SD (Gelman 2006, Gelman et al. 2007). Specifying the effects as "correlated" also models deviations as random effects, but treats them as multivariate normal, with a correlation between the presence-absence model estimated. Defaults to "zero".

Vessel.zeroTows

Effects for vessel interactions in binomial model. Character string that is one of the following: "zero", "fixed", random", "random2", "randomExpanded", or "correlated". The "random", "random2" and "randomExpanded" treatments of normally distributed random effects differ in that "random" assigns a uniform prior on the random effects standard deviation, "random2" assigns an Inverse Gamma prior on the random effects precision, while "randomExpanded" assigns the folded non-central t-distribution as a prior on the random effect SD (Gelman 2006, Gelman et al. 2007). Specifying the effects as "correlated" also models deviations as random effects, but treats them as multivariate normal, with a correlation between the presence-absence model estimated. Defaults to "zero".

Catchability.positiveTows

Specify offset for the positive model. Can be fixed ("one"), or estimated ("linear", "quadratic"). If "E" represents effort, the offset is included in the following form, ln(u) = ... + B1ln(E) + B2(ln(E)^2). Defaults to "one".

Catchability.zeroTows

Specify offset for the presence-absence model. Can be fixed ("zero","one"), or estimated ("linear", "quadratic"). If "E" represents effort, the offset is included in the following form, logit(p) = ... + B1E + B2(E^2). Defaults to "zero".

year.deviations

Argument ("correlated","uncorrelated") specifying whether year deviations should be estimated as correlated random effects (correlation between presence-absence and positive model deviates estimated). By default, this is "uncorrelated", meaning year deviations are included as fixed effects.

strata.deviations

Argument ("correlated","uncorrelated") specifying whether strata deviations should be estimated as correlated random effects (correlation between presence-absence and positive model deviates estimated). By default, this is "uncorrelated", meaning strata deviations are included as fixed effects.

covariates

Two element vector specifying whether covariates are included.

positive

Boolean, defaults to FALSE

binomial

Boolean, defaults to FALSE

likelihood

Character string specifying the form of the positive model. Can be one of the following: "gamma" (or "gammaFixedCV"), "lognormal" (or "lognormalFixedCV"), "invGaussian" (or "invGaussianFixedCV"), "lognormalECE", "gammaECE", "poisson", "zt_poisson", or "negbin". Defaults to "gamma". The forms of the model are as follows:

gamma

Models the response as continuous from a Gamma distribution, with a log-link. The form of the Gamma distribution used is Y ~ Gamma(shape = a, rate = b), where E(Y) = a / b, and CV(Y) = 1 / sqrt(a). For consistency with the lognormal, the CV^2 is assigned an Inverse Gamma (0.001,0.001) prior. If the distribution is specified as "gammaFixedCV", the CV = 1

lognormal

Models the response as continuous from a lognormal distribution, with a log-link. The CV^2 is assigned an Inverse Gamma (0.001,0.001) prior, and the variance of the lognormal distribution is calculated as var = (log(CV^2)+1). If the distribution is specified as "lognormalFixedCV", the CV = 1

invGaussian

Models the response as continuous from an inverse Gaussian (Wald) distribution, with a log-link. The parameterization is in terms of the mean (u) and variance (u^3 / lambda). This model is considerably slower than the lognormal or gamma because the "zeros" trick needs to be implemented. For consistency with the other distributions, the CV^2 is assigned an Inverse Gamma (0.001,0.001) prior. If the distribution is specified as "invGaussianFixedCV", the CV = 1.

gammaECE

Extends the gamma distribution to model the positive distribution as a 2-component mixture (normal and "extreme catch events", Thorson 2011). The probability of membership in each class ("normal", "extreme") is estimated. Extreme catch events are allowed to have a separate estimated variance parameter (or CV). The mean of extreme catch events is also estimated; for identifiability, this is estimated as an offset from normal catch events in link-space, e.g. log(u_extreme) = log(u_normal) + logratio, where the "logratio" parameter is assigned a log-uniform(0,5) prior distribution.

lognormalECE

Extends the lognormal distribution to model the positive distribution as a 2-component mixture (normal and "extreme catch events", Thorson 2011). The probability of membership in each class ("normal", "extreme") is estimated. Extreme catch events are allowed to have a separate estimated variance parameter (or CV). The mean of extreme catch events is also estimated; for identifiability, this is estimated as an offset from normal catch events in link-space, e.g. log(u_extreme) = log(u_normal) + logratio, where the "logratio" parameter is assigned a log-uniform(0,5) prior distribution.

poisson

Models the response as discrete counts from the Poisson distribution, parameterized using the log-link function, Y ~ Poisson(u), with log(u) = B0 + B1*X. Because this is a delta-GLM model, applying the Poisson distribution isn't really appropriate when counts are small (zeros are a possibility). The zt_poisson distribution is more appropriate for these settings.

ztpoisson

Models the response as discrete counts from the zero-truncated Poisson distribution, parameterized using the log-link Y ~ Poisson(u), log(u) = B0 + B1X. This is more appropriate for small count data than the poisson. Because this implements the zeros trick to calculate the likelihood, estimation is slower than the traditional Poisson

negbin

Models the response as discrete counts from the Negative binomial distribution, parameterized using the log-link function, Y ~ NegBin(u, r), with log(u) = B0 + B1X.

model.name

Character string specifying the name of the JAGS txt file that is written to the working directory. Defaults "to deltaGLM.txt"

fit.model

Boolean, specifying whether the model should be fit or not. Defaults to TRUE; if FALSE, just the JAGS script file is written.

write.model

Boolean, whether to write model to a file. Defaults to TRUE

mcmc.control

List of parameter to control MCMC estimation

chains

Number of MCMC chains to estimate

thin

Thinning rate, defaults to 1

burn

Burn in period, defaults to 5000

iterToSave

iterations to save after burn-in, defaults to 2000

Parallel

Whether to conduct estimation using parallel computing (faster), using the function jags.parallel().

Species

Species name, defaults to "NULL"

logitBounds

2 element vector specifying bounds of logit link space. Defaults c(-20,20)

logBounds

2 element vector specifying bounds of log link space. Defaults c(-20,20)

prior.scale

Scale parameter for the variance parameter of the "randomExpanded" random effects. This is a 6 element vector, defaults to (25, 25, 25, 25, 25, 25), where the elements are (strataYear.positive, strataYear.presenceAbsence, vesselYear.positive, vesselYear.presenceAbsence, vessel.positive, vessel.presenceAbsence)

dgammaNum

Prior on precision parameters, e.g. tau ~ dgamma(dgammaNum, dgammaNum). Defaults to 0.001

Value

list of the following

modelFit

fitted model object

functionCall

function call, for reproducibility

estimatedParameters

estimated parameters

Species

Species name

Data

Data used to estimate parameters


nwfsc-assess/nwfscDeltaGLM documentation built on April 4, 2018, 3:06 p.m.