The summary() function gives a nice overview of a fitted model, but is for display only. If you need the actual numbers for further processing, you may prefer to use one of several ‘extractor’ functions. We have already seen the coef() function which extracts the estimated parameters of a fitted model. Other extractor functions are discussed below.
parameterEstimates
The parameterEstimates() function returns a data.frame containing all the model parameters in the rows:
fit <-cfa(HS.model, data=HolzingerSwineford1939)parameterEstimates(fit)
The lhs (left-hand side), op (operator) and rhs (right-hand side) columns define the parameter. The est, se, z and pvalue columns provide the point estimate, the standard error, the z-value and the p-value for this parameter. The last two columns are the lower and upper bounds of a 95% confidence interval around the point estimate.
standardizedSolution
The standardizedSolution() function is similar to the parameterEstimates() function, but only shows the standardized parameter estimates and corresponding standard errors, z-values, p-values and confidence intervals.
fitted.values
The fitted() and fitted.values() functions return the model-implied (fitted) covariance matrix (and mean vector) of a fitted model:
fit <-cfa(HS.model, data = HolzingerSwineford1939)fitted(fit)
The resid() or residuals() functions return (unstandardized) residuals of a fitted model. This is simply the difference between the observed and implied covariance matrix and mean vector.
fit <-cfa(HS.model, data = HolzingerSwineford1939)resid(fit)
The lavResiduals() gives more extensive information about the residuals. Per default, it will print both raw and standardized residuals, as well as several summary statistics (including the SRMR and the unbiased SRMR).
vcov
The function vcov() returns the estimated covariance matrix of the parameter estimates.
AIC and BIC
The AIC() and BIC() functions return the AIC and BIC values of a fitted model.
fitMeasures
The fitMeasures() function returns all the fit measures computed by lavaan as a named numeric vector.
fit <-cfa(HS.model, data=HolzingerSwineford1939)fitMeasures(fit)
If you only want the value of a single fit measure, say, the CFI, you give the name (in lower case) as the second argument:
fit <-cfa(HS.model, data=HolzingerSwineford1939)fitMeasures(fit, "cfi")
cfi
0.931
Or you can provide a vector of fit measures, as in
fitMeasures(fit, c("cfi","rmsea","srmr"))
cfi rmsea srmr
0.931 0.092 0.065
lavInspect
If you want to peek inside a fitted lavaan object (the object that is returned by a call to cfa(), sem()or growth()), you can use the lavInspect() function, with a variety of options. By default, calling lavInspect() on a fitted lavaan object returns a list of the model matrices that are used internally to represent the model. The free parameters are nonzero integers.
fit <-cfa(HS.model, data=HolzingerSwineford1939)lavInspect(fit)