tidy() and glance() methods so a POEMED result composes with the
broom ecosystem; the generics are re-exported, so tidy(fit) and
glance(fit) work after library(POEMED) alone. For a pe_mediation()
fit, tidy() returns the per-mediator table (see pe_mediators()) and
glance() returns a one-row summary of the two tests and the total
indirect effect. For a pe_power_curve() table both return the table
itself (it is already one row per grid point).
Usage
# S3 method for class 'poemed_tbl'
tidy(x, ...)
# S3 method for class 'poemed_tbl'
glance(x, ...)
tidy(x, ...)
glance(x, ...)Value
A data.frame. For a fit, tidy() has the columns of
pe_mediators() and glance() the columns stat_hdmm, pval_hdmm,
stat_pe, pval_pe, total_indirect_effect (one column per
exposure when there are several, suffixed with the exposure's column
name or, for an unnamed X, _1, _2, ...), n_active_mediators,
and n_observations.
Examples
set.seed(113)
d <- simulate_mediation_data(n = 120, p = 40, pattern = "contrasting",
outcome = "continuous", c1 = 1)
fit <- pe_mediation(d$X, d$Y, d$M, outcome = "continuous")
#> Warning: HBIC selected lambda = 0.05, the smallest value of `lambda_grid`, for the full model and the reduced model of the benchmark test. The criterion is minimized over the grid alone, so its minimum may lie beyond that end or between the end and its neighbor. Consider extending the grid past it and using a finer partition (more values), and compare the active mediators identified and the p-values across grids.
# HBIC chose the smallest value of the default grid here, so the fit
# warned; see the lambda_grid argument of ?pe_mediation.
tidy(fit)
#> mediator t_outcome t_exposure screen_p active
#> 1 1 15.3550897 2.4315406 1.503477e-02 FALSE
#> 2 2 -6.5433631 2.4345980 1.490834e-02 FALSE
#> 3 3 6.4949016 5.1600037 2.469450e-07 TRUE
#> 4 4 -6.3345582 5.2491552 1.527983e-07 TRUE
#> 5 7 1.5766423 1.1868839 2.352734e-01 FALSE
#> 6 35 1.1860333 0.6768048 4.985298e-01 FALSE
#> 7 36 0.8702505 -1.5136989 3.841635e-01 FALSE
glance(fit)
#> stat_hdmm pval_hdmm stat_pe pval_pe total_indirect_effect
#> 1 2.658533 0.1029957 424.9162 2.076815e-94 0.1290853
#> n_active_mediators n_observations
#> 1 2 120