modelDefinitionToNIMBLE: Convert a Model Definition into NIMBLE Code

View source: R/mcmcInternals.R

modelDefinitionToNIMBLER Documentation

Convert a Model Definition into NIMBLE Code

Description

A function to create a full NIMBLE model definition from a standard model specification with a syntax similar to that used in the glm model specification

Usage

modelDefinitionToNIMBLE(
  formula,
  data,
  family = "gaussian",
  link = "identity",
  centreCovs = TRUE,
  scaleCovs = TRUE,
  suffix = "",
  sharedTermNode = NULL,
  ...
)

Arguments

formula

A formula that takes a similar form to that used in glm except that hierarchical components can be added to the model specification using the h function. In addition it is possible to specify random effects from INLA using the f function.

data

A data.frame, list, or inla.data.stack object containing the data to apply the model formula to.

family

The specification of the likelihood family to use. The default is a Gaussian distribution with identity link. The argument can either be a string containing the name of the likelihood family (case insensitive) or a family object containing the family and link function specification. If the family argument is a string then the link argument can be used to specify an alternative link function than the default link function for that distribution. See names(errorFamilites()) for a list of natively supported error distributions. Alternatively, the user can specify a custom error distribution through the application of the customError function.

link

A character scalar giving the name of the link function to be used with the likelihood family. See unique(unlist(errorFamilies())) for a list of natively-supported link functions.

centreCovs

A logical scalar denoting whether the fixed effects in the model should be centred before the analysis: each covariate element is subtracted by its mean. centreCovs can also be a function with one argument that is a vector of covariate values. In this case the variable is instead centred around the output of this function.

scaleCovs

A logical scalar denoting whether the fixed effects in the model should be scaled before the analysis: each covariate element is divided by its standard deviation. scaleCovs can also be a function with one argument that is a vector of covariate values. In this case the variable is instead scaled around the output of this function.

suffix

A character scalar that will be appended to all variables used in the NIMBLE code (including constants and data)

sharedTermNode

A character containing the name of a node containing the expectation that is shared across different likelihoods. Defaults to NULL and this default should be used in most cases where the model specification isn't being combined with a larger model component

...

Other parameters that are passed to the error distribution processing functions

Value

A list object containing the following named elements:

responseValues

The values of the response variable

responseName

The name of the response variable

hFunctions

Calls to special 'h' functions

fFunctions

Calls to special 'f' functions

sFunctions

Calls to special 's' functions

covNames

The names of the covariates used in the model specification and equivalent valid names to use in the NIMBLE model

covFrame

A data frame of the processed covariates

modelMatrix

A model matrix resulted from an expansion of the covariates performed by model.matrix

offetFrame

A data frame of offset terms used in the model

code

NIMBLE model specification code for the model defined using the input parameters (see nimbleCode)

constants

A list of constants to be passed to NIMBLE (see nimbleModel)

data

A list of data to be passed to NIMBLE (see nimbleModel)

inits

A list of starting values for model variables to be passed to NIMBLE (see nimbleModel)

dimensions

Named list of dimensions for variables to be passed to NIMBLE (see nimbleModel)

monitors

A character vector of names of variables to record during MCMC sampling in NIMBLE (see configureMCMC)

monitors2

A character vector of names of varaibles to record during MCMC sampling in NIMBLE with a different thinning interval (see configureMCMC)

hierAttributes

A list containing attributes that are set in each of the hierarchical component models

link

A link list structure (as returned from customLink) that defines the link function used in the model

family

A error distribution list structure (as returned from customError) that defines the error distribution used in the model

Author(s)

Joseph D. Chipperfield, joechip90@googlemail.com

See Also

nimbleCode customLink customError errorFamilies glm inla.stack.data model.matrix nimbleModel configureMCMC


joechip90/PaGAn documentation built on April 17, 2025, 4:05 p.m.