DesignLibrary (version 0.1.2)

mediation_analysis_designer: Create a design for mediation analysis

Description

A mediation analysis design that examines the effect of treatment (Z) on mediator (M) and the effect of mediator (M) on outcome (Y) (given Z=0) as well as direct effect of treatment (Z) on outcome (Y) (given M=0). Analysis is implemented using an interacted regression model. Note this model is not guaranteed to be unbiased despite randomization of Z because of possible violations of sequential ignorability.

Usage

mediation_analysis_designer(N = 200, a = 1, b = 0.4, c = 0,
  d = 0.5, rho = 0)

Arguments

N

An integer. Size of sample.

a

A number. Parameter governing effect of treatment (Z) on mediator (M).

b

A number. Effect of mediator (M) on outcome (Y) when Z = 0.

c

A number. Interaction between mediator (M) and (Z) for outcome (Y).

d

A number. Direct effect of treatment (Z) on outcome (Y), when M = 0.

rho

A number in [-1,1]. Correlation between mediator (M) and outcome (Y) error terms. Non zero correlation implies a violation of sequential ignorability.

Value

A mediation analysis design.

Details

See vignette online.

Examples

Run this code
# NOT RUN {
# Generate a mediation analysis design using default arguments:
mediation_1 <- mediation_analysis_designer()
draw_estimands(mediation_1)
# }
# NOT RUN {
diagnose_design(mediation_1, sims = 1000)
# }
# NOT RUN {
# A design with a violation of sequential ignorability and heterogeneous effects:
mediation_2 <- mediation_analysis_designer(a = 1, rho = .5, c = 1, d = .75)
draw_estimands(mediation_2)
# }
# NOT RUN {
diagnose_design(mediation_2, sims = 1000)
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace