format_ci | R Documentation |
Round and format confidence intervals for presentation.
format_ci(
point,
lower,
upper,
null_value = NA_real_,
digits = NA_real_,
max_its = 4,
unacceptables = NA_real_
)
point, lower, upper |
Point estimates, lower bounds, and upper bounds. |
null_value |
A vector of null values to be compared to. |
digits |
A vector of digits to begin rounding at. |
max_its |
The maximum number of additiona digits to give |
The goal of this function is to round confidence intervals
for presentation. You can supply digits to round to or let the function guess.
It will try to improve the CI until it hits the max_its
. The function
attempts to have the point estimate and each end of the CI as different numbers.
If you supply a null_value
it will try not to use that as either endpoint
and keep the null value on the same side of the CI as the unformatted value is.
If unacceptables
is supplied, these values will not be allowed as
endpoints for the CI.
Sven Halvorson
# Set up a dataset for a logistic regression model:
df = nycflights13::flights %>%
mutate(on_time = dep_delay <= 0)
analysis_table = glm(
formula = on_time ~ month + sched_dep_time + origin + air_time,
data = df,
family = binomial
) %>%
broom::tidy(
conf.int = TRUE,
exponentiate = TRUE
)
cis = format_ci(
point = analysis_table['estimate'],
lower = analysis_table['conf.low'],
upper = analysis_table['conf.high'],
null_value = 1,
unacceptables = 0
)
analysis_table %>%
select(
term,
estimate,
conf.low,
conf.high
) %>%
bind_cols(cis)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.