modsem_predict | R Documentation |
modsem
ModelsA generic function (and corresponding methods) that produces predicted
values or factor scores from modsem
models.
modsem_predict(object, ...)
## S3 method for class 'modsem_da'
modsem_predict(
object,
standardized = FALSE,
H0 = TRUE,
newdata = NULL,
center.data = TRUE,
...
)
## S3 method for class 'modsem_pi'
modsem_predict(object, ...)
object |
|
... |
Further arguments passed to |
standardized |
Logical. If |
H0 |
Logical. If |
newdata |
Compute factor scores based on a different dataset, than the one used in the model estimation. |
center.data |
Should data be centered before computing factor scores? Default is |
* For modsem_pi
: whatever lavaan::predict()
, which usually
returns a matrix of factor scores.
* For modsem_da
: a numeric matrix n \times p
, where n
is the number of
(complete) observations in the dataset, and p
the number of latent variables. Each
column contains either raw or standardised factor scores, depending on the
standardized
argument.
modsem_predict(modsem_da)
: Computes (optionally standardised) factor scores via the
regression method using the baseline model unless H0 = FALSE
.
modsem_predict(modsem_pi)
: Wrapper for lavaan::predict
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))
## Not run:
est_lms <- modsem(m1, oneInt, method = "lms")
head(modsem_predict(est_lms))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.