ht_2pop_prop {statBasics} | R Documentation |
Hypothesis testing for two population porportions
Description
Comparing proportions in two populations
Usage
ht_2pop_prop(
x,
y,
n_x = NULL,
n_y = NULL,
delta = 0,
alternative = "two.sided",
conf_level = NULL,
sig_level = 0.05,
na_rm = FALSE
)
Arguments
x |
a vector of 0 and 1, or a scalar of count of sucesses in the first group. |
y |
a vector of 0 and 1, or a scalar of count of sucesses in the first group. |
n_x |
a scalar of number of trials in the first group. |
n_y |
a scalar of number of trials in the second group. |
delta |
a scalar value indicating the difference in proportions ( |
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 |
Details
ht_2pop_prop
can be used for testing the null hipothesis that proportions (probabilities of success) in two groups are the same.
If is.null(n_x) == T
and is.null(n_y) == T
, then x
and y
must be a numeric value of 0 and 1 and the proportions are computed using x
and y
. If is.null(n_x) == F
and is.null(n_y) == F
, then x
, y
, n_x
and n_y
must be non-negative integer scalars and x <= n_x
and y <= n_y
.
Value
a tibble
with the following columns:
- statistic
the value of the test statistic.
- p_value
the p-value for the test.
- critical_value
critical value in the General Procedure for Hypothesis Testing.
- critical_region
critical region in the General Procedure for Hypothesis Testing.
- delta
a scalar value indicating the value of
delta
.- alternative
character string giving the direction of the alternative hypothesis.
- lower_ci
lower bound of the confidence interval. It is presented only if
!is.null(conf_level)
.- upper_ci
upper bound of the confidence interval. It is presented only if
!is.null(conf_level)
.
Examples
x <- 3
n_x <- 100
y <- 50
n_y <- 333
ht_2pop_prop(x, y, n_x, n_y)
x <- rbinom(100, 1, 0.75)
y <- rbinom(500, 1, 0.75)
ht_2pop_prop(x, y)