Learn R Programming

lavaan (version 0.7-2)

lavaan: Fit a Latent Variable Model

Description

Fit a latent variable model.

Usage

lavaan(model = NULL, data = NULL, ordered = NULL, aux = NULL,
       sampling_weights   = NULL,
       sample_cov = NULL, sample_mean = NULL, sample_th = NULL,
       sample_nobs = NULL,
       group = NULL, cluster = NULL, constraints = "", 
       wls_v = NULL, nacov = NULL, ov_order = "model",
       slot_options = NULL, slot_par_table = NULL, slot_sample_stats = NULL,
       slot_data = NULL, slot_model = NULL, slot_cache = NULL,
       sloth1 = NULL,
       ...)

Value

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

Arguments

model

A description of the user-specified model. Typically, the model is described using the lavaan model syntax. See model.syntax for more information. Alternatively, a parameter table (e.g., the output of the lavParTable() function) is also accepted.

data

An optional data frame containing the observed variables used in the model. If some variables are declared as ordered factors, lavaan will treat them as ordinal variables.

ordered

Character vector. Only used if the data is in a data.frame. Treat these variables as ordered (ordinal) variables, if they are endogenous in the model. Importantly, all other variables will be treated as numeric (unless they are declared as ordered in the data.frame.) Since 0.6-4, ordered can also be logical. If TRUE, all observed endogenous variables are treated as ordered (ordinal). If FALSE, all observed endogenous variables are considered to be numeric (again, unless they are declared as ordered in the data.frame.)

aux

Character vector. Names of auxiliary observed variables. Auxiliary variables are not part of the user-specified model; they are used to make the missing-at-random (MAR) assumption more plausible under missing data. Only available (for now) with continuous data and one of missing = "ml", "two.stage" or "robust.two.stage". With missing = "ml" (full-information ML), the auxiliary variables are added to the model as a block of `saturated correlates' (Graham, 2003): each auxiliary variable is freely correlated with every other auxiliary variable, with every model observed variable, and has a free mean. The (enlarged) model is estimated with casewise FIML, so the auxiliary variables affect both the point estimates and the standard errors, while leaving the model degrees of freedom unchanged. The baseline model is adjusted accordingly (so CFI/TLI remain correct), and the auxiliary (nuisance) parameters are hidden from the default output (use remove_aux = FALSE in parameterEstimates() to show them; they are always part of coef()). With missing = "two.stage" or "robust.two.stage", the auxiliary variables are instead included in the first-stage EM run that estimates the saturated summary statistics the model is fitted to, so they also affect the model estimates; the two-stage standard errors account for the auxiliary variables via the augmented first-stage asymptotic covariance (Savalei & Bentler, 2009), except when fixed-x covariates are present (in which case they fall back to the model-only covariance). Binary or ordered/categorical auxiliary variables are not supported and are removed (with a warning).

sampling_weights

A variable name in the data frame containing sampling weight information. Currently only available for non-clustered data. Depending on the sampling_weights.normalization option, these weights may be rescaled (or not) so that their sum equals the number of observations (total or per group).

sample_cov

Numeric matrix. A sample variance-covariance matrix. The rownames and/or colnames must contain the observed variable names. For a multiple group analysis, a list with a variance-covariance matrix for each group. If conditional.x = TRUE, this is the residual variance-covariance matrix (given the exogenous covariates), and the regression intercepts, slopes and covariate moments are provided through the attributes res.slopes, cov.x and mean.x of sample_cov (with sample_mean holding the residual intercepts). It is recommended to supply these attributes with (dim)names, so that they can be matched against the model's internal variable order; unnamed attributes are assumed to be in that internal order already.

sample_mean

A sample mean vector. For a multiple group analysis, a list with a mean vector for each group.

sample_th

Vector of sample-based thresholds. For a multiple group analysis, a list with a vector of thresholds for each group.

sample_nobs

Number of observations if the full data frame is missing and only sample moments are given. For a multiple group analysis, a list or a vector with the number of observations for each group.

group

Character. A variable name in the data frame defining the groups in a multiple group analysis.

cluster

Character. A (single) variable name in the data frame defining the clusters in a two-level dataset.

constraints

Additional (in)equality constraints not yet included in the model syntax. See model.syntax for more information.

wls_v

A user provided weight matrix to be used by estimator "WLS"; if the estimator is "DWLS", only the diagonal of this matrix will be used. For a multiple group analysis, a list with a weight matrix for each group. The elements of the weight matrix should be in the following order (if all data is continuous): first the means (if a meanstructure is involved), then the lower triangular elements of the covariance matrix including the diagonal, ordered column by column. In the categorical case: first the thresholds (including the means for continuous variables), then the slopes (if any), the variances of continuous variables (if any), and finally the lower triangular elements of the correlation/covariance matrix excluding the diagonal, ordered column by column.

nacov

A user provided matrix containing the elements of (N times) the asymptotic variance-covariance matrix of the sample statistics. For a multiple group analysis, a list with an asymptotic variance-covariance matrix for each group. See the wls_v argument for information about the order of the elements.

ov_order

Character. If "model" (the default), the order of the observed variable names (as reflected for example in the output of lav_object_vnames()) is determined by the model syntax. If "data", the order is determined by the data (either the full data.frame or the sample (co)variance matrix). If the wls_v and/or nacov matrices are provided, this argument is currently set to "data".

slot_options

Options slot from a fitted lavaan object. If provided, no new Options slot will be created by this call.

slot_par_table

ParTable slot from a fitted lavaan object. If provided, no new ParTable slot will be created by this call.

slot_sample_stats

SampleStats slot from a fitted lavaan object. If provided, no new SampleStats slot will be created by this call.

slot_data

Data slot from a fitted lavaan object. If provided, no new Data slot will be created by this call.

slot_model

Model slot from a fitted lavaan object. If provided, no new Model slot will be created by this call.

slot_cache

Cache slot from a fitted lavaan object. If provided, no new Cache slot will be created by this call.

sloth1

h1 slot from a fitted lavaan object. If provided, no new h1 slot will be created by this call.

...

Many more options can be specified, using 'name = value'. See lavOptions for a complete list.

References

Yves Rosseel (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36. tools:::Rd_expr_doi("10.18637/jss.v048.i02")

See Also

cfa, sem, growth

Examples

Run this code
# The Holzinger and Swineford (1939) example
HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '

fit <- lavaan(HS.model, data=HolzingerSwineford1939,
              auto.var=TRUE, auto.fix.first=TRUE,
              auto.cov.lv.x=TRUE)
summary(fit, fit.measures=TRUE)

Run the code above in your browser using DataLab