The following presents an example of how to use the functions in this package to generate confidence intervals for the indirect effect for the model fitted in the Model Fitting article.
Arguments
| Variables | Values | Notes |
|---|---|---|
| R | 20000 | Number of Monte Carlo replications. |
| B | 5000 | Number of bootstrap samples. |
Monte Carlo Method
Maximum Likelihood
mc_ml <- MCML(
fit_ml,
R = R
)
mc_ml
#> 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> -0.014833023 -0.000230099 0.009405113 0.123442323 0.150985676 0.187875583Multiple Imputation
The two versions are based on the pooled covariance matrix used.
vcov uses the total covariance matrix \(\mathbf{V}_{T}\) while
vcov_tilde uses the adjusted total covariance matrix \(\tilde{\mathbf{V}}_{T}\).
mc_mi <- MCMI(
fit_mi,
R = R
)
mc_mi
#> 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> vcov -0.012533766 -0.0008536301 0.008771913 0.1244398 0.1533265 0.2002091
#> vcov_tilde -0.009596199 0.0010447389 0.010266007 0.1212220 0.1455933 0.1754708Nonparametric Bootstrapping
Maximum Likelihood Nested within Nonparametric Bootstrap (NB(ML))
nb_ml <- NBML(
data_missing,
B = B,
mplus_bin = mplus_bin
)
nb_ml
#> Lower .5% Lower 2.5% Lower 5% Estimate Upper 5% Upper 2.5% Upper .5%
#> bc 0.002 0.012 0.018 0.056 0.127 0.142 0.171
#> pc -0.001 0.008 0.013 0.056 0.114 0.129 0.160Multiple Imputation
Multiple Imputation Nested Within Nonparametric Bootstrap (NB(MI))
nb_mi <- NBMI(
data_missing,
data_mi,
B = B,
m = m,
mplus_bin = mplus_bin
)
nb_mi
#> 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> bc -0.008599074 0.002197657 0.012710451 0.1431757 0.1785678 0.2054530
#> pc -0.010897738 -0.001965398 0.007835137 0.1283433 0.1575050 0.2002295Nonparametric Bootstrap Nested Within Multiple Imputation (MI(NB))
mi_nb <- MINB(
data_mi,
B = B
)
mi_nb
#> 0.05% 0.5% 2.5% 97.5% 99.5% 99.95%
#> bc -0.01025972 0.0026119888 0.012309673 0.1409874 0.1730426 0.2142799
#> pc -0.01551219 -0.0008570296 0.008490644 0.1295344 0.1604574 0.2014387Joint Significance Test
The JointSigML() and JointSigMI() functions
return 1 for a significant result and 0
otherwise. Note that the output vector’s name corresponds to the
alpha level. The default value of alpha is
alpha = c(0.05, 0.01, 0.001).
Maximum Likelihood
joint_ml <- JointSigML(
fit_ml
)
joint_ml
#> 0.05 0.01 0.001
#> 1 1 0Multiple Imputation
The two versions are based on the two types of pooled covariance matrices \(\mathbf{V}_{T}\) and \(\tilde{\mathbf{V}}_{T}\).
joint_mi <- JointSigMI(
fit_mi
)
joint_mi
#> 0.05 0.01 0.001
#> vcov 1 1 0
#> vcov_tilde 1 1 0Results
Here is a summary of the \(95\%\) confidence intervals.
ci <- rbind(
mc_ml[c(3, 4)],
mc_mi[, c(3, 4)],
nb_ml[, c(2, 6)],
nb_mi[, c(3, 4)],
mi_nb[, c(3, 4)]
)
rownames(ci) <- c(
"MC.FIML",
"MC.MI",
"MC.MI.ADJ",
"NBBC(FIML)",
"NBPC(FIML)",
"NBBC(MI)",
"NBPC(MI)",
"MI(NBBC)",
"MI(NBPC)"
)
knitr::kable(ci)| 2.5% | 97.5% | |
|---|---|---|
| MC.FIML | 0.0094051 | 0.1234423 |
| MC.MI | 0.0087719 | 0.1244398 |
| MC.MI.ADJ | 0.0102660 | 0.1212220 |
| NBBC(FIML) | 0.0120000 | 0.1420000 |
| NBPC(FIML) | 0.0080000 | 0.1290000 |
| NBBC(MI) | 0.0127105 | 0.1431757 |
| NBPC(MI) | 0.0078351 | 0.1283433 |
| MI(NBBC) | 0.0123097 | 0.1409874 |
| MI(NBPC) | 0.0084906 | 0.1295344 |