Inspect or extract information from a lavaanList object
lavListInspect.RdThe lavListInspect() and lavListTech() functions can be used to
inspect/extract information that is stored inside (or can be computed from) a
lavaanList object.
Usage
lavListInspect(object, what = "free", add.labels = TRUE,
add.class = TRUE, list.by.group = TRUE,
drop.list.single.group = TRUE)
lavListTech(object, what = "free", add.labels = FALSE,
add.class = FALSE, list.by.group = FALSE,
drop.list.single.group = FALSE)Arguments
- object
An object of class
lavaanList.- what
Character. What needs to be inspected/extracted? See Details for a full list. Note: the
whatargument 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. IfFALSE, 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.) IfTRUE, the list will be unlisted if there is only a single group.
Details
The lavListInspect() and lavListTech() functions only differ in
the way they return the results. The lavListInspect() function will
prettify the output by default, while the lavListTech() will not attempt
to prettify the output by default.
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()andvcov()."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."start":A list of model matrices. The values represent the starting values for all model parameters. Alias:
"starting.values".
Information about the data (including missing patterns):
"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.
"level.label":A character vector. The level labels.
"cluster":A character vector. The cluster variable(s) in the data.frame (if any).
"nlevels":Integer. The number of levels.
"ordered":A character vector. The ordered variables.
"nobs":Integer vector. The number of observations in each group that were used in the analysis (in each dataset).
"norig":Integer vector. The original number of observations in each group (in each dataset).
"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 (in each dataset).
Model features:
"meanstructure":Logical.
TRUEif a meanstructure was included in the model."categorical":Logical.
TRUEif categorical endogenous variables were part of the model."fixed.x":Logical.
TRUEif the exogenous x-covariates are treated as fixed."parameterization":Character. Either
"delta"or"theta".
"list":The parameter table. The same output as given by
parTable()."options":List. The option list.
"call":List. The call as returned by match.call, coerced to a list.
Examples
# fit model
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
# a data generating function
generateData <- function() lavSimulateData(HS.model, sample.nobs = 100)
set.seed(1234)
fit <- semList(HS.model, dataFunction = generateData, ndat = 5,
store.slots = "partable")
# extract information
lavListInspect(fit, "free")
#> $lambda
#> visual textul speed
#> x1 0 0 0
#> x2 1 0 0
#> x3 2 0 0
#> x4 0 0 0
#> x5 0 3 0
#> x6 0 4 0
#> x7 0 0 0
#> x8 0 0 5
#> x9 0 0 6
#>
#> $theta
#> x1 x2 x3 x4 x5 x6 x7 x8 x9
#> x1 7
#> x2 0 8
#> x3 0 0 9
#> x4 0 0 0 10
#> x5 0 0 0 0 11
#> x6 0 0 0 0 0 12
#> x7 0 0 0 0 0 0 13
#> x8 0 0 0 0 0 0 0 14
#> x9 0 0 0 0 0 0 0 0 15
#>
#> $psi
#> visual textul speed
#> visual 16
#> textual 19 17
#> speed 20 21 18
#>
lavListTech(fit, "free")
#> $lambda
#> [,1] [,2] [,3]
#> [1,] 0 0 0
#> [2,] 1 0 0
#> [3,] 2 0 0
#> [4,] 0 0 0
#> [5,] 0 3 0
#> [6,] 0 4 0
#> [7,] 0 0 0
#> [8,] 0 0 5
#> [9,] 0 0 6
#>
#> $theta
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
#> [1,] 7 0 0 0 0 0 0 0 0
#> [2,] 0 8 0 0 0 0 0 0 0
#> [3,] 0 0 9 0 0 0 0 0 0
#> [4,] 0 0 0 10 0 0 0 0 0
#> [5,] 0 0 0 0 11 0 0 0 0
#> [6,] 0 0 0 0 0 12 0 0 0
#> [7,] 0 0 0 0 0 0 13 0 0
#> [8,] 0 0 0 0 0 0 0 14 0
#> [9,] 0 0 0 0 0 0 0 0 15
#>
#> $psi
#> [,1] [,2] [,3]
#> [1,] 16 19 20
#> [2,] 19 17 21
#> [3,] 20 21 18
#>