mediator {mrt}R Documentation

Simple mediator analysis and graph

Description

A function that conducts a simple mediation analysis and makes the figure shown in Wright and London (2009).

Usage

mediator(x, y, m, ...)

Arguments

x The predictor variable
y The response variable
m The mediator
... Other arguments

Value

The graph is the main output.

Note

There are other mediation packages. This was shown in Wright and London to illustrate how to make a function. It does not do anything particularly novel or clever.

Author(s)

Daniel B. Wright

Examples

set.seed(143)
leaflet <- rep(c(0,1),each=50)
fairskin <- rbinom(100,1,.5)
likely <- rbinom(100,10,.20 + .2*leaflet + .2*fairskin)
plan <- rbinom(100,7,likely/15+leaflet*.2)
mediator(leaflet,plan,likely)

[Package mrt version 0.3 Index]