ht_2pop_mean | R Documentation |
Performs a hypothesis testing for the difference in means of two populations.
ht_2pop_mean(
x,
y,
delta = 0,
sd_pop_1 = NULL,
sd_pop_2 = NULL,
var_equal = FALSE,
alternative = "two.sided",
conf_level = NULL,
sig_level = 0.05,
na_rm = TRUE
)
x |
a (non-empty) numeric vector. |
y |
a (non-empty) numeric vector. |
delta |
a scalar value indicating the difference in means ( |
sd_pop_1 |
a number specifying the known standard deviation of the first population. Default value is |
sd_pop_2 |
a number specifying the known standard deviation of the second population. Default value is |
var_equal |
a logical variable indicating whether to treat the two variances as being equal. If |
alternative |
a character string specifying the alternative hypothesis, must be one of ‘"two.sided"’ (default), ‘"greater"’ or ‘"less"’. |
conf_level |
a number indicating the confidence level to compute the confidence interval. If |
sig_level |
a number indicating the significance level to use in the General Procedure for Hypothesis Testing. |
na_rm |
a logical value indicating whether |
We have wrapped the t.test
and the BSDA::z.test
in a function as explained in the book of Montgomery and Runger (2010) <ISBN: 978-1-119-74635-5>.
a tibble
with the following columns:
the value of the test statistic.
the p-value for the test.
critical value in the General Procedure for Hypothesis Testing.
critical region in the General Procedure for Hypothesis Testing.
a scalar value indicating the value of \Delta_0
.
character string giving the direction of the alternative hypothesis.
lower bound of the confidence interval. It is presented only if !is.null(conf_level)
.
upper bound of the confidence interval. It is presented only if !is.null(conf_level)
.
# t-test: var_equal == FALSE
x <- rnorm(1000, mean = 10, sd = 2)
y <- rnorm(500, mean = 5, sd = 1)
# H0: mu_1 - mu_2 == -1 versus H1: mu_1 - mu_2 != -1
ht_2pop_mean(x, y, delta = -1)
# t-test: var_equal == TRUE
x <- rnorm(1000, mean = 10, sd = 2)
y <- rnorm(500, mean = 5, sd = 2)
# H0: mu_1 - mu_2 == -1 versus H1: mu_1 - mu_2 != -1
ht_2pop_mean(x, y, delta = -1, var_equal = TRUE)
# z-test
x <- rnorm(1000, mean = 10, sd = 3)
x <- rnorm(500, mean = 5, sd = 1)
# H0: mu_1 - mu_2 >= 0 versus H1: mu_1 - mu_2 < 0
ht_2pop_mean(x, y, delta = 0, sd_pop_1 = 3, sd_pop_2 = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.