Description Usage Arguments Details Value Author(s) Examples

Estimates a Bayesian multilevel mediation model using Stan.

1 2 |

`d` |
A |

`id` |
Column of participant IDs in |

`x` |
Column of X values in |

`m` |
Column of M values in |

`y` |
Column of Y values in |

`priors` |
A list of named values to be used as the prior scale parameters. See details. |

`binary_y` |
Set to TRUE if y is binary and should be modelled with logistic regression. Defaults to FALSE (y treated as continuous.) This feature is experimental. |

`...` |
Other optional parameters passed to |

Draw samples from the joint posterior distribution of a multilevel mediation model using Stan.

Users may pass a list of named values for the `priors`

argument.
The values will be used to define the scale parameter of the
respective prior distributions.
This list may specify some or all of the following parameters:

- dy, dm
Regression intercepts (for Y and M as outcomes, respectively.)

- a, b, cp
Regression slopes.

- tau_x
Varying effects SDs for above parameters (e.g replace x with a.)

- lkj_shape
Shape parameter for the LKJ prior.

See examples for specifying the following: Gaussian distributions with SD = 10 as priors for the intercepts, Gaussians with SD = 2 for the slopes, Half-Cauchy distributions with scale parameters 1 for the varying effects SDs, and an LKJ prior of 2.

An object of S4 class stanfit, with all its available methods.

Matti Vuorre mv2521@columbia.edu

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
## Not run:
## Run example from Bolger and Laurenceau (2013)
data(BLch9)
fit <- mlm(BLch9)
mlm_summary(fit)
### With priors
Priors <- list(dy = 10, dm = 10, a = 2, b = 2, cp = 2,
tau_dy = 1, tau_dm = 1, tau_a = 1, tau_b = 1, tau_cp = 1,
lkj_shape = 2)
fit <- mlm(BLch9, priors = Priors)
## End(Not run)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.