Learn R Programming

MBESS (version 4.1.0)

mediation: Effect sizes and confidence intervals in a mediation model

Description

Automate the process of simple mediation analysis (one independent variable and one mediator) and effect size estimation for mediation models, as discussed in Preacher and Kelley (2011).

Usage

mediation(x, mediator, dv, S = NULL, N = NULL, x.location.S = NULL, mediator.location.S = NULL, dv.location.S = NULL, mean.x = NULL, mean.m = NULL, mean.dv = NULL, conf.level = 0.95, bootstrap = FALSE, B = 10000, which.boot="both", save.bs.replicates=FALSE, complete.set=FALSE)

Arguments

x
vector of the predictor/independent variable
mediator
vector of the mediator variable
dv
vector of the dependent/outcome variable
S
Covariance matrix
N
Sample size, necessary when a covariance matrix (S) is used
x.location.S
location of the predictor/independent variable in the covariance matrix (S)
mediator.location.S
location of the mediator variable in the covariance matrix (S)
dv.location.S
location of the dependent/outcome variable in the covariance matrix (S)
mean.x
mean of the x (independent/predictor) variable when a covariance matrix (S) is used
mean.m
mean of the m (mediator) variable when a covariance matrix (S) is used
mean.dv
mean of the y/dv (dependent/outcome) variable when a covariance matrix (S) is used
conf.level
desired level of confidence (e.g., .90, .95, .99, etc.)
bootstrap
TRUE or FALSE, based on whether or not a bootstrap procedure is performed to obtain confidence intervals for the various effect sizes
B
number of bootstrap replications when bootstrap=TRUE (e.g., 10000)
which.boot
which bootstrap method to use. It can be Percentile or BCa, or both
save.bs.replicates
Logical argument indicating whether to save the each bootstrap sample or not
complete.set
identifies if the function should report the estimated kappa.squarred (see below)

Value

Details

Based on the work of Preacher and Kelley (2010) and works cited therein, this function implements (simple) mediation analysis in a way that automates much of the results that are generally of interest, where "simple" means one independent variable, one mediator, and one dependent variable. More specifically, three regression outputs are automated as is the calculation of effect sizes that are thought to be useful or potentially useful in the context of mediation. Much work on mediation models exists in the literature, which should be consulted for proper interpretation of the effect sizes, models, and meaning of results. The usefulness of effect size $\kappa^2$ was called into question by Wen and Fan (2015). Further, another paper by Lachowicz, Preacher, and Kelley (submitted) offers a better was of quantifying the effect size and it is developed for more complex models. Users are encouraged to use, instead of or in addition to this function, the upsilon function.

References

Buyse, M., & Molenberghs, G. (1998). Criteria for the validation of surrogate endpoints in randomized experiments. Biometrics, 54, 1014--1029.

Ditlevsen, S., Christensen, U., Lynch, J., Damsgaard, M. T., & Keiding, N. (2005). The mediation proportion: A structural equation approach for estimating the proportion of exposure effect on outcome explained by an intermediate variable. Epidemiology, 16, 114--120.

Freedman, L. S. (2001). Confidence intervals and statistical power of the 'Validation' ratio for surrogate or intermediate endpoints. Journal of Statistical Planning and Inference, 96, 143--153.

Hansen, W. B., & McNeal, R. B. (1996). The law of maximum expected potential effect: Constraints placed on program effectiveness by mediator relationships. Health Education Research, 11, 501--507.

Huang, B., Sivaganesan, S., Succop, P., & Goodman, E. (2004). Statistical assessment of mediational effects for logistic mediational models. Statistics in Medicine, 23, 2713--2728.

Lachowicz, M. J., Preacher, K. J., & Kelley, K. (submitted). A novel measure of effect size for mediation analysis. Submited for publication.

Lindenberger, U., & Potter, U. (1998). The complex nature of unique and shared effects in hierarchical linear regression: Implications for developmental psychology. Psychological Methods, 3, 218--230.

MacKinnon, D. P. (2008). Introduction to statistical mediation analysis. Mahwah, NJ: Erlbaum.

Preacher, K. J., & Hayes, A. F. (2008b). Asymptotic and resampling strategies for assessing and comparing indirect effects in multiple mediator models. Behavior Research Methods, 40, 879--891.

Preacher, K. J., & Kelley, K. (2011). Effect size measures for mediation models: Quantitative and graphical strategies for communicating indirect effects. Psychological Methods, 16, 93--115.

Sobel, M. E. (1982). Asymptotic confidence intervals for indirect effects in structural equation models. In S. Leinhardt (Ed.), Sociological Methodology 1982 (pp. 290--312). Washington DC: American Sociological Association.

Wen, Z., & Fan, X. (2015). Monotonicity of effect sizes: Questioning kappa-squared as mediation effect size measure. Psychological Methods, 20, 193--203.

See Also

mediation.effect.plot, mediation.effect.bar.plot

Examples

Run this code
## Not run: 
# ############################################
# # EXAMPLE 1
# # Using the Jessor data discussed in Preacher and Kelley (2011), to illustrate
# # the methods based on summary statistics. 
#  
# mediation(S=rbind(c(2.26831107,  0.6615415, -0.08691755), 
# c(0.66154147,  2.2763549, -0.22593820), c(-0.08691755, -0.2259382,  0.09218055)), 
# N=432, x.location.S=1, mediator.location.S=2, dv.location.S=3, mean.x=7.157645, 
# mean.m=5.892785, mean.dv=1.649316, conf.level=.95)
# 
# ############################################
# # EXAMPLE 2
# # Clear the workspace:
# rm(list=ls(all=TRUE))
# 
# # An (Unrealistic) example data (from Hayes) 
# Data <- rbind(
#   c(-5.00, 25.00, -1.00),
#   c(-4.00, 16.00, 2.00),
#   c(-3.00, 9.00, 3.00),
#   c(-2.00, 4.00, 4.00),
#   c(-1.00, 1.00, 5.00),
#   c(.00, .00, 6.00),
#   c(1.00, 1.00, 7.00),
#   c(2.00, 4.00, 8.00),
#   c(3.00, 9.00, 9.00),
#   c(4.00, 16.00, 10.00),
#   c(5.00, 25.00, 13.00),
#   c(-5.00, 25.00, -1.00),
#   c(-4.00, 16.00, 2.00),
#   c(-3.00, 9.00, 3.00),
#   c(-2.00, 4.00, 4.00),
#   c(-1.00, 1.00, 5.00),
#   c(.00, .00, 6.00),
#   c(1.00, 1.00, 7.00),
#   c(2.00, 4.00, 8.00),
#   c(3.00, 9.00, 9.00),
#   c(4.00, 16.00, 10.00),
#   c(5.00, 25.00, 13.00))
# 
# 
# # "Regular" example of the Hayes data.
# mediation(x=Data[,1], mediator=Data[,2], dv=Data[,3], conf.level=.95)
# 
# # Sufficient statistics example of the Hayes data.
# mediation(S=var(Data), N=22, x.location.S=1, mediator.location.S=2, dv.location.S=3, 
# mean.x=mean(Data[,1]), mean.m=mean(Data[,2]), mean.dv=mean(Data[,3]), conf.level=.95)
# 
# # Example had there been two groups. 
# gp.size <- length(Data[,1])/2 # adjust if using an odd number of observations.
# grouping.variable <- c(rep(0, gp.size), rep(1, gp.size))
# mediation(x=grouping.variable, mediator=Data[,2], dv=Data[,3])
# 
# ############################################
# # EXAMPLE 3
# # Bootstrap of continuous data. 
# set.seed(12414) # Seed used for repeatability (there is nothing special about this seed)
# bs.Results <- mediation(x=Data[,1], mediator=Data[,2], dv=Data[,3], 
# bootstrap=TRUE, B=5000, save.bs.replicates=TRUE)
# 
# ls() # Notice that Bootstrap.Replicates is available in the 
# workspace (if save.bs.replicates=TRUE in the above call). 
# 
# #Now, given the Bootstrap.Replicates object, one can do whatever they want with them. 
# 
# # See the names of the effect sizes (and their ordering)
# colnames(Bootstrap.Replicates)
# 
# # Define IE as the indirect effect from the Bootstrap.Replicates object. 
# IE <- Bootstrap.Replicates$Indirect.Effect
# 
# # Summary statistics
# mean(IE)
# median(IE)
# sqrt(var(IE))
# 
# # CIs from percentile perspective
# quantile(IE, probs=c(.025, .975))
# 
# # p-value. 
# mean(IE>0)
# ## End(Not run)

Run the code above in your browser using DataLab