mediator {mrt} | R Documentation |
A function that conducts a simple mediation analysis and makes the figure shown in Wright and London (2009).
mediator(x, y, m, ...)
x |
The predictor variable |
y |
The response variable |
m |
The mediator |
... |
Other arguments |
The graph is the main output.
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.
Daniel B. Wright
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)