mma: Marginal Mediation

View source: R/Marginal_Mediation.R

mmaR Documentation

Marginal Mediation

Description

Provides the ability to perform marginal mediation. Marginal mediation is particularly useful for situations where the mediator or outcome is categorical, a count, or some other non-normally distributed variable. The results provide the average marginal effects of the models, providing simple interpretation of the indirect effects.

Usage

mma(..., ind_effects, ci_type = "perc", boot = 500, ci = 0.95)

Arguments

...

the glm model objects; the first is the model with the outcome while the others are the mediated effects ("a" paths)

ind_effects

a vector of the desired indirect effects. Has the form "var1-var2".

ci_type

a string indicating the type of bootstrap method to use (currently "perc" and "basic" are available; "perc" is recommended). Further development will allow the Bias-Corrected bootstrap soon.

boot

the number of bootstrapped samples; default is 500.

ci

the confidence interval; the default is .95 which is the 95% confidence interval.

Details

Using the average marginal effects as discussed by Tamas Bartus (2005), the coefficients are transformed into probabilities (for binary outcomes) or remain in their original units (continuous outcomes).

Value

A list of class mma containing:

ind_effects

the indirect effects reported in the average marginal effect

dir_effects

the direct effects reported in the average marginal effect

ci_level

the confidence level

data

the original data frame

reported_ind

the indirect effects the user requested (in the ...)

boot

the number of bootstrap samples

model

the formulas of the individual sub-models

call

the original function call

Author(s)

Tyson S. Barrett

References

Bartus, T. (2005). Estimation of marginal effects using margeff. The Stata Journal, 5(3), 309–329.

MacKinnon, D. (2008). Introduction to Statistical Mediation Analysis. Taylor \& Francis, LLC.

Examples


## A minimal example:

library(furniture)
data(nhanes_2010)
bcpath = glm(marijuana ~ home_meals + gender + age + asthma, 
           data = nhanes_2010, 
           family = "binomial")
apath = glm(home_meals ~ gender + age + asthma,
           data = nhanes_2010, 
           family = "gaussian")
(fit = mma(bcpath, apath, 
           ind_effects = c("genderFemale-home_meals",
                           "age-home_meals",
                           "asthmaNo-home_meals"),
           boot = 10))


MarginalMediation documentation built on April 15, 2022, 9:06 a.m.