bsem | R Documentation |
Fit a Structural Equation Model (SEM).
bsem(..., cp = "srs",
dp = NULL, n.chains = 3, burnin, sample,
adapt, mcmcfile = FALSE, mcmcextra = list(), inits = "simple",
convergence = "manual", target = "stan", save.lvs = FALSE,
wiggle = NULL, wiggle.sd = 0.1, prisamp = FALSE, jags.ic = FALSE,
seed = NULL, bcontrol = list())
... |
Default lavaan arguments. See |
cp |
Handling of prior distributions on covariance parameters:
possible values are |
dp |
Default prior distributions on different types of
parameters, typically the result of a call to |
n.chains |
Number of desired MCMC chains. |
burnin |
Number of burnin/warmup iterations (not including the adaptive iterations, for target="jags"). Defaults to 4000 or target="jags" and 500 for Stan targets. |
sample |
The total number of samples to take after burnin. Defaults to 10000 for target="jags" and 1000 for Stan targets. |
adapt |
For target="jags", the number of adaptive iterations to use at the start of sampling. Defaults to 1000. |
mcmcfile |
If |
mcmcextra |
A list with potential names |
inits |
If it is a character string, the options are currently
|
convergence |
Useful only for |
target |
Desired MCMC sampling, with |
save.lvs |
Should sampled latent variables (factor scores) be saved? Logical; defaults to FALSE |
wiggle |
Labels of equality-constrained parameters that should be "approximately" equal. Can also be "intercepts", "loadings", "regressions", "means". |
wiggle.sd |
The prior sd (of normal distribution) to be used in approximate equality constraints. Can be one value, or (for target="stan") a numeric vector of values that is the same length as wiggle. |
prisamp |
Should samples be drawn from the prior, instead of the
posterior ( |
jags.ic |
Should DIC be computed the JAGS way, in addition to the BUGS way? Logical; defaults to FALSE |
seed |
A vector of length |
bcontrol |
A list containing additional parameters passed to
|
The bsem
function is a wrapper for the more general
blavaan
function, using the following default
lavaan
arguments:
int.ov.free = TRUE
, int.lv.free = FALSE
,
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
.
An object of class lavaan, for which several methods
are available, including a summary
method.
Edgar C. Merkle, Ellen Fitzsimmons, James Uanhoro, & Ben Goodrich (2021). Efficient Bayesian Structural Equation Modeling in Stan. Journal of Statistical Software, 100(6), 1-22. URL http://www.jstatsoft.org/v100/i06/.
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/.
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/.
blavaan
# The industrialization and Political Democracy Example
# Bollen (1989), page 332
data(PoliticalDemocracy, package = "lavaan")
model <- '
# latent variable definitions
ind60 =~ x1 + x2 + x3
dem60 =~ y1 + a*y2 + b*y3 + c*y4
dem65 =~ y5 + a*y6 + b*y7 + c*y8
# regressions
dem60 ~ ind60
dem65 ~ ind60 + dem60
# residual correlations
y1 ~~ y5
y2 ~~ y4 + y6
y3 ~~ y7
y4 ~~ y8
y6 ~~ y8
'
## Not run:
# mildly informative priors for mv intercepts and loadings
fit <- bsem(model, data = PoliticalDemocracy,
dp = dpriors(nu = "normal(5,10)", lambda = "normal(1,.5)"))
summary(fit)
## End(Not run)
# A short run for rough results
fit <- bsem(model, data = PoliticalDemocracy, burnin = 100, sample = 100,
dp = dpriors(nu = "normal(5,10)", lambda = "normal(1,.5)"),
n.chains = 2)
summary(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.