fix_to_zero {semlrtp} | R Documentation |
Fix a Free Parameter To Zero And Fit a Model Again
Description
It fixes a designated free parameter in a lavaan object to zero and refit the model.
Usage
fix_to_zero(fit, par_id, store_fit = FALSE, se_keep_bootstrap = FALSE)
Arguments
fit |
A |
par_id |
An integer. The row
number of the free parameter in the
parameter table of |
store_fit |
Logical. If |
se_keep_bootstrap |
Logical.
If |
Details
It modifies the parameter
table of a lavaan
-class object and
then fits the model again.
Users should usually call
lrtp()
directly instead of calling
this function. It is exported for
developers.
Value
A fix_to_zero
-class object, which
is a list with these elements:
-
fit0
is thelavaan
output of the refitted object.NA
if the fit failed for some reasons. To be considered an acceptable solution, the optimization must converge, the solution passeslavaan
's post check, the variance-covariance matrix of estimates successfully computed, and the increase in the model degree of freedom equal to the expected change. -
fit1
is the originallavaan
output ifstore_fit
isTRUE
. It isNULL
ifstore_fit
isFALSE
, the default. -
par_id
is the row number of the designated free parameter in the parameter table. -
call
is the original call to this function. -
ptable0
is the parameter table with the designated parameter fixed to zero. It can be used for diagnostic purpose if the fit failed. -
fit0_error
is the error message in refitting the model (ptable0
), if any. If no error, it isNA
. -
vcov_ok
isTRUE
if the variance-covariance matrix of the estimates can be computed without error nor warning.FALSE
otherwise. -
vcov_msg
is the message generated when usinglavaan::lavInspect()
to get the variance-covariance matrix of the parameter estimates of the refitted model. IfTRUE
, then no error nor warning. Can be used for diagnostic purposes. -
converged
: Whether refitting the modified model (ptable0
) converged. -
post_check_passed
: Whether the solution of the modified model (ptable0
) passedlavaan
's post check. -
post_check_msg
: If the solution failedlavaan
's post check, it stores the warning message. If the solution passes the check, it isNA
. -
fit_not_ok
: If the fit failed for some reasons, the fit object, if available, is stored in this element rather than infit0
. such that the fit object can be retrieved for diagnostic purposed if necessary. -
df_diff_one
: Whether the difference in model degrees of freedom between the modified model and the original model is one. If a variance is fitted to zero, related covariance(s) is/are also fitted to zero and so the difference in model degrees of freedom can be legitimately greater than one. -
se_force_standard
: Whetherse
was forced to be"standard"
even if it is"bootstrap"
infit
. IfFALSE
, then eitherse
is not"bootstrap"
infit
or it was not changed in fitting the restricted model.
Author(s)
Shu Fai Cheung https://orcid.org/0000-0002-9871-9448
See Also
Examples
library(lavaan)
data(data_sem16)
mod <-
"
f1 =~ x1 + x2 + x3
f2 =~ x4 + x5 + x6
"
fit <- sem(mod, data_sem16)
# Fix the factor covariance to zero
out <- fix_to_zero(fit, par_id = 15)
summary(out$fit0)