View source: R/ci_location_shift.R
ci_mean_diff | R Documentation |
This function calculates CIs for the population value of mean(x) - mean(y). The default is Student's method with Welch's correction for unequal variances, but also bootstrap CIs are available.
ci_mean_diff(
x,
y,
probs = c(0.025, 0.975),
var.equal = FALSE,
type = c("t", "bootstrap"),
boot_type = c("stud", "bca", "perc", "norm", "basic"),
R = 9999L,
seed = NULL,
...
)
x |
A numeric vector. |
y |
A numeric vector. |
probs |
Lower and upper probabilities, by default |
var.equal |
Should the two variances be treated as being equal?
The default is |
type |
Type of CI. One of "t" (default), or "bootstrap". |
boot_type |
Type of bootstrap CI. Only used for |
R |
The number of bootstrap resamples. Only used for |
seed |
An integer random seed. Only used for |
... |
Further arguments passed to |
The default bootstrap type is "stud" (bootstrap t) as it has a stable variance
estimator (see Efron, p. 188). Resampling is done within sample.
When boot_type = "stud"
, the standard error is estimated by Welch's method
if var.equal = FALSE
(the default), and by pooling otherwise.
Thus, var.equal
not only has an effect for the classic Student approach
(type = "t"
) but also for boot_type = "stud"
.
An object of class "cint", see ci_mean()
for details.
Efron, B. and Tibshirani R. J. (1994). An Introduction to the Bootstrap. Chapman & Hall/CRC.
x <- 10:30
y <- 1:30
ci_mean_diff(x, y)
t.test(x, y)$conf.int
ci_mean_diff(x, y, type = "bootstrap", R = 999) # Use larger R
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.