Compute confidence interval
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 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.
A 1 x 2 tibble with 'lower_ci' and 'upper_ci' columns. Values correspond to lower and upper bounds of the confidence interval.
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 ) # 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" ) # More in-depth explanation of how to use the infer package ## Not run: vignette("infer") ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.