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.
lavPredict(object, type = "lv", newdata = NULL, method = "EBM",
se.fit = FALSE, label = TRUE, fsm = FALSE,
optim.method = "bfgs")
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.
An optional data.frame, containing the same variables as the data.frame used when fitting the model in object.
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.
Not used yet.
Logical. If TRUE, the columns are labeled.
Logical. If TRUE, return the factor score matrix as an attribute. Only for numeric data.
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.
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).
# NOT RUN {
# 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"))
# }
Run the code above in your browser using DataLab