lavPredict: Predict the values of latent variables (and their...

Description Usage Arguments Details See Also Examples

Description

The lavPredict() function can be used to compute (or ‘predict’) estimated values for latent variables, and given these values, the model-implied values for the indicators of these latent variables. NOTE: the goal of this function is NOT to predict future values of dependent variables as in the regression framework!

Usage

1
2
3
lavPredict(object, type = "lv", newdata = NULL, method = "EBM",
           se = "none", label = TRUE, fsm = FALSE, level = 1L,
           optim.method = "bfgs", ETA = NULL)

Arguments

object

An object of class lavaan.

type

A character string. If "lv", estimated values for the latent variables in the model are computed. If "ov", model predicted values for the indicators of the latent variables in the model are computed. If "yhat", the estimated value for the observed indicators, given user-specified values for the latent variables provided by de ETA argument. If "fy", densities (or probabilities) for each observed indicator, given user-specified values for the latent variables provided by de ETA argument.

newdata

An optional data.frame, containing the same variables as the data.frame used when fitting the model in object.

method

A character string. In the linear case (when the indicators are continuous), the possible options are "regression" or "Bartlett". In the categorical case, the two options are "EBM" for the Empirical Bayes Modal approach, and "ML" for the maximum likelihood approach.

se

Character. If "none", no standard errors are computed. If "standard", naive standard errors are computed (assuming the parameters of the measurement model are known). The standard errors are returned as an attribute.

label

Logical. If TRUE, the columns are labeled.

fsm

Logical. If TRUE, return the factor score matrix as an attribute. Only for numeric data.

level

Integer. Only used in a multilevel SEM. If level = 1, only factor scores for latent variable defined at the first (within) level are computed; if level = 2, only factor scores for latent variables defined at the second (between) level are computed.

optim.method

Character string. Only used in the categorical case. If "nlminb" (the default in 0.5), the "nlminb()" function is used for the optimization. If "bfgs" or "BFGS" (the default in 0.6), the "optim()" function is used with the BFGS method.

ETA

An optional matrix or list, containing latent variable values for each observation. Used for computations when type = "ov".

Details

The predict() function calls the lavPredict() function with its default options.

If there are no latent variables in the model, type = "ov" will simply return the values of the observed variables. Note that this function can not be used to ‘predict’ values of dependent variables, given the values of independent values (in the regression sense). In other words, the structural component is completely ignored (for now).

See Also

lavaan

Examples

1
2
3
4
5
6
7
8
# fit model
HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '
     
fit <- cfa(HS.model, data=HolzingerSwineford1939)
head(lavPredict(fit))
head(lavPredict(fit, type = "ov"))

nietsnel/psindex documentation built on June 22, 2019, 10:56 p.m.