View source: R/lav_betaselect.R
lav_betaselect | R Documentation |
Can standardize selected
variables in a lavaan
model without
refitting the models, can handle
product term correctly and skip
categorical predictors in
standardization.
lav_betaselect(
object,
to_standardize = ".all.",
not_to_standardize = NULL,
skip_categorical_x = TRUE,
output = c("data.frame", "text"),
std_se = c("none", "delta", "bootstrap"),
std_z = TRUE,
std_pvalue = TRUE,
std_ci = TRUE,
level = 0.95,
progress = TRUE,
boot_out = NULL,
bootstrap = 100L,
store_boot_est = TRUE,
parallel = c("no", "snow", "multicore"),
ncpus = parallel::detectCores(logical = FALSE) - 1,
cl = NULL,
iseed = NULL,
find_product_terms = TRUE,
...,
delta_method = c("lavaan", "numDeriv"),
vector_form = TRUE
)
object |
The output of
|
to_standardize |
A string vector,
which should be the names of the
variables to be standardized.
Default is |
not_to_standardize |
A string
vector, which should be the names
of the variables that should not be
standardized. This argument is useful
when most variables, except for a few,
are to be standardized. This argument
cannot be ued with |
skip_categorical_x |
Logical.
If |
output |
The format of the
output. Not used because the format
of the printout is now controlled
by the |
std_se |
String. If set to |
std_z |
Logical. If |
std_pvalue |
Logical. If |
std_ci |
Logical. If |
level |
The level of confidence of the confidence intervals. Default is .95. It will be used in the confidence intervals of both the unstandardized and standardized solution. |
progress |
Logical. If |
boot_out |
If |
bootstrap |
If |
store_boot_est |
Logical. If
|
parallel |
If |
ncpus |
If |
cl |
If |
iseed |
If |
find_product_terms |
String.
If it is certain that a model does
not have product terms, setting this
to |
... |
Optional arguments to be
passed to the |
delta_method |
The method used to compute delta-method standard errors. For internal use and should not be changed. |
vector_form |
The internal method used to compute standardized solution. For internal use and should not be changed. |
This function lets users select which variables to be standardized when computing the standardized solution. It has the following features:
It automatically skips predictors which has only two unique values, assuming that they are dummy variables.
It does not standardize product term, which is incorrect. Instead, it computes the product term with its component variables standardized first.
It can be used to generate bootstrap confidence intervals for the standardized solution (Falk, 2018). Bootstrap confidence interval is better than doing standardization before fitting a model because it correctly takes into account the sampling variance of the standard deviations. It is also better than delta-method confidence interval because it takes into account the usually asymmetric distribution of parameters after standardization, such as standardized loadings and correlations.
For comparison, it can also report delta-method standard errors and confidence intervals if requested.
In most SEM programs, users have limited control on which variables to standardize when requesting the standardized solution. The solution may be uninterpretable or misleading in these conditions:
Dummy variables are standardized and their coefficients cannot be interpreted as the difference between two groups on the outcome variables.
Product terms (interaction terms) are standardized and they cannot be interpreted as the changes in the effects of focal variables when the moderators change (Cheung, Cheung, Lau, Hui, & Vong, 2022).
Variables with meaningful units can be more difficult to interpret when they are standardized (e.g., age).
Moreover, the delta method is usually used in standardization, which is suboptimal for standardization unless the sample size is large (Falk, 2018). For example, the covariance with variables standardized is a correlation, and its sampling distribution is skewed unless its population value is zero. However, delta-method confidence interval for the correlation is necessarily symmetric around the point estimate.
It only supports observed variable interaction terms, and only support two-way interactions.
It does not support multilevel models.
It only supports models fitted to raw data.
Intercepts not supported.
A lav_betaselect
-class object,
which is a data frame storing the parameter
estimates, similar in form to the
output of lavaan::parameterEstimates()
.
Shu Fai Cheung https://orcid.org/0000-0002-9871-9448
Asparouhov, A., & Muthén, B. (2021). Bootstrap p-value computation. Retrieved from https://www.statmodel.com/download/FAQ-Bootstrap%20-%20Pvalue.pdf
Cheung, S. F., Cheung, S.-H., Lau, E. Y. Y., Hui, C. H., & Vong, W. N. (2022) Improving an old way to measure moderation effect in standardized units. Health Psychology, 41(7), 502-505. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1037/hea0001188")}
Falk, C. F. (2018). Are robust standard errors the best approach for interval estimation with nonnormal data in structural equation modeling? Structural Equation Modeling: A Multidisciplinary Journal, 25(2) 244-266. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10705511.2017.1367254")}
print.lav_betaselect()
for its print method.
library(lavaan)
mod <-
"
med ~ iv + mod + iv:mod
dv ~ med + iv
"
fit <- sem(mod,
data_test_medmod,
fixed.x = TRUE)
summary(fit)
fit_beta <- lav_betaselect(fit,
to_standardize = c("iv", "dv"))
fit_beta
print(fit_beta, standardized_only = FALSE)
# In real studies:
# - should set bootstrap to at least 5000
# - should set parallel to "snow" or "multicore"
fit_beta_boot <- lav_betaselect(fit,
to_standardize = c("iv", "dv"),
std_se = "bootstrap",
std_ci = TRUE,
bootstrap = 100,
iseed = 1234)
fit_beta_boot
print(fit_beta_boot, standardized_only = FALSE)
# Print full results
print(fit_beta_boot,
standardized_only = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.