LINPRED {nimbleMacros} | R Documentation |
Macro to build code for linear predictor from R formula
Description
Converts an R formula into corresponding code for a linear predictor in NIMBLE model code. Options are available to specify a link function and to also generate code for priors corresponding to the parameters in the linear predictor.
Arguments
formula |
An R formula, possibly with the parameters followed by
brackets containing indices. If there are no indices, the macro attempts
to guess the correct indices from the context. The formula must be
right-hand side only (e.g. |
link |
A link function that will be applied to the left-hand-side (the response) in the final linear predictor. Default is none. |
coefPrefix |
All model coefficient names will begin with this prefix.
default is |
sdPrefix |
All dispersion parameters will begin with this prefix. Default is no prefix. |
priors |
Prior specifications, generated with |
modelMatrixNames |
Logical indicating if parameters should be named so they match the
names one would get from R's |
noncentered |
Logical indicating whether to use noncentered parameterization
for random effects. Default is |
centerVar |
Grouping variable (covariate) to 'center' the random effects on.
By default (when NULL), random effects come from normal distributions with mean 0
as with |
modelInfo |
Used internally by nimbleMacros; a list of model information such as constants and dimensions |
.env |
Used internally by nimbleMacros; the environment where the model was created |
Value
NIMBLE code for the linear predictor specified by the formula, and optionally the associated priors.
Author(s)
Ken Kellner
Examples
constants <- list(x = rnorm(3), x2 = factor(letters[1:3]))
code <- nimbleCode({
mu[1:3] <- LINPRED(~x + x2)
})
mod <- nimbleModel(code, constants = constants)
mod$getCode()