mediation_tidiers | R Documentation |
These methods tidy the coefficients of mediation::mediate
output
(i.e., mediate.mer
objects) when lme4::lmer
and
lme4::glmer
models (i.e., merMod
objects) provide the input.
## S3 method for class 'mediate.mer'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
an object of class |
conf.int |
whether to include a confidence interval |
conf.level |
confidence level for CI |
... |
additional arguments (unused: for generic consistency) |
All tidying methods return a data.frame
without rownames. The
structure depends on the method chosen.
tidy
returns one row for each estimated effect:
first the mediated effect in the control and treatment groups, respectively,
then the direct effect in each group.
It contains the columns
term |
term being estimated |
estimate |
estimated coefficient |
std.error |
standard error |
p.value |
P-value computed from t-statistic (may be missing/NA) |
mediate
, tidy.mediate
if (require("lme4") && require("mediation")) {
## Borrowed from \code{help(mediation::mediate)}:
## Not run:
## Varying intercept for mediator
mod_m <- glmer(job_dich ~ treat + econ_hard + (1 | educ),
family = binomial(link = "probit"), data = jobs)
## Varying intercept and slope for outcome
mod_y <- glmer(work1 ~ treat + job_dich + econ_hard + (1 + treat | occp),
family = binomial(link = "probit"), data = jobs)
## Output based on mediator group ("educ")
mod_med <- mediate(mod_m, mod_y, treat = "treat",
mediator = "job_dich", sims=50, group.out="educ")
## End(Not run)
## Load stored objects
load(system.file("extdata", "mediation_example.rda", package="broom.mixed"))
## Tidy outputs
tidy(mod_m)
tidy(mod_y)
tidy(mod_med)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.