% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/generics.R, R/generics_modsem_pi.R,
%   R/predict_da.R
\name{modsem_predict}
\alias{modsem_predict}
\alias{modsem_predict.modsem_pi}
\alias{modsem_predict.modsem_da}
\title{Predict From \code{modsem} Models}
\usage{
modsem_predict(object, ...)

\method{modsem_predict}{modsem_pi}(object, ...)

\method{modsem_predict}{modsem_da}(
  object,
  newdata = NULL,
  method = c("EBM", "ML", "Bartlett", "Regression"),
  type = c("lv", "ov", "all"),
  standardized = FALSE,
  se = FALSE,
  drop.list.single.group = TRUE,
  ...
)
}
\arguments{
\item{object}{An object of class \code{modsem_pi} or \code{modsem_da},
respectively.}

\item{...}{Further arguments passed to \code{lavaan::predict} for
\code{\link{modsem_pi}} objects; currently ignored by the
\code{\link{modsem_da}} method.}

\item{newdata}{Optional \code{data.frame} or matrix. If supplied, factor
scores are computed for these observations instead of the data used during
model estimation. Must contain all observed-variable columns required by
the model; missing values are handled via FIML. Currently only supported
by the \code{\link{modsem_da}} method.}

\item{method}{Character. Scoring method. One of \code{"EBM"} (Empirical
Bayes Modal; MAP estimate of the posterior), \code{"ML"} (maximum
likelihood), \code{"Regression"} (alias for \code{"EBM"}), or
\code{"Bartlett"} (alias for \code{"ML"}). For \code{\link{modsem_da}}
objects this selects the optimisation-based scoring algorithm. For
\code{\link{modsem_pi}} objects the argument is forwarded to
\code{lavaan::lavPredict}, which accepts the same \code{method} values.}

\item{type}{Character. Which scores to return: \code{"lv"} for latent
variable scores only (default), \code{"ov"} for model-implied observed
variable scores, or \code{"all"} for both combined. For
\code{\link{modsem_da}} objects this is handled directly; for
\code{\link{modsem_pi}} objects it is forwarded to
\code{lavaan::lavPredict}, which supports the same \code{type} values.}

\item{standardized}{Logical. If \code{TRUE}, each score column is
standardised (mean 0, SD 1) before returning. Currently only used by the
\code{\link{modsem_da}} method.}

\item{se}{Logical. If \code{TRUE}, attach standard-error and asymptotic
covariance attributes for \code{\link{modsem_da}} predictions. Standard
errors are returned in the \code{"se"} attribute and covariance matrices in
the \code{"acov"} attribute.}

\item{drop.list.single.group}{Logical. If \code{TRUE}, covariance attributes
for single-group \code{\link{modsem_da}} predictions drop the outer group
list, matching \code{lavaan::lavPredict}.}
}
\value{
* For \code{\link{modsem_pi}}: whatever \code{lavaan::predict()} returns,
  which is usually a matrix of factor scores.
* For \code{\link{modsem_da}}: a numeric matrix with one row per
  observation. Columns depend on \code{type}: latent variable scores
  (\code{"lv"}), model-implied observed-variable scores (\code{"ov"}), or
  both (\code{"all"}). Columns are optionally standardised if
  \code{standardized = TRUE}.
}
\description{
A generic function (and corresponding methods) that produces predicted
values or factor scores from \code{\link{modsem}} models.
}
\section{Methods (by class)}{
\itemize{
\item \code{modsem_predict(modsem_pi)}: Wrapper for \code{lavaan::predict}

\item \code{modsem_predict(modsem_da)}: Computes factor scores or model-implied observed-variable scores for a
\code{\link{modsem_da}} model via MAP optimisation.

}}
\examples{
m1 <- '
# Outer Model
  X =~ x1 + x2 + x3
  Z =~ z1 + z2 + z3
  Y =~ y1 + y2 + y3

# Inner Model
  Y ~ X + Z + X:Z
'

est_dca <- modsem(m1, oneInt, method = "dblcent")
head(modsem_predict(est_dca))

\dontrun{
est_lms <- modsem(m1, oneInt, method = "lms")
head(modsem_predict(est_lms))
}

}
