get_confidence_interval: Compute confidence interval

Description Usage Arguments Value Aliases Examples

View source: R/get_confidence_interval.R

Description

Only simulation-based methods are (currently only) supported.

Usage

1
2
3
4
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Prepare the dataset
mtcars_df <- mtcars %>%
  dplyr::mutate(am = factor(am))

# Calculate the difference in means in the dataset
d_hat <- mtcars_df %>%
  specify(mpg ~ am) %>%
  calculate(stat = "diff in means", order = c("1", "0"))

# Same calculation on 100 bootstrap replicates
bootstrap_distn <- mtcars_df %>%
  specify(mpg ~ am) %>%
  generate(reps = 100, type = "bootstrap") %>%
  calculate(stat = "diff in means", order = c("1", "0"))

# Use level to set the confidence level
bootstrap_distn %>%
  get_confidence_interval(level = 0.9)

# To calculate std error, set the type and point estimate
bootstrap_distn %>%
  get_confidence_interval(type = "se", point_estimate = d_hat)

andrewpbray/infer documentation built on Aug. 29, 2019, 5:57 a.m.