Use tidy_override
and tidy_replace
to provide your own p values,
confidence intervals etc. for a model.
A model with methods defined for generics::tidy()
and/or generics::glance()
.
In tidy_override
, columns of statistics to replace tidy
output. In
tidy
and glance
methods, arguments passed on to the underlying model.
A list of summary statistics for glance
.
Logical: allow adding new columns to tidy(x)
and glance(x)
?
Data frame to replace the result of tidy(x)
.
A tidy_override
object.
An object that can be passed in to huxreg
.
tidy_override
allows you to replace some columns of tidy(x)
with your own
data.
tidy_replace
allows you to replace the result of tidy(x)
entirely.
if (! requireNamespace("broom", quietly = TRUE)) {
stop("Please install 'broom' to run this example.")
}
lm1 <- lm(mpg ~ cyl, mtcars)
fixed_lm1 <- tidy_override(lm1,
p.value = c(.04, .12),
glance = list(r.squared = 0.99))
huxreg(lm1, fixed_lm1)
#> ────────────────────────────────────────────────────
#> (1) (2)
#> ───────────────────────────────────
#> (Intercept) 37.885 *** 37.885 *
#> (2.074) (2.074)
#> cyl -2.876 *** -2.876
#> (0.322) (0.322)
#> ───────────────────────────────────
#> N 32 32
#> R2 0.726 0.990
#> logLik -81.653 -81.653
#> AIC 169.306 169.306
#> ────────────────────────────────────────────────────
#> *** p < 0.001; ** p < 0.01; * p < 0.05.
#>
#> Column names: names, model1, model2
if (requireNamespace("nnet", quietly = TRUE)) {
mnl <- nnet::multinom(gear ~ mpg, mtcars)
tidied <- broom::tidy(mnl)
mnl4 <- tidy_replace(mnl, tidied[tidied$y.level == 4, ])
mnl5 <- tidy_replace(mnl, tidied[tidied$y.level == 5, ])
huxreg(mnl4, mnl5, statistics = "nobs")
}
#> # weights: 9 (4 variable)
#> initial value 35.155593
#> iter 10 value 23.131901
#> final value 23.129234
#> converged
#> ────────────────────────────────────────────────────
#> (1) (2)
#> ───────────────────────────────────
#> (Intercept) -9.502 ** -7.691 *
#> (3.262) (3.232)
#> mpg 0.475 ** 0.358 *
#> (0.168) (0.168)
#> ───────────────────────────────────
#> nobs
#> ────────────────────────────────────────────────────
#> *** p < 0.001; ** p < 0.01; * p < 0.05.
#>
#> Column names: names, model1, model2