indirectmed2: Indirect Effect for Serial Mediation

View source: R/indirectmed2.R

indirectmed2R Documentation

Indirect Effect for Serial Mediation

Description

This function runs a serial mediation model with two mediators to calculate the indirect effect, which will be used for bootstrapping the confidence interval of the indirect effect. This function is used in conjunction with the boot function and is formatted to work as a bootstrapped effect.

Usage

indirectmed2(formula2, formula3, formula4, x, m1, m2, df, random)

Arguments

formula2

The formula for mediation for the a1 path, usually m1 ~ x. Can also include covariates and will be eq2 if the createformula() function is used.

formula3

The formula for mediation for the a2 and d21 paths, usually m2 ~ x + m1. Can also include covariates and will be eq3 if the createformula() function is used.

formula4

The formula for mediation for the b1 and b2 paths, usually y ~ x + m1 + m2. Can also include covariates and will be eq4 if the createformula() function is used.

x

The column name for x in the data frame.

m1

The column name for mediator 1 in the data frame.

m2

The column name for mediator 2 in the data frame.

random

This variable is used to denote the data frame will be randomize by row, as part of the boot library.

data

The dataframe where the columns from the formula can be found.

Examples

indirectmed2("Q31 ~ Q151", "Q41 ~ Q151 + Q31",
             "Q11 ~ Q151 + Q31 + Q41", mtcars)

doomlab/MeMoBootR documentation built on April 5, 2023, 8:27 p.m.