Compute a confidence interval around a summary statistic. Only simulation-based methods are (currently only) 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)

Arguments

x

Data frame of calculated statistics or containing attributes of theoretical distribution values. Currently, dependent on statistics being stored in stat column as created in calculate() function.

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 "percentile" with "se" corresponding to (multiplier * standard error) and "bias-corrected" for bias-corrected interval as other options.

point_estimate

A numeric value or a 1x1 data frame set to NULL by default. Needed to be provided if type is "se" or "bias-corrected".

Value

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

Aliases

get_ci() is an alias of get_confidence_interval(). conf_int() is a deprecated alias of get_confidence_interval().

Examples

# find the point estimate---mean number of hours worked per week point_estimate <- gss %>% specify(response = hours) %>% calculate(stat = "mean") %>% dplyr::pull() # starting with the gss dataset gss %>% # ...we're interested in the number of hours worked per week specify(response = hours) %>% # hypothesizing that the mean is 40 hypothesize(null = "point", mu = 40) %>% # generating data points for a null distribution generate(reps = 1000, type = "bootstrap") %>% # finding the null distribution calculate(stat = "mean") %>% get_confidence_interval( point_estimate = point_estimate, # 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
# More in-depth explanation of how to use the infer package if (FALSE) { vignette("infer") }