MCFunc {semmcci} | R Documentation |
Monte Carlo Confidence Intervals (Function)
Description
Calculates Monte Carlo confidence intervals for defined parameters.
Usage
MCFunc(
coef,
vcov,
func,
...,
R = 20000L,
alpha = c(0.001, 0.01, 0.05),
decomposition = "eigen",
pd = TRUE,
tol = 1e-06,
seed = NULL,
ncores = NULL
)
Arguments
coef |
Numeric vector. Vector of estimated parameters. |
vcov |
Numeric matrix. Sampling variance-covariance matrix of estimated parameters. |
func |
R function.
|
... |
Additional arguments to pass to |
R |
Positive integer. Number of Monte Carlo replications. |
alpha |
Numeric vector.
Significance level |
decomposition |
Character string.
Matrix decomposition of the sampling variance-covariance matrix
for the data generation.
If |
pd |
Logical.
If |
tol |
Numeric.
Tolerance used for |
seed |
Integer. Random seed for reproducibility. |
ncores |
Positive integer.
Number of cores to use.
If |
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 defined parameters
are generated using the simulated sampling distribution.
Parameters are defined using the func
argument.
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 ("MCFunc").
Author(s)
Ivan Jacob Agaloos Pesigan
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
See Also
Other Monte Carlo in Structural Equation Modeling Functions:
Func()
,
MC()
,
MCGeneric()
,
MCMI()
,
MCStd()
Examples
library(semmcci)
## MCFunc() ----------------------------------------------------------------
### Define func ------------------------------------------------------------
func <- function(x) {
out <- exp(x)
names(out) <- "exp"
return(out)
}
### Generate Confidence Intervals ------------------------------------------
MCFunc(
coef = 0,
vcov = matrix(1),
func = func,
R = 5L, # use a large value e.g., 20000L for actual research
alpha = 0.05
)