Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

reg_intervals

A convenience function for confidence intervals with linear-ish parametric models


Description

A convenience function for confidence intervals with linear-ish parametric models

Usage

reg_intervals(
  formula,
  data,
  model_fn = "lm",
  type = "student-t",
  times = NULL,
  alpha = 0.05,
  filter = term != "(Intercept)",
  keep_reps = FALSE,
  ...
)

Arguments

formula

An R model formula with one outcome and at least one predictor.

data

A data frame.

model_fn

The model to fit. Allowable values are "lm", "glm", "survreg", and "coxph". The latter two require that the survival package be installed.

type

The type of bootstrap confidence interval. Values of "student-t" and "percentile" are allowed.

times

A single integer for the number of bootstrap samples. If left NULL, 1,001 are used for t-intervals and 2,001 for percentile intervals.

alpha

Level of significance.

filter

A logical expression used to remove rows from the final result, or NULL to keep all rows.

keep_reps

Should the individual parameter estimates for each bootstrap sample be retained?

...

Options to pass to the model function (such as family for glm()).

Value

A tibble with columns "term", ".lower", ".estimate", ".upper", ".alpha", and ".method". If keep_reps = TRUE, an additional list column called ".replicates" is also returned.

References

Davison, A., & Hinkley, D. (1997). Bootstrap Methods and their Application. Cambridge: Cambridge University Press. doi:10.1017/CBO9780511802843

See Also

Examples

set.seed(1)
reg_intervals(mpg ~ I(1/sqrt(disp)), data = mtcars)

set.seed(1)
reg_intervals(mpg ~ I(1/sqrt(disp)), data = mtcars, keep_reps = TRUE)

rsample

General Resampling Infrastructure

v0.1.0
MIT + file LICENSE
Authors
Julia Silge [aut, cre] (<https://orcid.org/0000-0002-3671-836X>), Fanny Chow [aut], Max Kuhn [aut], Hadley Wickham [aut], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.