stan_inits: Calculate Initial Values for Stan VM Model

View source: R/modeler.R

stan_initsR Documentation

Calculate Initial Values for Stan VM Model

Description

Internal function used to get rough starting values for a variability model in Stan. Uses inidivudal standard deviations, means, and linear regressions.

Usage

stan_inits(
  stan.data,
  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,
  ...
)

Arguments

stan.data

A list containing the data to be passed to Stan

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.

Value

A named list containing the initial values for Stan.

Author(s)

Joshua F. Wiley <josh@elkhartgroup.com>

Examples

# make me!

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