Stable lifecycle

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) as the other option.

point_estimate

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

Value

A 1 x 2 tibble with values corresponding to lower and upper values in 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()
#> Warning: Removed 1244 rows containing missing values.
# 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 = 10000, type = "bootstrap") %>% # finding the null distribution calculate(stat = "mean") %>% get_confidence_interval(point_estimate = point_estimate, # at the 95% confidence level level = .95, # using the standard error method type = "se")
#> Warning: Removed 1244 rows containing missing values.
#> # A tibble: 1 x 2 #> lower upper #> <dbl> <dbl> #> 1 40.1 41.4
# More in-depth explanation of how to use the infer package vignette("infer")
#> Warning: vignette ‘infer’ not found