jsdm_stancode: Make stancode for the jsdm model

View source: R/jsdm_stancode.R

jsdm_stancodeR Documentation

Make stancode for the jsdm model

Description

This function returns the Stan code used to fit the model as specified by the data list, family and method.

Usage

jsdm_stancode(
  method,
  family,
  prior = jsdm_prior(),
  log_lik = TRUE,
  site_intercept = "none",
  beta_param = "cor",
  zi_param = "constant"
)

## S3 method for class 'jsdmstan_model'
print(x, ...)

Arguments

method

The method, one of "gllvm" or "mglmm"

family

is the response family, must be one of "gaussian", "neg_binomial", "poisson", "binomial", "bernoulli", "zi_poisson", or "zi_neg_binomial". Regular expression matching is supported.

prior

The prior, given as the result of a call to jsdm_prior()

log_lik

Whether the log likelihood should be calculated in the generated quantities (by default TRUE), required for loo

site_intercept

Whether a site intercept should be included, potential values "none" (no site intercept), "grouped" (a site intercept with hierarchical grouping) or "ungrouped" (site intercept with no grouping)

beta_param

The parameterisation of the environmental covariate effects, by default "cor". See details for further information.

zi_param

For the zero-inflated families, whether the zero-inflation parameter is a species-specific constant (default, "constant"), or varies by environmental covariates ("covariate").

x

The jsdm_stancode object

...

Currently unused

Details

Environmental covariate effects ("betas") can be parameterised in two ways. With the "cor" parameterisation all covariate effects are assumed to be constrained by a correlation matrix between the covariates. With the "unstruct" parameterisation all covariate effects are assumed to draw from a simple distribution with no correlation structure. Both parameterisations can be modified using the prior object.

Value

A character vector of Stan code, class "jsdmstan_model"

Functions

  • print(jsdmstan_model): A printing function for jsdmstan_model objects

Examples

jsdm_stancode(family = "gaussian", method = "gllvm")
jsdm_stancode(family = "poisson", method = "mglmm")


fseaton/jsdmstan documentation built on Sept. 29, 2024, 6:40 p.m.