Calculates Monte Carlo confidence intervals for free and defined parameters.
Usage
MC(
lav,
R = 20000L,
alpha = c(0.001, 0.01, 0.05),
decomposition = "eigen",
pd = TRUE,
tol = 1e-06,
seed = NULL
)
Arguments
- lav
Object of class
lavaan
.- R
Positive integer. Number of Monte Carlo replications.
- alpha
Numeric vector. Significance level \(\alpha\).
- decomposition
Character string. Matrix decomposition of the sampling variance-covariance matrix for the data generation. If
decomposition = "chol"
, use Cholesky decomposition. Ifdecomposition = "eigen"
, use eigenvalue decomposition. Ifdecomposition = "svd"
, use singular value decomposition.- pd
Logical. If
pd = TRUE
, check if the sampling variance-covariance matrix is positive definite usingtol
.- tol
Numeric. Tolerance used for
pd
.- seed
Integer. Random seed for reproducibility.
Value
Returns an object of class semmcci
which is
a list with the following elements:
- call
Function call.
- args
List of function arguments.
- thetahat
Parameter estimates \(\hat{\theta}\).
- thetahatstar
Sampling distribution of parameter estimates \(\hat{\theta}^{\ast}\).
- fun
Function used ("MC").
Details
A sampling distribution of parameter estimates is generated
from the multivariate normal distribution
using the parameter estimates and the sampling variance-covariance matrix.
Confidence intervals for free and defined parameters
are generated using the simulated sampling distribution.
Parameters can be defined using the :=
operator
in the lavaan
model syntax.
References
MacKinnon, D. P., Lockwood, C. M., & Williams, J. (2004). Confidence limits for the indirect effect: Distribution of the product and resampling methods. Multivariate Behavioral Research, 39(1), 99-128. doi:10.1207/s15327906mbr3901_4
Pesigan, I. J. A., & Cheung, S. F. (2023). Monte Carlo confidence intervals for the indirect effect with missing data. Behavior Research Methods. doi:10.3758/s13428-023-02114-4
Preacher, K. J., & Selig, J. P. (2012). Advantages of Monte Carlo confidence intervals for indirect effects. Communication Methods and Measures, 6(2), 77–98. doi:10.1080/19312458.2012.679848
Examples
library(semmcci)
library(lavaan)
#> This is lavaan 0.6-19
#> lavaan is FREE software! Please report any bugs.
# Data ---------------------------------------------------------------------
data("Tal.Or", package = "psych")
df <- mice::ampute(Tal.Or)$amp
# Monte Carlo --------------------------------------------------------------
## Fit Model in lavaan -----------------------------------------------------
model <- "
reaction ~ cp * cond + b * pmi
pmi ~ a * cond
cond ~~ cond
indirect := a * b
direct := cp
total := cp + (a * b)
"
fit <- sem(data = df, model = model, missing = "fiml")
## MC() --------------------------------------------------------------------
MC(
fit,
R = 5L, # use a large value e.g., 20000L for actual research
alpha = 0.05
)
#> Monte Carlo Confidence Intervals
#> est se R 2.5% 97.5%
#> cp 0.2235 0.0896 5 0.1924 0.4207
#> b 0.4887 0.0864 5 0.3610 0.5406
#> a 0.4741 0.3787 5 0.0740 0.9810
#> cond~~cond 0.2494 0.0296 5 0.2223 0.2912
#> reaction~~reaction 1.8401 0.2955 5 1.4575 2.2071
#> pmi~~pmi 1.7413 0.1565 5 1.6776 2.0474
#> reaction~1 0.6304 0.5826 5 0.2263 1.5980
#> pmi~1 5.3771 0.3198 5 4.9565 5.6760
#> cond~1 0.4826 0.0233 5 0.4521 0.5068
#> indirect 0.2317 0.1517 5 0.0321 0.3609
#> direct 0.2235 0.0896 5 0.1924 0.4207
#> total 0.4551 0.1710 5 0.3385 0.7492