Calculates standardized Monte Carlo confidence intervals for free and defined parameters.
Usage
MCStd(object, alpha = c(0.001, 0.01, 0.05))
Arguments
- object
object of class
semmcci
. Output of theMC()
function.- alpha
Numeric vector. Significance level \(\alpha\).
Value
Returns an object of class semmccistd
which is a list with the following elements:
R
Number of Monte Carlo replications.
alpha
Significance level \(\alpha\) specified.
lavaan
lavaan
object.decomposition
Matrix decomposition used to generate multivariate normal random variates.
thetahat
Parameter estimates \(\hat{\theta}\).
thetahatstar
Sampling distribution of parameter estimates \(\hat{\theta}^{\ast}\).
ci
Confidence intervals.
thetahat_std
Standardized parameter estimates \(\hat{\theta}_{\mathrm{std}}\).
thetahatstar_std
Standardized sampling distribution of parameter estimates \(\hat{\theta}^{\ast}_{\mathrm{std}}\).
Details
The empirical sampling distribution
of parameter estimates from the argument object
is standardized,
that is, each randomly generated vector of parameters is standardized.
Defined parameters are computed from the standardized component parameters.
Confidence intervals are generated
using the standardized empirical sampling distribution.
Examples
library(semmcci)
library(lavaan)
# Generate Data ------------------------------------------------------------
n <- 1000
a <- 0.50
b <- 0.50
cp <- 0.25
s2_em <- 1 - a^2
s2_ey <- 1 - cp^2 - a^2 * b^2 - b^2 * s2_em - 2 * cp * a * b
em <- rnorm(n = n, mean = 0, sd = sqrt(s2_em))
ey <- rnorm(n = n, mean = 0, sd = sqrt(s2_ey))
X <- rnorm(n = n)
M <- a * X + em
Y <- cp * X + b * M + ey
df <- data.frame(X, M, Y)
# Fit Model in lavaan ------------------------------------------------------
model <- "
Y ~ cp * X + b * M
M ~ a * X
indirect := a * b
direct := cp
total := cp + (a * b)
"
fit <- sem(data = df, model = model, fixed.x = FALSE)
# Monte Carlo --------------------------------------------------------------
output <- MC(
fit,
R = 100L, # use a large value e.g., 20000L for actual research
alpha = c(0.001, 0.01, 0.05)
)
# Standardized Monte Carlo -------------------------------------------------
MCStd(output)
#> Standardized Monte Carlo Confidence Intervals
#> est se R 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> cp 0.2644 0.0257 100 0.2038 0.2046 0.2116 0.3076 0.3168 0.3223
#> b 0.4968 0.0220 100 0.4427 0.4429 0.4526 0.5437 0.5456 0.5461
#> a 0.4889 0.0277 100 0.4223 0.4229 0.4326 0.5350 0.5457 0.5474
#> Y~~Y 0.5548 0.0207 100 0.5121 0.5132 0.5178 0.5970 0.6072 0.6090
#> M~~M 0.7610 0.0269 100 0.7003 0.7023 0.7138 0.8129 0.8212 0.8217
#> X~~X 1.0000 0.0000 100 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
#> indirect 0.2429 0.0165 100 0.2040 0.2048 0.2069 0.2728 0.2788 0.2794
#> direct 0.2644 0.0257 100 0.2038 0.2046 0.2116 0.3076 0.3168 0.3223
#> total 0.5073 0.0240 100 0.4483 0.4505 0.4569 0.5480 0.5554 0.5618