Skip to contents

Monte Carlo Confidence Intervals for the Parameter Estimates

Usage

# S3 method for class 'semmcci'
confint(object, parm = NULL, level = 0.95, ...)

Arguments

object

Object of class semmcci.

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.

Value

Returns a matrix of confidence intervals.

Author

Ivan Jacob Agaloos Pesigan

Examples

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)
#>                          2.5 %    97.5 %
#> cp                  0.14744403 0.7424726
#> b                   0.39090186 0.6275559
#> a                   0.25381433 0.9820780
#> cond~~cond          0.17972964 0.2524786
#> reaction~~reaction  1.34975722 2.2492023
#> pmi~~pmi            1.29018738 1.9165882
#> reaction~1         -0.06055857 1.1563419
#> pmi~1               5.03084449 5.5610594
#> cond~1              0.40614698 0.4774202
#> indirect            0.10571688 0.6181068
#> direct              0.14744403 0.7424726
#> total               0.28138005 0.9628996
confint(std)
#>                         2.5 %    97.5 %
#> cp                 0.04537408 0.2215256
#> b                  0.33150148 0.5391836
#> a                  0.08727263 0.3392317
#> cond~~cond         1.00000000 1.0000000
#> reaction~~reaction 0.64807453 0.8778464
#> pmi~~pmi           0.88325556 0.9923690
#> indirect           0.03291196 0.1751982
#> direct             0.04537408 0.2215256
#> total              0.08728626 0.2877587

# 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)
#>                          2.5 %    97.5 %
#> cp                 -0.14995801 0.4109224
#> b                   0.44634838 0.6073850
#> a                  -0.12663687 0.7490378
#> cond~~cond          0.21245147 0.2869141
#> reaction~~reaction  1.70126346 2.2532347
#> pmi~~pmi            1.63113261 2.0323056
#> indirect           -0.07290374 0.4550059
#> direct             -0.14995801 0.4109224
#> total               0.25450317 0.6908409
confint(std)
#>                          2.5 %    97.5 %
#> cp                 -0.04435560 0.1136109
#> b                   0.39462158 0.5548349
#> a                  -0.04176436 0.2736435
#> cond~~cond          1.00000000 1.0000000
#> reaction~~reaction  0.69848874 0.8389369
#> pmi~~pmi            0.92487793 0.9958554
#> indirect           -0.01983783 0.1410071
#> direct             -0.04435560 0.1136109
#> total               0.07658417 0.2139349