tidymodels / infer
Showing 1 of 2 files from the diff.

@@ -21,52 +21,46 @@
Loading
21 21
#'
22 22
#' @return A 1 x 2 tibble with 'lower_ci' and 'upper_ci' columns. Values
23 23
#'   correspond to lower and upper bounds of the confidence interval.
24 -
#`
25 -
#' @details
26 -
#'   A null hypothesis is not required to compute a confidence interval,
27 -
#'   but including `hypothesize()` in a chain leading to `get_confidence_interval()`
28 -
#'   will not break anything.  This can be useful when computing a confidence
29 -
#'   interval after previously computing a p-value.
30 24
#'
25 +
#' @details
26 +
#' A null hypothesis is not required to compute a confidence interval, but
27 +
#' including `hypothesize()` in a chain leading to `get_confidence_interval()`
28 +
#' will not break anything. This can be useful when computing a confidence
29 +
#' interval after previously computing a p-value.
31 30
#'
32 31
#' @section Aliases:
33 -
#'   `get_ci()` is an alias of `get_confidence_interval()`.
34 -
#'   `conf_int()` is a deprecated alias of `get_confidence_interval()`.
32 +
#' `get_ci()` is an alias of `get_confidence_interval()`.
33 +
#' `conf_int()` is a deprecated alias of `get_confidence_interval()`.
35 34
#'
36 35
#' @examples
37 36
#'
38 -
#' gss %>%
39 -
#'   # we're interested in the number of hours worked per week
37 +
#' boot_distr <- gss %>%
38 +
#'   # We're interested in the number of hours worked per week
40 39
#'   specify(response = hours) %>%
41 -
#'   # generate bootstrap samples
40 +
#'   # Generate bootstrap samples
42 41
#'   generate(reps = 1000, type = "bootstrap") %>%
43 -
#'   # calculate mean of each bootstrap sample
44 -
#'   calculate(stat = "mean") %>%
45 -
#'   # calculate the confidence interval around the point estimate
42 +
#'   # Calculate mean of each bootstrap sample
43 +
#'   calculate(stat = "mean")
44 +
#'
45 +
#' boot_distr %>%
46 +
#'   # Calculate the confidence interval around the point estimate
46 47
#'   get_confidence_interval(
47 -
#'     # at the 95% confidence level; percentile method
48 +
#'     # At the 95% confidence level; percentile method
48 49
#'     level = 0.95
49 50
#'   )
50 51
#'
51 -
#' # for type = "se" or type = "bias-corrected" we need a point estimate
52 +
#' # For type = "se" or type = "bias-corrected" we need a point estimate
52 53
#' sample_mean <- gss %>%
53 54
#'   specify(response = hours) %>%
54 55
#'   calculate(stat = "mean") %>%
55 56
#'   dplyr::pull()
56 57
#'
57 -
#' gss %>%
58 -
#'   # ...we're interested in the number of hours worked per week
59 -
#'   specify(response = hours) %>%
60 -
#'   # generating data points for a null distribution
61 -
#'   generate(reps = 1000, type = "bootstrap") %>%
62 -
#'   # finding the null distribution
63 -
#'   calculate(stat = "mean") %>%
64 -
#    # calculate the confidence interval around the point estimate
58 +
#' boot_distr %>%
65 59
#'   get_confidence_interval(
66 60
#'     point_estimate = sample_mean,
67 -
#'     # at the 95% confidence level
61 +
#'     # At the 95% confidence level
68 62
#'     level = 0.95,
69 -
#'     # using the standard error method
63 +
#'     # Using the standard error method
70 64
#'     type = "se"
71 65
#'   )
72 66
#'
@@ -99,7 +93,8 @@
Loading
99 93
get_ci <- function(x, level = 0.95, type = "percentile",
100 94
                   point_estimate = NULL) {
101 95
  get_confidence_interval(
102 -
    x, level = level, type = type, point_estimate = point_estimate
96 +
    x,
97 +
    level = level, type = type, point_estimate = point_estimate
103 98
  )
104 99
}
105 100
@@ -125,14 +120,14 @@
Loading
125 120
  z0 <- stats::qnorm(p)
126 121
  # z_alpha_2 is z_(alpha/2)
127 122
  z_alpha_2 <- stats::qnorm((1 + c(-level, level)) / 2)
128 -
  new_probs <- stats::pnorm(2*z0 + z_alpha_2)
123 +
  new_probs <- stats::pnorm(2 * z0 + z_alpha_2)
129 124
130 125
  ci_vec <- stats::quantile(x[["stat"]], probs = new_probs)
131 126
132 127
  make_ci_df(ci_vec)
133 128
}
134 129
135 -
check_ci_args <- function(x, level, type, point_estimate){
130 +
check_ci_args <- function(x, level, type, point_estimate) {
136 131
  if (!is.null(point_estimate)) {
137 132
    if (!is.data.frame(point_estimate)) {
138 133
      check_type(point_estimate, is.numeric)
@@ -156,7 +151,7 @@
Loading
156 151
157 152
  if ((type %in% c("se", "bias-corrected")) && is.null(point_estimate)) {
158 153
    stop_glue(
159 -
      'A numeric value needs to be given for `point_estimate` ',
154 +
      "A numeric value needs to be given for `point_estimate` ",
160 155
      'for `type` "se" or "bias-corrected".'
161 156
    )
162 157
  }
Files Coverage
R 99.84%
Project Totals (15 files) 99.84%
1
comment:
2
  layout: "reach, diff, flags, files"
3
  behavior: default
4
  require_changes: false  # if true: only post the comment if coverage changes
5
  require_base: no        # [yes :: must have a base report to post]
6
  require_head: yes       # [yes :: must have a head report to post]
7
  branches: null
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading