Closed douglas24 closed 5 years ago
This is already supported in broom
-
library(mediation)
#> Loading required package: MASS
#> Loading required package: Matrix
#> Loading required package: mvtnorm
#> Loading required package: sandwich
#> mediation: Causal Mediation Analysis
#> Version: 4.4.6
library(broom)
data(jobs)
b <- lm(job_seek ~ treat + econ_hard + sex + age, data = jobs)
c <- lm(depress2 ~ treat + job_seek + econ_hard + sex + age, data = jobs)
mod <- mediate(b, c, sims = 50, treat = "treat", mediator = "job_seek")
tidy(mod)
#> # A tibble: 4 x 4
#> term estimate std.error p.value
#> <chr> <dbl> <dbl> <dbl>
#> 1 acme_0 -0.0131 0.00943 0.12
#> 2 acme_1 -0.0131 0.00943 0.12
#> 3 ade_0 -0.0444 0.0397 0.36
#> 4 ade_1 -0.0444 0.0397 0.36
tidy(summary(mod))
#> # A tibble: 4 x 4
#> term estimate std.error p.value
#> <chr> <dbl> <dbl> <dbl>
#> 1 acme_0 -0.0131 0.00943 0.12
#> 2 acme_1 -0.0131 0.00943 0.12
#> 3 ade_0 -0.0444 0.0397 0.36
#> 4 ade_1 -0.0444 0.0397 0.36
Created on 2019-03-10 by the reprex package (v0.2.1.9000)
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
I would like to request that broom be able to work with the summary() function in the mediation package so that broom's tidy function will work with it.