
Last chance! 50% off unlimited learning
Sale ends in
A shortcut wrapper function to get the observed test statistic for a t test.
This function has been deprecated in favor of the more general observe()
.
t_stat(
x,
formula,
response = NULL,
explanatory = NULL,
order = NULL,
alternative = "two-sided",
mu = 0,
conf_int = FALSE,
conf_level = 0.95,
...
)
A data frame that can be coerced into a tibble.
A formula with the response variable on the left and the
explanatory on the right. Alternatively, a response
and explanatory
argument can be supplied.
The variable name in x
that will serve as the response.
This is an alternative to using the formula
argument.
The variable name in x
that will serve as the
explanatory variable. This is an alternative to using the formula argument.
A string vector of specifying the order in which the levels of
the explanatory variable should be ordered for subtraction, where order = c("first", "second")
means ("first" - "second")
.
Character string giving the direction of the alternative
hypothesis. Options are "two-sided"
(default), "greater"
, or "less"
.
A numeric value giving the hypothesized null mean value for a one sample test and the hypothesized difference for a two sample test.
A logical value for whether to include the confidence
interval or not. TRUE
by default.
A numeric value between 0 and 1. Default value is 0.95.
Pass in arguments to infer functions.
Other wrapper functions:
chisq_stat()
,
chisq_test()
,
observe()
,
prop_test()
,
t_test()
Other functions for calculating observed statistics:
chisq_stat()
,
observe()
library(tidyr)
# t test statistic for true mean number of hours worked
# per week of 40
gss %>%
t_stat(response = hours, mu = 40)
# t test statistic for number of hours worked per week
# by college degree status
gss %>%
tidyr::drop_na(college) %>%
t_stat(formula = hours ~ college,
order = c("degree", "no degree"),
alternative = "two-sided")
Run the code above in your browser using DataLab