lavPredict {lavaan}R Documentation

Predict the values of latent or obsered variables.

Description

The lavPredict() function can be used to compute estimated values for latent variables, and model predicted values for observed variables.

Usage

lavPredict(object, type = "lv", newdata = NULL, method = "EBM",
           se.fit = FALSE, label = TRUE, optim.method = "nlminb")

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 observed variables in the model are computed.

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 only option (for now) is "EBM" for the Empirical Bayes Modal approach.

se.fit

Not used yet.

label

Logical. If TRUE, the columns are labeled.

optim.method

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

Details

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

See Also

lavaan

Examples

# 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"))

[Package lavaan version 0.5-18 Index]