lavaan-class {lavaan} | R Documentation |
Class For Representing A (Fitted) Latent Variable Model
Description
The lavaan
class represents a (fitted) latent variable
model. It contains a description of the model as specified by the user,
a summary of the data, an internal matrix representation, and if the model
was fitted, the fitting results.
Objects from the Class
Objects can be created via the
cfa
, sem
, growth
or
lavaan
functions.
Slots
version
:The lavaan package version used to create this objects
call
:The function call as returned by
match.call()
.timing
:The elapsed time (user+system) for various parts of the program as a list, including the total time.
Options
:Named list of options that were provided by the user, or filled-in automatically.
ParTable
:Named list describing the model parameters. Can be coerced to a data.frame. In the documentation, this is called the ‘parameter table’.
pta
:Named list containing parameter table attributes.
Data
:Object of internal class
"Data"
: information about the data.SampleStats
:Object of internal class
"SampleStats"
: sample statisticsModel
:Object of internal class
"Model"
: the internal (matrix) representation of the modelCache
:List using objects that we try to compute only once, and reuse many times.
Fit
:Object of internal class
"Fit"
: the results of fitting the model. No longer used.boot
:List. Results and information about the bootstrap.
optim
:List. Information about the optimization.
loglik
:List. Information about the loglikelihood of the model (if maximum likelihood was used).
implied
:List. Model implied statistics.
vcov
:List. Information about the variance matrix (vcov) of the model parameters.
test
:List. Different test statistics.
h1
:List. Information about the unrestricted h1 model (if available).
baseline
:List. Information about a baseline model (often the independence model) (if available).
internal
:List. For internal use only.
external
:List. Empty slot to be used by add-on packages.
Methods
- coef
signature(object = "lavaan", type = "free")
: Returns the estimates of the parameters in the model as a named numeric vector. Iftype="free"
, only the free parameters are returned. Iftype="user"
, all parameters listed in the parameter table are returned, including constrained and fixed parameters.- fitted.values
signature(object = "lavaan")
: Returns the implied moments of the model as a list with two elements (per group):cov
for the implied covariance matrix, andmean
for the implied mean vector. If only the covariance matrix was analyzed, the implied mean vector will be zero.- fitted
signature(object = "lavaan")
: an alias forfitted.values
.- residuals
signature(object = "lavaan", type="raw")
: Iftype = "raw"
, this function returns the raw (= unscaled) difference between the observed and the expected (model-implied) summary statistics. Iftype = "cor"
, ortype = "cor.bollen"
, the observed and model implied covariance matrices are first transformed to a correlation matrix (usingcov2cor()
), before the residuals are computed. Iftype = "cor.bentler"
, both the observed and model implied covariance matrices are rescaled by dividing the elements by the square roots of the corresponding variances of the observed covariance matrix. Iftype="normalized"
, the residuals are divided by the square root of the asymptotic variance of the corresponding summary statistic (the variance estimate depends on the choice for these
argument). Unfortunately, the corresponding normalized residuals are not entirely correct, and this option is only available for historical interest. Iftype="standardized"
, the residuals are divided by the square root of the asymptotic variance of these residuals. The resulting standardized residuals elements can be interpreted as z-scores. Iftype="standardized.mplus"
, the residuals are divided by the square root of the asymptotic variance of these residuals. However, a simplified formula is used (see the Mplus reference below) which often results in negative estimates for the variances, resulting in manyNA
values for the standardized residuals.- resid
signature(object = "lavaan")
: an alias forresiduals
- vcov
signature(object = "lavaan")
: returns the covariance matrix of the estimated parameters.- predict
signature(object = "lavaan")
: compute factor scores for all cases that are provided in the data frame. For complete data only.- anova
signature(object = "lavaan")
: returns model comparison statistics. This method is just a wrapper around the functionlavTestLRT
. If only a single argument (a fitted model) is provided, this model is compared to the unrestricted model. If two or more arguments (fitted models) are provided, the models are compared in a sequential order. Test statistics are based on the likelihood ratio test. For more details and further options, see thelavTestLRT
page.- update
signature(object = "lavaan", model, add, ..., evaluate=TRUE)
: update a fitted lavaan object and evaluate it (unlessevaluate=FALSE
). Note that we use the environment that is stored within the lavaan object, which is not necessarily the parent frame. Theadd
argument is analogous to the one described in thelavTestScore
page, and can be used to add parameters to the specified model rather than passing an entirely newmodel
argument.- nobs
signature(object = "lavaan")
: returns the effective number of observations used when fitting the model. In a multiple group analysis, this is the sum of all observations per group.- logLik
signature(object = "lavaan")
: returns the log-likelihood of the fitted model, if maximum likelihood estimation was used. TheAIC
andBIC
methods automatically work vialogLik()
.- show
signature(object = "lavaan")
: Print a short summary of the model fit- summary
signature(object = "lavaan", header = TRUE, fit.measures = FALSE, estimates = TRUE, ci = FALSE, fmi = FALSE, standardized = FALSE, std.nox = FALSE, remove.step1 = TRUE, remove.unused = TRUE, cov.std = TRUE, rsquare = FALSE, modindices = FALSE, ci = FALSE, nd = 3L)
: Print a nice summary of the model estimates. Ifheader = TRUE
, the header section (including fit measures) is printed. Iffit.measures = TRUE
, additional fit measures are added to the header section. The relatedfm.args
list allows to set options related to the fit measures. SeefitMeasures
for more details. Ifestimates = TRUE
, print the parameter estimates section. Ifci = TRUE
, add confidence intervals to the parameter estimates section. Iffmi = TRUE
, add the fmi (fraction of missing information) column, if it is available. Ifstandardized=TRUE
or a character vector, the standardized solution is also printed (seeparameterEstimates
). Note that SEs and tests are still based on unstandardized estimates. UsestandardizedSolution
to obtain SEs and test statistics for standardized estimates. Thestd.nox
argument is deprecated; thestandardized
argument allows"std.nox"
solution to be specifically requested. Ifremove.step1
, the parameters of the measurement part are not shown (only used when usingsam()
.) Ifremove.unused
, automatically added parameters that are fixed to their default (0 or 1) values are removed. Ifrsquare=TRUE
, the R-Square values for the dependent variables in the model are printed. Ifefa = TRUE
, EFA related information is printed. The relatedefa.args
list allows to set options related to the EFA output. Seesummary.efaList
for more details. Ifmodindices=TRUE
, modification indices are printed for all fixed parameters. The argumentnd
determines the number of digits after the decimal point to be printed (currently only in the parameter estimates section.) Historically, nothing was returned, but since 0.6-12, a list is returned of classlavaan.summary
for which is print function is available.
References
Yves Rosseel (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36. doi:10.18637/jss.v048.i02
Standardized Residuals in Mplus. Document retrieved from URL https://www.statmodel.com/download/StandardizedResiduals.pdf
See Also
cfa
, sem
,
fitMeasures
, standardizedSolution
,
parameterEstimates
, lavInspect
,
modindices
Examples
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- cfa(HS.model, data = HolzingerSwineford1939)
summary(fit, standardized = TRUE, fit.measures = TRUE, rsquare = TRUE)
fitted(fit)
coef(fit)
resid(fit, type = "normalized")