Confidence Interval of Indirect Effect or Conditional Indirect Effect
Source:R/confint_indirect.R
confint.indirect.Rd
Return the
confidence interval of the indirect
effect or conditional indirect effect
stored in the output of
indirect_effect()
or
cond_indirect()
.
Usage
# S3 method for class 'indirect'
confint(object, parm, level = 0.95, boot_type, ...)
Arguments
- object
The output of
indirect_effect()
orcond_indirect()
.- parm
Ignored because the stored object always has only one parameter.
- level
The level of confidence, default is .95, returning the 95% confidence interval.
- boot_type
If bootstrap confidence interval is to be formed, the type of bootstrap confidence interval. The supported types are
"perc"
(percentile bootstrap confidence interval, the recommended method) and"bc"
(bias-corrected, or BC, bootstrap confidence interval). If not supplied, the storedboot_type
will be used.- ...
Additional arguments. Ignored by the function.
Details
It extracts and returns the stored confidence interval if available.
The type of confidence interval depends on the call used to compute the effect. This function merely retrieves the stored estimates, which could be generated by nonparametric bootstrapping, Monte Carlo simulation, or other methods to be supported in the future, and uses them to form the percentile confidence interval.
If the following conditions are met, the stored standard errors, if available, will be used test an effect and form it confidence interval:
Confidence intervals have not been formed (e.g., by bootstrapping or Monte Carlo).
The path has no mediators.
The model has only one group.
The path is moderated by one or more moderator.
Both the
x
-variable and they
-variable are not standardized.
If the model is fitted by OLS
regression (e.g., using stats::lm()
),
then the variance-covariance matrix
of the coefficient estimates will be
used, and confidence
intervals are computed from the t
statistic.
If the model is fitted by structural
equation modeling using lavaan
, then
the variance-covariance computed by
lavaan
will be used,
and confidence intervals are computed
from the z statistic.
Caution
If the model is fitted by structural equation modeling and has moderators, the standard errors, p-values, and confidence interval computed from the variance-covariance matrices for conditional effects can only be trusted if all covariances involving the product terms are free. If any of them are fixed, for example, fixed to zero, it is possible that the model is not invariant to linear transformation of the variables.
Examples
dat <- modmed_x1m3w4y1
# Indirect Effect
library(lavaan)
mod1 <-
"
m1 ~ x
m2 ~ m1
y ~ m2 + x
"
fit <- sem(mod1, dat,
meanstructure = TRUE, fixed.x = FALSE,
se = "none", baseline = FALSE)
# R should be at least 2000 or 5000 in real research.
out1 <- indirect_effect(x = "x", y = "y",
m = c("m1", "m2"),
fit = fit,
boot_ci = TRUE, R = 45, seed = 54151,
parallel = FALSE,
progress = FALSE)
out1
#>
#> == Indirect Effect ==
#>
#> Path: x -> m1 -> m2 -> y
#> Indirect Effect: 0.064
#> 95.0% Bootstrap CI: [-0.052 to 0.156]
#>
#> Computation Formula:
#> (b.m1~x)*(b.m2~m1)*(b.y~m2)
#>
#> Computation:
#> (0.52252)*(0.39883)*(0.30941)
#>
#>
#> Percentile confidence interval formed by nonparametric bootstrapping
#> with 45 bootstrap samples.
#>
#> Coefficients of Component Paths:
#> Path Coefficient
#> m1~x 0.523
#> m2~m1 0.399
#> y~m2 0.309
#>
confint(out1)
#> Percentile: 2.5 % Percentile: 97.5 %
#> y~x -0.05232493 0.1562506