Title: | Monte Carlo Confidence Intervals in Structural Equation Modeling |
---|---|
Description: | Monte Carlo confidence intervals for free and defined parameters in models fitted in the structural equation modeling package 'lavaan' can be generated using the 'semmcci' package. 'semmcci' has three main functions, namely, MC(), MCMI(), and MCStd(). The output of 'lavaan' is passed as the first argument to the MC() function or the MCMI() function to generate Monte Carlo confidence intervals. Monte Carlo confidence intervals for the standardized estimates can also be generated by passing the output of the MC() function or the MCMI() function to the MCStd() function. A description of the package and code examples are presented in Pesigan and Cheung (2023) <doi:10.3758/s13428-023-02114-4>. |
Authors: | Ivan Jacob Agaloos Pesigan [aut, cre, cph] , Shu Fai Cheung [ctb] |
Maintainer: | Ivan Jacob Agaloos Pesigan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.4.9000 |
Built: | 2024-10-22 18:19:19 UTC |
Source: | https://github.com/jeksterslab/semmcci |
Parameter Estimates
## S3 method for class 'semmcci' coef(object, ...)
## S3 method for class 'semmcci' coef(object, ...)
object |
Object of class |
... |
additional arguments. |
Returns a vector of parameter estimates.
Ivan Jacob Agaloos Pesigan
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) coef(unstd) coef(std) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) coef(unstd) coef(std)
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) coef(unstd) coef(std) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) coef(unstd) coef(std)
Monte Carlo Confidence Intervals for the Parameter Estimates
## S3 method for class 'semmcci' confint(object, parm = NULL, level = 0.95, ...)
## S3 method for class 'semmcci' confint(object, parm = NULL, level = 0.95, ...)
object |
Object of class |
parm |
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered. |
level |
the confidence level required. |
... |
additional arguments. |
Returns a matrix of confidence intervals.
Ivan Jacob Agaloos Pesigan
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) confint(unstd) confint(std) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) confint(unstd) confint(std)
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) confint(unstd) confint(std) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) confint(unstd) confint(std)
Calculates Monte Carlo confidence intervals for defined parameters.
Func(coef, func, ..., est, alpha = c(0.001, 0.01, 0.05), ncores = NULL)
Func(coef, func, ..., est, alpha = c(0.001, 0.01, 0.05), ncores = NULL)
coef |
List. A list of parameters. |
func |
R function.
|
... |
Additional arguments to pass to |
est |
Numeric vector. Vector of original parameter estimates. |
alpha |
Numeric vector.
Significance level |
ncores |
Positive integer.
Number of cores to use.
If |
The distribution of parameters is provided as a list (params
)
and the definition of the function of paremeters
is provided by a function (func
).
Confidence intervals for defined parameters
are generated using the generated sampling distribution.
Returns an object of class semmcci
which is
a list with the following elements:
Function call.
List of function arguments.
Parameter estimates .
Sampling distribution of parameter estimates
.
Function used ("Func").
Ivan Jacob Agaloos Pesigan
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
Other Monte Carlo in Structural Equation Modeling Functions:
MC()
,
MCFunc()
,
MCGeneric()
,
MCMI()
,
MCStd()
library(semmcci) ## Generate Parameters ----------------------------------------------------- coef <- lapply( X = 1:5, FUN = function(i) { rnorm(n = 1) } ) ## Func() ------------------------------------------------------------------ ### Define func ------------------------------------------------------------ func <- function(x) { out <- exp(x) names(out) <- "exp" return(out) } ### Generate Confidence Intervals ------------------------------------------ Func( coef, func = func, est = 1, alpha = 0.05 )
library(semmcci) ## Generate Parameters ----------------------------------------------------- coef <- lapply( X = 1:5, FUN = function(i) { rnorm(n = 1) } ) ## Func() ------------------------------------------------------------------ ### Define func ------------------------------------------------------------ func <- function(x) { out <- exp(x) names(out) <- "exp" return(out) } ### Generate Confidence Intervals ------------------------------------------ Func( coef, func = func, est = 1, alpha = 0.05 )
Calculates Monte Carlo confidence intervals for free and defined parameters.
MC( lav, R = 20000L, alpha = c(0.001, 0.01, 0.05), decomposition = "eigen", pd = TRUE, tol = 1e-06, seed = NULL )
MC( lav, R = 20000L, alpha = c(0.001, 0.01, 0.05), decomposition = "eigen", pd = TRUE, tol = 1e-06, seed = NULL )
lav |
Object of class |
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. |
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.
Returns an object of class semmcci
which is
a list with the following elements:
Function call.
List of function arguments.
Parameter estimates .
Sampling distribution of parameter estimates
.
Function used ("MC").
Ivan Jacob Agaloos Pesigan
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
Other Monte Carlo in Structural Equation Modeling Functions:
Func()
,
MCFunc()
,
MCGeneric()
,
MCMI()
,
MCStd()
library(semmcci) library(lavaan) # 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 )
library(semmcci) library(lavaan) # 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 )
Calculates Monte Carlo confidence intervals for defined parameters.
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 )
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 )
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 |
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.
Returns an object of class semmcci
which is
a list with the following elements:
Function call.
List of function arguments.
Parameter estimates .
Sampling distribution of parameter estimates
.
Function used ("MCFunc").
Ivan Jacob Agaloos Pesigan
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
Other Monte Carlo in Structural Equation Modeling Functions:
Func()
,
MC()
,
MCGeneric()
,
MCMI()
,
MCStd()
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 )
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 )
Calculates Monte Carlo confidence intervals
for defined parameters
for any fitted model object with coef
and vcov
methods.
MCGeneric( object, def, R = 20000L, alpha = c(0.001, 0.01, 0.05), decomposition = "eigen", pd = TRUE, tol = 1e-06, seed = NULL )
MCGeneric( object, def, R = 20000L, alpha = c(0.001, 0.01, 0.05), decomposition = "eigen", pd = TRUE, tol = 1e-06, seed = NULL )
object |
R object.
Fitted model object with |
def |
List of character strings. A list of defined functions of parameters. The string should be a valid R expression when parsed and should result a single value when evaluated. |
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. |
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 def
argument.
Returns an object of class semmcci
which is
a list with the following elements:
Function call.
List of function arguments.
Parameter estimates .
Sampling distribution of parameter estimates
.
Function used ("MCGeneric").
Ivan Jacob Agaloos Pesigan
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
Other Monte Carlo in Structural Equation Modeling Functions:
Func()
,
MC()
,
MCFunc()
,
MCMI()
,
MCStd()
library(semmcci) library(lavaan) # 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 " fit <- sem(data = df, model = model, missing = "fiml") ## MCGeneric() ------------------------------------------------------------- MCGeneric( fit, R = 5L, # use a large value e.g., 20000L for actual research alpha = 0.05, def = list( "a * b", "cp + (a * b)" ) )
library(semmcci) library(lavaan) # 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 " fit <- sem(data = df, model = model, missing = "fiml") ## MCGeneric() ------------------------------------------------------------- MCGeneric( fit, R = 5L, # use a large value e.g., 20000L for actual research alpha = 0.05, def = list( "a * b", "cp + (a * b)" ) )
Calculates Monte Carlo confidence intervals for free and defined parameters. Missing values are handled using multilple imputation.
MCMI( lav, mi, R = 20000L, alpha = c(0.001, 0.01, 0.05), decomposition = "eigen", pd = TRUE, tol = 1e-06, seed = NULL )
MCMI( lav, mi, R = 20000L, alpha = c(0.001, 0.01, 0.05), decomposition = "eigen", pd = TRUE, tol = 1e-06, seed = NULL )
lav |
Object of class |
mi |
Object of class |
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. |
A sampling distribution of parameter estimates is generated
from the multivariate normal distribution
using the parameter estimates and the sampling variance-covariance matrix
obtained using multiple imputation.
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.
Returns an object of class semmcci
which is
a list with the following elements:
Function call.
List of function arguments.
Parameter estimates .
Sampling distribution of parameter estimates
.
Function used ("MCMI").
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
Rubin, D. B. (1987). Multiple imputation for nonresponse in surveys. John Wiley & Sons, Inc.
Other Monte Carlo in Structural Equation Modeling Functions:
Func()
,
MC()
,
MCFunc()
,
MCGeneric()
,
MCStd()
library(semmcci) library(lavaan) # Data --------------------------------------------------------------------- data("Tal.Or", package = "psych") df <- mice::ampute(Tal.Or)$amp # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## 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) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ MCMI( fit, mi = mi, R = 5L, # use a large value e.g., 20000L for actual research alpha = 0.05 )
library(semmcci) library(lavaan) # Data --------------------------------------------------------------------- data("Tal.Or", package = "psych") df <- mice::ampute(Tal.Or)$amp # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## 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) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ MCMI( fit, mi = mi, R = 5L, # use a large value e.g., 20000L for actual research alpha = 0.05 )
Calculates standardized Monte Carlo confidence intervals for free and defined parameters.
MCStd(mc, alpha = c(0.001, 0.01, 0.05))
MCStd(mc, alpha = c(0.001, 0.01, 0.05))
mc |
|
alpha |
Numeric vector.
Significance level |
The empirical sampling distribution
of parameter estimates from the argument mc
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.
Returns an object of class semmcci
which is
a list with the following elements:
Function call.
List of function arguments.
Parameter estimates .
Sampling distribution of parameter estimates
.
Function used ("MCStd").
Ivan Jacob Agaloos Pesigan
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
Other Monte Carlo in Structural Equation Modeling Functions:
Func()
,
MC()
,
MCFunc()
,
MCGeneric()
,
MCMI()
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L, # use a large value e.g., 20000L for actual research alpha = 0.05 ) ## Standardized Monte Carlo ------------------------------------------------ MCStd(unstd, alpha = 0.05) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L, # use a large value e.g., 20000L for actual research alpha = 0.05 ) ## Standardized Monte Carlo ------------------------------------------------ MCStd(unstd, alpha = 0.05)
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L, # use a large value e.g., 20000L for actual research alpha = 0.05 ) ## Standardized Monte Carlo ------------------------------------------------ MCStd(unstd, alpha = 0.05) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L, # use a large value e.g., 20000L for actual research alpha = 0.05 ) ## Standardized Monte Carlo ------------------------------------------------ MCStd(unstd, alpha = 0.05)
semmcci
Print Method for Object of Class semmcci
## S3 method for class 'semmcci' print(x, alpha = NULL, digits = 4, ...)
## S3 method for class 'semmcci' print(x, alpha = NULL, digits = 4, ...)
x |
an object of class |
alpha |
Numeric vector.
Significance level |
digits |
Integer indicating the number of decimal places to display. |
... |
further arguments. |
Prints a matrix of estimates, standard errors, number of Monte Carlo replications, and confidence intervals.
Ivan Jacob Agaloos Pesigan
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) print(unstd) print(std) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) print(unstd) print(std)
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) print(unstd) print(std) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) print(unstd) print(std)
semmcci
Summary Method for an Object of Class semmcci
## S3 method for class 'semmcci' summary(object, alpha = NULL, digits = 4, ...)
## S3 method for class 'semmcci' summary(object, alpha = NULL, digits = 4, ...)
object |
Object of class |
alpha |
Numeric vector.
Significance level |
digits |
Digits to print. |
... |
additional arguments. |
Returns a matrix of estimates, standard errors, number of Monte Carlo replications, and confidence intervals.
Ivan Jacob Agaloos Pesigan
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) summary(unstd) summary(std) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) summary(unstd) summary(std)
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) summary(unstd) summary(std) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) summary(unstd) summary(std)
Sampling Covariance Matrix of the Parameter Estimates
## S3 method for class 'semmcci' vcov(object, ...)
## S3 method for class 'semmcci' vcov(object, ...)
object |
Object of class |
... |
additional arguments. |
Returns a matrix of the variance-covariance matrix of parameter estimates.
Ivan Jacob Agaloos Pesigan
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) vcov(unstd) vcov(std) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) vcov(unstd) vcov(std)
library(semmcci) library(lavaan) # 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() -------------------------------------------------------------------- unstd <- MC( fit, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) vcov(unstd) vcov(std) # Monte Carlo (Multiple Imputation) ---------------------------------------- ## Multiple Imputation ----------------------------------------------------- mi <- mice::mice( data = df, print = FALSE, m = 5L, # use a large value e.g., 100L for actual research, seed = 42 ) ## Fit Model in lavaan ----------------------------------------------------- fit <- sem(data = df, model = model) # use default listwise deletion ## MCMI() ------------------------------------------------------------------ unstd <- MCMI( fit, mi = mi, R = 5L # use a large value e.g., 20000L for actual research ) ## Standardized Monte Carlo ------------------------------------------------ std <- MCStd(unstd) vcov(unstd) vcov(std)