vm_stan: Create a Stan class VM object

View source: R/modeler.R

vm_stanR Documentation

Create a Stan class VM object

Description

Internal function to create and compile a Stan model.

Usage

vm_stan(
  design = c("V -> Y", "V -> M -> Y", "V", "X -> V", "X -> V -> Y", "X -> M -> V"),
  useU = TRUE,
  UQ = FALSE,
  IIVQ = FALSE,
  centerU = 0,
  centerIIV = 0,
  ...,
  template_only = FALSE
)

Arguments

design

A character string indicating the type of model to be run. One of “V -> Y” for variability predicting an outcome, “V -> M -> Y” for mediation of variability on an outcome, “V” to take posterior samples of individual variability estimates alone.

useU

A logical value whether the latent intercept estimated in Stage 1 should also be used as a predictor. Defaults to TRUE. Note if there is a mediator as well as main outcome, the latent intercepts will be used as a predictor for both.

UQ

A logical value whether the latent intercept estimated in Stage 1 should also be used as a predictor with a qudratice effect. Defaults to FALSE. Note if there is a mediator as well as main outcome, the latent intercepts will be used as a predictor for both.

IIVQ

A logical value whether the latent variabilities estimated in Stage 1 should also be used as a predictor with a qudratice effect. Defaults to FALSE. Note if there is a mediator as well as main outcome, the latent intercepts will be used as a predictor for both.

centerU

A numeric vector of length one (scalar) that is used to center the latent intercept estimates before using as a predictor of the outcome / mediator. Uses the formula: (U - centerU). Particularly useful when including quadratic terms.

centerIIV

A numeric vector of length one (scalar) that is used to center the latent variability estimates before using as a predictor of the outcome / mediator. Uses the formula: (IIV - centerIIV). Particularly useful when including quadratic terms.

...

Additional arguments passed to sampling.

template_only

A logical, not commonly used. If TRUE returns the Stan template code only, without actually compiling or running the Stan model. Useful for modifying the default models.

Value

A compiled Stan model.

Author(s)

Joshua F. Wiley <jwiley.psych@gmail.com>

Examples

varian:::vm_stan("V -> Y", useU=TRUE, template_only = TRUE)
varian:::vm_stan("V -> Y", useU=TRUE, UQ = TRUE, IIVQ = TRUE, template_only = TRUE)
varian:::vm_stan("V -> M -> Y", useU=TRUE, UQ = TRUE, IIVQ = TRUE, template_only = TRUE)

ElkhartGroup/varian documentation built on March 20, 2023, 9:40 p.m.