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

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 statistics

Model:

Object of internal class "Model": the internal (matrix) representation of the model

Cache:

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

Methods

coef

signature(object = "lavaan", type = "free"): Returns the estimates of the parameters in the model as a named numeric vector. If type="free", only the free parameters are returned. If type="unco", both free and constrained parameters (simple equality constraints only) are returned. If type="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, and mean 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 for fitted.values.

residuals

signature(object = "lavaan", type="raw"): If type="raw", this function returns the raw (=unstandardized) difference between the implied moments and the observed moments as a list of two elements: cov for the residual covariance matrix, and mean for the residual mean vector. If only the covariance matrix was analyzed, the residual mean vector will be zero. If codetype="cor", the observed and model implied covariance matrix is first transformed to a correlation matrix (using cov2cor), before the residuals are computed. If type="normalized", the residuals are normalized. If type="standardized", the residuals are standardized. In the latter case, the residuals have a metric similar to z-values.

resid

signature(object = "lavaan"): an alias for residuals

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. See anova. At least two arguments (fitted models) are required. If the test statistic is scaled, an appropriate scaled difference test will be computed.

update

signature(object = "lavaan", model.syntax, ..., evaluate=TRUE): update a fitted lavaan object and evaluate it (unless evaluate=FALSE). Note that we use the environment that is stored within the lavaan object, which is not necessarily the parent frame.

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. The AIC and BIC methods automatically work via logLik().

inspect

signature(object = "lavaan", what = "free"): This is the main ‘extractor’ function for lavaan objects. It allows the user to peek into the internal representation of the model. In addition, the requested information is returned (typically as a list) and can be used for further processing. The following values for what are allowed (in alphabetical order):

"coef":

A list of model matrices containing the current values of all parameters.

"coefficients":

An alias for "coef".

"converged":

Returns TRUE if the optimization routine has converged; FALSE otherwise.

"cov.all":

Model implied covariance matrix of both the observed and latent variables.

"cov.lv":

Model implied covariance matrix of the latent variables.

"cor.all":

Model implied covariance matrix of both the observed and latent variables, in a correlation mectric.

"cor.lv":

Model implied covariance matrix of the latent variables, in a correlation metric.

"derivatives":

An alias for "dx".

"dx":

A list of model matrices containing the derivatives of all parameters evaluated at the current (typically minimum) function value.

"estimates":

An alias for "coef".

"est":

An alias for "coef".

"free":

A list of model matrices counting the free parameters in the model, typically in the same order as they are specified by the user.

"gradient":

An alias for "dx".

"list":

A dataframe showing the internal representation of a lavaan model. Each row corresponds to a model parameter. The columns contain all the information that lavaan stores about these parameters (for example, if it is free of fixed, the user-specified starting values, etcetera). This is called the parameter table.

"mi":

A data.frame containing modification indices and expected parameter change (EPC) values, both in unstandardized and standardized metric.

"modindices":

An alias for "mi".

"modification":

An alias for "mi".

"modificationindices":

An alias for "mi".

"modification.indices":

An alias for "mi".

"nacov":

N times the asymptotic variance of the model parameters.

"parameters":

An alias for "coef".

"parameter.estimates":

An alias for "coef".

"parameter.values":

An alias for "coef".

"r2":

An alias for "rsquare".

"rsquare":

A named vector with the R-Square value of the dependent observed and latent variables.

"r-square":

An alias for "rsquare".

"sampstat":

The sample statistics used for the analysis.

"se":

A list of model matrices containing the estimated standard errors for all free parameters.

"standardized":

An alias for "std.coef".

"standardizedsolution":

An alias for "std.coef".

"standardized.solution":

An alias for "std.coef".

"standard.errors":

An alias for "se".

"start":

A list of model matrices containing the starting values for all parameters.

"starting.values":

An alias for "start".

"std":

An alias for "std.coef".

"std.coef":

A data.frame containing both the raw and (completely) standardized parameter values.

"std.err":

An alias for "se".

"wls.v":

The weight matrix for WLS.

"x":

An alias for "coef".

show

signature(object = "lavaan"): Print a short summary of the model fit

summary

signature(object = "lavaan", standardized=FALSE, fit.measures=FALSE, rsquare=FALSE, modindices=FALSE): Print a nice summary of the model estimates. If standardized=TRUE, the standardized solution is also printed. If fit.measures=TRUE, the chi-square statistic is supplemented by several fit measures. If rsquare=TRUE, the R-Square values for the dependent variables in the model are printed. If modindices=TRUE, modification indices are printed for all fixed parameters. Nothing is returned (use inspect or another extractor function to extract information from a fitted model).

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/.

See Also

cfa, sem, growth, fitMeasures, standardizedSolution, parameterEstimates, 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)
inspect(fit, "free")
inspect(fit, "start")
inspect(fit, "rsquare")
inspect(fit, "fit")
fitted.values(fit)
coef(fit)
resid(fit, type="normalized")

[Package lavaan version 0.5-16 Index]