Compute a confidence interval around a summary statistic. Currently, only simulation-based methods are supported.

Learn more in `vignette("infer")`

.

get_confidence_interval( x, level = 0.95, type = "percentile", point_estimate = NULL ) get_ci(x, level = 0.95, type = "percentile", point_estimate = NULL)

x | Data frame of calculated statistics or containing attributes of
theoretical distribution values. Currently, dependent on statistics being
stored in |
---|---|

level | A numerical value between 0 and 1 giving the confidence level. Default value is 0.95. |

type | A string giving which method should be used for creating the
confidence interval. The default is |

point_estimate | A numeric value or a 1x1 data frame set to |

A 1 x 2 tibble with 'lower_ci' and 'upper_ci' columns. Values correspond to lower and upper bounds of the confidence interval.

A null hypothesis is not required to compute a confidence interval, but
including `hypothesize()`

in a chain leading to `get_confidence_interval()`

will not break anything. This can be useful when computing a confidence
interval after previously computing a p-value.

`get_ci()`

is an alias of `get_confidence_interval()`

.
`conf_int()`

is a deprecated alias of `get_confidence_interval()`

.

boot_distr <- gss %>% # We're interested in the number of hours worked per week specify(response = hours) %>% # Generate bootstrap samples generate(reps = 1000, type = "bootstrap") %>% # Calculate mean of each bootstrap sample calculate(stat = "mean") boot_distr %>% # Calculate the confidence interval around the point estimate get_confidence_interval( # At the 95% confidence level; percentile method level = 0.95 )#> # A tibble: 1 x 2 #> lower_ci upper_ci #> <dbl> <dbl> #> 1 40.1 42.7# For type = "se" or type = "bias-corrected" we need a point estimate sample_mean <- gss %>% specify(response = hours) %>% calculate(stat = "mean") %>% dplyr::pull() boot_distr %>% get_confidence_interval( point_estimate = sample_mean, # At the 95% confidence level level = 0.95, # Using the standard error method type = "se" )#> # A tibble: 1 x 2 #> lower_ci upper_ci #> <dbl> <dbl> #> 1 40.1 42.7