The objective of this package is to perform statistical inference using an expressive statistical grammar that coheres with the tidyverse
design framework.
To install the current stable version of infer
from CRAN:
install.packages("infer")
To install the developmental version of infer
, make sure to install remotes
first:
install.packages("remotes")
remotes::install_github("andrewpbray/infer")
These examples assume that mtcars
has been overwritten so that the variables cyl
, vs
, am
, gear
, and carb
are factor
s.
mtcars <- as.data.frame(mtcars) %>%
mutate(cyl = factor(cyl),
vs = factor(vs),
am = factor(am),
gear = factor(gear),
carb = factor(carb))
Hypothesis test for a difference in proportions:
mtcars %>%
specify(am ~ vs, success = "1") %>%
hypothesize(null = "independence") %>%
generate(reps = 100, type = "permute") %>%
calculate(stat = "diff in props", order = c("1", "0"))
Confidence interval for a difference in means:
mtcars %>%
specify(mpg ~ am) %>%
generate(reps = 100, type = "bootstrap") %>%
calculate(stat = "diff in means", order = c("1", "0"))