mediation: Mediation Analysis

View source: R/mediation.R

mediationR Documentation

Mediation Analysis

Description

Return all direct and indirect effects within a recursive path model.

Usage

mediation(
  model,
  data = NULL,
  stat = all_indirect,
  nrep = 5000,
  alpha = 0.05,
  standardized = FALSE
)

Arguments

model

an object of class "formula": a symbolic description of the model to be fitted. More details of model specification are given under "Details". Basically, model is the order of the variables in the model from last (outcome variables) to first (exogenous variables).

data

an optional data frame, list or environment (or object coercible by as.data.frame() to a data frame) containing the variables in the model. If data = NULL, the variables are taken from environment(formula), typically the environment from which mediation is called.

stat

A function for the statistics to compute either all_indirect (saturated model) or specific_indirect

nrep

Number of repetitions for the boostrap. Default is 5000.

alpha

Type I error rate to build the 100 * (1-\alpha)% confidence interval. Default is .05.

standardized

Option to get standardized coefficients.

Details

Basically, mediation is a wrapper for the boot function from the pathanalysis package.

Value

The mediation analysis

Examples

mediation(model = y ~ m2 ~ m1 ~ x, data = medEX, standardized = TRUE)

quantmeth/pathanalysis documentation built on Aug. 6, 2023, 8:56 a.m.