mediation_tidiers: Tidying methods for mediation analyses involving mixed...

mediation_tidiersR Documentation

Tidying methods for mediation analyses involving mixed effects models

Description

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.

Usage

## S3 method for class 'mediate.mer'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

Arguments

x

an object of class mediate.mer, as from mediate using lmer, glmer, or nlmer models

conf.int

whether to include a confidence interval

conf.level

confidence level for CI

...

additional arguments (unused: for generic consistency)

Value

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)

See Also

mediate, tidy.mediate

Examples

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)
}

broom.mixed documentation built on Oct. 16, 2024, 1:06 a.m.