MCStd Function Use Case 1: Standardized Regression Coefficients
Ivan Jacob Agaloos Pesigan
2024-10-22
Source:vignettes/mcstd-1-std-regression.Rmd
mcstd-1-std-regression.Rmd
The MCStd()
function is used to generate Monte Carlo
confidence intervals for standardized regression coefficients.
Data
In this example, we use data from Kwan & Chan (2011) where child’s reading ability () is regressed on parental occupational status (), parental educational level (), and child’s home possession ()
Note that is the stochastic error term with expected value of zero and finite variance , is the intercept, and , , and are regression coefficients.
covs
#> Y1 X1 X2 X3
#> Y1 6088.8281 271.1429 49.5848 20.0337
#> X1 271.1429 226.2577 29.9232 4.8812
#> X2 49.5848 29.9232 9.0692 1.0312
#> X3 20.0337 4.8812 1.0312 0.8371
nobs
#> [1] 200
Model Fitting
We can now fit the model using the sem()
function from
lavaan
with mimic = "eqs"
to ensure
compatibility with results from Kwan & Chan
(2011).
Note: We recommend setting
fixed.x = FALSE
when generating standardized estimates and confidence intervals to model the variances and covariances of the exogenous observed variables if they are assumed to be random. Iffixed.x = TRUE
, which is the default setting inlavaan
,MC()
will fix the variances and the covariances of the exogenous observed variables to the sample values.
fit <- sem(
model = model, mimic = "eqs", fixed.x = FALSE,
sample.cov = covs, sample.nobs = nobs
)
Standardized Monte Carlo Confidence Intervals
Standardized Monte Carlo Confidence intervals can be generated by
passing the result of the MC()
function to the
MCStd()
function.
unstd <- MC(fit, R = 20000L, alpha = 0.05)
MCStd(unstd, alpha = 0.05)
#> Standardized Monte Carlo Confidence Intervals
#> est se R 2.5% 97.5%
#> Y1~X1 0.1207 0.0900 20000 -0.0586 0.2945
#> Y1~X2 0.0491 0.0913 20000 -0.1305 0.2278
#> Y1~X3 0.2194 0.0709 20000 0.0783 0.3565
#> Y1~~Y1 0.9002 0.0405 20000 0.8005 0.9575
#> X1~~X1 1.0000 0.0000 20000 1.0000 1.0000
#> X1~~X2 0.6606 0.0408 20000 0.5730 0.7340
#> X1~~X3 0.3547 0.0627 20000 0.2257 0.4719
#> X2~~X2 1.0000 0.0000 20000 1.0000 1.0000
#> X2~~X3 0.3743 0.0622 20000 0.2470 0.4900
#> X3~~X3 1.0000 0.0000 20000 1.0000 1.0000