-
Notifications
You must be signed in to change notification settings - Fork 4
/
metafor_tidiers.R
85 lines (82 loc) · 2.31 KB
/
metafor_tidiers.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#' Tidying methods for meta-analysis models (via the metafor package)
#'
#' These methods include a tidy and a glance for a meta-analytic fixed- and
#' random/mixed-effects models with or without moderators via linear
#' (mixed-effects) models. See the documentation of the metafor-package
#' for more details on these models. Sourced: https://github.com/talgalili/broom/blob/master/R/metafor_tidiers.R
#'
#' @template boilerplate
#'
#' @name metafor_tidiers
#'
#' @param x model object returned by [metafor::rma()]
#' @param ... Additional arguments (not used).
#'
NULL
#' @rdname metafor_tidiers
#'
#' @return `tidy` returns a [tibble::tibble()` frame with one row for each
#' coefficient. The columns are the same as for [broom::tidy.lm()]
#'
#' @export
#' @examples
#'
#'
tidy.rma <- function(x, ...) {
with(
x,
tibble(
estimate = as.vector(b),
std.error = se,
statistic = zval,
p.value = pval,
conf.low = ci.lb,
conf.high = ci.ub
)
)
}
# tidy.rma(a)
# tidy.rma(fit_AR_3)
# tidy.rma(fit_AR_3)
#' @rdname metafor_tidiers
#'
#' @return `glance`` returns a tibble with columns:
#'
#' * tau2 - estimated amount of (residual) heterogeneity. Always 0 when method="FE".
#' * se.tau2 - estimated standard error of the estimated amount of (residual) heterogeneity.
#' * k - number of outcomes included in the model fitting.
#' * p - number of coefficients in the model (including the intercept).
#' * m - number of coefficients included in the omnibus test of coefficients.
#' * QE - test statistic for the test of (residual) heterogeneity.
#' * QEp - p-value for the test of (residual) heterogeneity.
#' * QM - test statistic for the omnibus test of coefficients.
#' * QMp - p-value for the omnibus test of coefficients.
#' * I2 - value of I^2. See print.rma.uni for more details.
#' * H2 - value of H^2. See print.rma.uni for more details.
#' * R2 - value of R^2. See print.rma.uni for more details.
#' * int.only - logical that indicates whether the model is an intercept-only model.
#'
#' @export
#' @examples
#'
#' TODO
glance.rma <- function(x, ...) {
with(
x,
tibble(
tau2 = tau2,
se.tau2 = se.tau2,
k = k,
p = p,
m = m,
QE = QE,
QEp = QEp,
QM = QM,
QMp = QMp,
I2 = I2,
H2 = H2,
# R2 = R2,
int.only = int.only
)
)
}