Learn R Programming

blavaan (version 0.3-2)

bgrowth: Fit Growth Curve Models

Description

Fit a Growth Curve model.

Usage

bgrowth(..., cp = "srs", dp = NULL, n.chains = 3,
burnin, sample, adapt, mcmcfile = FALSE, mcmcextra = list(), 
inits = "simple", convergence = "manual", target = "jags",
save.lvs = FALSE, jags.ic = FALSE, seed = NULL, bcontrol = list())

Arguments

...

Default lavaan arguments. See lavaan.

cp

Handling of prior distributions on covariance parameters: possible values are "srs" or "fa". Option "srs" is more flexible and better from a theoretical standpoint, but it is also slower.

dp

Default prior distributions on different types of parameters, typically the result of a call to dpriors(). See the dpriors() help file for more information.

n.chains

Number of desired MCMC chains.

burnin

Number of burnin iterations, NOT including the adaptive iterations.

sample

The total number of samples to take after burnin.

adapt

The number of adaptive iterations to use at the start of the simulation.

mcmcfile

If TRUE, the JAGS/Stan model will be written to file (in the lavExport directory). Can also supply a character string, which serves as the name of the directory to which files will be written.

mcmcextra

A list with potential names syntax and monitor. The syntax object is a text string containing extra code to insert in the JAGS/Stan model syntax, and the monitor object is a character vector containing extra JAGS/Stan parameters to sample.

inits

If it is a character string, the options are currently "simple" (default), "Mplus", "prior", and "jags". In the first two cases, parameter values are set as though they will be estimated via ML (see lavaan). The starting parameter value for each chain is then perturbed from the original values through the addition of uniform noise. If "prior" is used, the starting parameter values are obtained based on the prior distributions (while also trying to ensure that the starting values will not crash the model estimation). If "jags", no starting values are specified and JAGS will choose values on its own. If start is a fitted object of class '>lavaan, the estimated values of the corresponding parameters will be extracted, then perturbed in the manner described above. If it is a model list, for example the output of the paramaterEstimates() function, the values of the est or start or ustart column (whichever is found first) will be extracted.

convergence

If "auto", parameters will be sampled until convergence is achieved (via autorun.jags). In this case, the arguments burnin and sample are passed to autorun.jags as startburnin and startsample, respectively. Otherwise, parameters are sampled as specified by the user (or by the run.jags defaults).

target

Desired MCMC package ("jags" is default, but "stan" also available).

save.lvs

Should sample latent variables (factor scores) be saved? Logical; defaults to FALSE

jags.ic

Should DIC be computed the JAGS way, in addition to the BUGS way? Logical; defaults to FALSE

seed

A vector of length n.chains containing random seeds for the MCMC run. If NULL, seeds will be chosen randomly.

bcontrol

A list containing additional parameters passed to run.jags (or autorun.jags) or stan. See the manpage of those functions for an overview of the additional parameters that can be set.

Value

An object of class blavaan, for which several methods are available, including a summary method.

Details

The bgrowth function is a wrapper for the more general blavaan function, using the following default lavaan arguments: meanstructure = TRUE, int.ov.free = FALSE, int.lv.free = TRUE, auto.fix.first = TRUE (unless std.lv = TRUE), auto.fix.single = TRUE, auto.var = TRUE, auto.cov.lv.x = TRUE, auto.th = TRUE, auto.delta = TRUE, and auto.cov.y = TRUE.

References

Yves Rosseel (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36. URL http://www.jstatsoft.org/v48/i02/.

Edgar C. Merkle & Yves Rosseel (2018). blavaan: Bayesian Structural Equation Models via Parameter Expansion. Journal of Statistical Software, 85(4), 1-30. URL http://www.jstatsoft.org/v85/i04/.

See Also

blavaan

Examples

Run this code
# NOT RUN {
## linear growth model with a time-varying covariate
model.syntax <- '
  # intercept and slope with fixed coefficients
    i =~ 1*t1 + 1*t2 + 1*t3 + 1*t4
    s =~ 0*t1 + 1*t2 + 2*t3 + 3*t4

  # regressions
    i ~ x1 + x2
    s ~ x1 + x2

  # time-varying covariates
    t1 ~ c1
    t2 ~ c2
    t3 ~ c3
    t4 ~ c4
'

fit <- bgrowth(model.syntax, data=Demo.growth)
summary(fit)
# }

Run the code above in your browser using DataLab