lavaan (version 0.6-1.1161)

lavInspect: Inspect or extract information from a fitted lavaan object

Description

The lavInspect() and lavTech() functions can be used to inspect/extract information that is stored inside (or can be computed from) a fitted lavaan object. Note: the (older) inspect() function is now simply a shortcut for lavInspect() with default arguments.

Usage

lavInspect(object, what = "free", add.labels = TRUE, add.class = TRUE,
           list.by.group = TRUE,
           drop.list.single.group = TRUE)

lavTech(object, what = "free", add.labels = FALSE, add.class = FALSE, list.by.group = FALSE, drop.list.single.group = FALSE)

inspect(object, what = "free", ...)

Arguments

object

An object of class '>lavaan.

what

Character. What needs to be inspected/extracted? See Details for a full list. Note: the what argument is not case-sensitive (everything is converted to lower case.)

add.labels

If TRUE, variable names are added to the vectors and/or matrices.

add.class

If TRUE, vectors are given the `lavaan.vector' class; matrices are given the `lavaan.matrix' class, and symmetric matrices are given the `lavaan.matrix.symmetric' class. This only affects the way they are printed on the screen.

list.by.group

Logical. Only used when the output are model matrices. If TRUE, the model matrices are nested within groups. If FALSE, a flattened list is returned containing all model matrices, with repeated names for multiple groups.

drop.list.single.group

If FALSE, the results are returned as a list, where each element corresponds to a group (even if there is only a single group.) If TRUE, the list will be unlisted if there is only a single group.

...

Additional arguments. Not used by lavaan, but by other packages.

Details

The lavInspect() and lavTech() functions only differ in the way they return the results. The lavInspect() function will prettify the output by default, while the lavTech() will not attempt to prettify the output by default. The (older) inspect() function is a simplified version of lavInspect() with only the first two arguments.

Below is a list of possible values for the what argument, organized in several sections:

Model matrices:

"free":

A list of model matrices. The non-zero integers represent the free parameters. The numbers themselves correspond to the position of the free parameter in the parameter vector. This determines the order of the model parameters in the output of for example coef() and vcov().

"partable":

A list of model matrices. The non-zero integers represent both the fixed parameters (for example, factor loadings fixed at 1.0), and the free parameters if we ignore any equality constraints. They correspond with all entries (fixed or free) in the parameter table. See parTable.

"se":

A list of model matrices. The non-zero numbers represent the standard errors for the free parameters in the model. If two parameters are constrained to be equal, they will have the same standard error for both parameters. Aliases: "std.err" and "standard.errors".

"start":

A list of model matrices. The values represent the starting values for all model parameters. Alias: "starting.values".

"est":

A list of model matrices. The values represent the estimated model parameters. Aliases: "estimates", and "x".

"dx.free":

A list of model matrices. The values represent the gradient (first derivative) values of the model parameters. If two parameters are constrained to be equal, they will have the same gradient value.

"dx.all":

A list of model matrices. The values represent the first derivative with respect to all possible matrix elements. Currently, this is only available when the estimator is "ML" or "GLS".

"std":

A list of model matrices. The values represent the (completely) standardized model parameters (the variances of both the observed and the latent variables are set to unity). Aliases: "std.all", "standardized".

"std.lv":

A list of model matrices. The values represent the standardized model parameters (only the variances of the latent variables are set to unity.)

"std.nox":

A list of model matrices. The values represent the (completely) standardized model parameters (the variances of both the observed and the latent variables are set to unity; however, the variances of any observed exogenous variables are not set to unity; hence no-x.)

Information about the data (including missing patterns):

"data":

A matrix containing the observed variables that have been used to fit the model. No column/row names are provided. Column names correspond to the output of lavNames(object), while the rows correspond to the output of lavInspect(object, "case.idx".

"group":

A character string. The group variable in the data.frame (if any).

"ngroups":

Integer. The number of groups.

"group.label":

A character vector. The group labels.

"cluster":

A character vector. The cluster variable(s) in the data.frame (if any).

"ordered":

A character vector. The ordered variables.

"nobs":

Integer vector. The number of observations in each group that were used in the analysis.

"norig":

Integer vector. The original number of observations in each group.

"ntotal":

Integer. The total number of observations that were used in the analysis. If there is just a single group, this is the same as the "nobs" option; if there are multiple groups, this is the sum of the "nobs" numbers for each group.

"case.idx":

The case/observation numbers that were used in the analysis. In the case of multiple groups: a list of numbers.

"empty.idx":

The case/observation numbers of those cases/observations that contained missing values only (at least for the observed variables that were included in the model). In the case of multiple groups: a list of numbers.

"patterns":

A binary matrix. The rows of the matrix are the missing data patterns where 1 and 0 denote non-missing and missing values for the corresponding observed variables respectively (or TRUE and FALSE if lavTech() is used.) If the data is complete (no missing values), there will be only a single pattern. In the case of multiple groups: a list of pattern matrices.

"coverage":

A symmetric matrix where each element contains the proportion of observed datapoints for the corresponding pair of observed variables. In the case of multiple groups: a list of coverage matrices.

Observed sample statistics:

"sampstat":

Observed sample statistics. Aliases: "samp", "sample", "samplestatistics". In the presence of missing values, the sample covariance matrix is computed using use="pairwise", while listwise deletion is used for the means (and thresholds, if any).

"sampstat.h1":

If all variables are continuous, and missing = "ml" (or "fiml"), the EM algorithm is used to compute an estimate of the sample covariance matrix and mean vector under the unrestricted (H1) model. Aliases: "h1", "missing.h1".

"wls.obs":

The observed sample statistics (covariance elements, intercepts/thresholds, etc.) in a single vector.

"wls.v":

The weight vector as used in weighted least squares estimation.

"gamma":

N times the asymptotic variance matrix of the sample statistics. Alias: "sampstat.nacov".

Model features:

"meanstructure":

Logical. TRUE if a meanstructure was included in the model.

"categorical":

Logical. TRUE if categorical endogenous variables were part of the model.

"fixed.x":

Logical. TRUE if the exogenous x-covariates are treated as fixed.

"parameterization":

Character. Either "delta" or "theta".

Model-implied sample statistics:

"cov.lv":

The model-implied variance-covariance matrix of the latent variables. Alias: "veta" [for V(eta)].

"cor.lv":

The model-implied correlation matrix of the latent variables.

"mean.lv":

The model-implied mean vector of the latent variables. Alias: "eeta" [for E(eta)].

"cov.ov":

The model-implied variance-covariance matrix of the observed variables. Aliases: "sigma", "sigma.hat".

"cor.ov":

The model-implied correlation matrix of the observed variables.

"mean.ov":

The model-implied mean vector of the observed variables. Aliases: "mu", "mu.hat".

"cov.all":

The model-implied variance-covariance matrix of both the observed and latent variables.

"cor.all":

The model-implied correlation matrix of both the observed and latent variables.

"th":

The model-implied thresholds. Alias: "thresholds".

"wls.est":

The model-implied sample statistics (covariance elements, intercepts/thresholds, etc.) in a single vector.

"vy":

The model-implied unconditional variances of the observed variables.

"rsquare":

The R-square value for all endogenous variables. Aliases: "r-square", "r2".

Optimizer information:

"converged":

Logical. TRUE if the optimizer has converged; FALSE otherwise.

"iteratons":

Integer. The number of iterations used by the optimizer.

"optim":

List. All available information regarding the optimization results.

"npar":

Integer. Number of free parameters (ignoring constraints).

"coef":

Numeric. The estimated parameter vector.

Gradient, Hessian, observed, expected and first.order information matrices:

"gradient":

Numeric vector containing the first derivatives of the discrepancy function with respect to the (free) model parameters.

"hessian":

Matrix containing the second derivatives of the discrepancy function with respect to the (free) model parameters.

"information":

Matrix containing either the observed or the expected information matrix (depending on the information option of the fitted model.

"information.expected":

Matrix containing the expected information matrix for the free model parameters.

"information.observed":

Matrix containing the observed information matrix for the free model parameters.

"information.first.order":

Matrix containing the first.order information matrix for the free model parameters. This is the outer product of the gradient elements (the first derivative of the discrepancy function with respect to the (free) model parameters). Alias: "first.order".

"augmented.information":

Matrix containing either the observed or the expected augmented (or bordered) information matrix (depending on the information option of the fitted model. Only relevant if constraints have been used in the model.

"augmented.information.expected":

Matrix containing the expected augmented (or bordered) information matrix. Only relevant if constraints have been used in the model.

"augmented.information.observed":

Matrix containing the observed augmented (or bordered) information matrix. Only relevant if constraints have been used in the model.

"augmented.information.first.order":

Matrix containing the first.order augmented (or bordered) information matrix. Only relevant if constraints have been used in the model.

"inverted.information":

Matrix containing either the observed or the expected inverted information matrix (depending on the information option of the fitted model.

"inverted.information.expected":

Matrix containing the inverted expected information matrix for the free model parameters.

"inverted.information.observed":

Matrix containing the inverted observed information matrix for the free model parameters.

"inverted.information.first.order":

Matrix containing the inverted first.order information matrix for the free model parameters.

Variance covariance matrix of the model parameters:

"vcov":

Matrix containing the variance covariance matrix of the estimated model parameters.

"vcov.std.all":

Matrix containing the variance covariance matrix of the standardized estimated model parameters. Standardization is done with respect to both observed and latent variables.

"vcov.std.lv":

Matrix containing the variance covariance matrix of the standardized estimated model parameters. Standardization is done with respect to the latent variables only.

"vcov.std.nox":

Matrix containing the variance covariance matrix of the standardized estimated model parameters. Standardization is done with respect to both observed and latent variables, but ignoring any exogenous observed covariates.

Miscellaneous:

"UGamma":

Matrix containing the product of 'U' and 'Gamma' matrices as used by the Satorra-Bentler correction. The trace of this matrix, divided by the degrees of freedom, gives the scaling factor.

"list":

The parameter table. The same output as given by parTable().

"fit":

The fit measures. Aliases: "fitmeasures", "fit.measures", "fit.indices". The same output as given by fitMeasures().

"mi":

The modification indices. Alias: "modindices", "modification.indices". The same output as given by modindices().

"options":

List. The option list.

"call":

List. The call as returned by match.call, coerced to a list.

"timing":

List. The timing (in milliseconds) of various lavaan subprocedures.

"test":

List. All available information regarding the (goodness-of-fit) test statistic(s).

"post.check":

Post-fitting check if the solution is admissible. A warning is raised if negative variances are found, or if either lavInspect(fit, "cov.lv") or lavInspect(fit, "theta") return a non-positive definite matrix.

"zero.cell.tables":

List. List of bivariate frequency tables where at least one cell is empty.

See Also

lavaan

Examples

Run this code
# NOT RUN {
# fit model
HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '
     
fit <- cfa(HS.model, data=HolzingerSwineford1939, group = "school")

# extract information
lavInspect(fit, "sampstat")
lavTech(fit, "sampstat")
# }

Run the code above in your browser using DataCamp Workspace