msomData: msomData

Description Usage Arguments Details Value

View source: R/msomData.R

Description

Format Data for MSOM

Usage

1
2
3
4
msomData(Data, n0 = 10, formula = year ~ stratum ~ K ~ spp,
  cov.vars = c(bt = "btemp", doy = "doy", yr = "year"), u.form = ~bt +
  I(bt^2), v.form = ~doy + I(doy^2) + yr, valueName = "abund",
  cov.by = c("year", "stratum", "K"), u_rv = NULL, v_rv = NULL)

Arguments

Data

A data.table containing response variable and covariates. Must have a key

n0

An integer indicating the number of never-observed species to add

formula

A formula indicating the dimensions of the output array (only Default tested)

cov.vars

A named character vector of covariates, where character elements correspond to columns Data, and names will be predictor names in model

u.form

Formula for covariates to be included in U, the matrix of presence covariates

v.form

Formula for covariates to be included in V, the matrix of detection covariates

valueName

Character indicating column name containing response in Data

cov.by

Chracter vector of dimension names for covariates; order matters, specify most specific last. Should be elements in formula, and columns in Data.

u_rv, v_rv

Character string indicating variable names in u.form or v.form that should be converted from representation as predictors whose values are known precisely (casually referred to as "constant") to predictors that are random variables ("rv"). If NULL (default), it is assumed that all predictors are known precisely. See 'Details'.

Details

Only the defaults have been tested. Arguments that should be manipulated include u.form, v.form, cov.vars, and n0. Other values can be changed if they are only being adjusted to conform with column names in Data. Otherwise, it is unlikely that this function will behave as desired. In particular, the nesting of year, stratum, and K has to be the same (or whatever names are used).

Casting of Data is done via trawlCast. 0's are filled where appropriate, and NA's indicate no sampling. In the output, all NA's are replaced with 0's. However, the nK element of the output list indicates how many of the K are actually samples, and because K is not ordered, any 0's beyond the magnitude indicated in nK for that year-stratum combination are actually the NA's.

With regard to u_rv and v_rv, the intercept term cannot be converted to a random variable representation, although categorical predictors can (note, though, that the reference level will be embedded in the intercept, and thus it is implied to be known excactly). Terms represented in the formula with special notation (a:b, a*b, etc) will not be converted, although if a formula is u.form=~a*b, and u_rv=c("a"), a column that would be named "a" in the model matrix will be encoded as a random variable, whereas colmns "a:b" and "b" will not be RV's.

Value

A named list appropriate for use with msomStatic.stan


rBatt/trawlDiversity documentation built on Aug. 14, 2021, 1:01 p.m.