ht_1pop_prop: Hypothesis testing for the population proportion

View source: R/ht_1pop_prop.R

ht_1pop_propR Documentation

Hypothesis testing for the population proportion

Description

One-sample test for proportion.

Usage

ht_1pop_prop(
  x,
  n = NULL,
  proportion = 0.5,
  alternative = "two.sided",
  conf_level = NULL,
  sig_level = 0.05,
  na.rm = TRUE
)

Arguments

x

a (non-empty) numeric vector indicating the number of successes. It can also be a vector with the number of successes, or it can be vector of 0 and 1.

n

a (non-empty) numeric vector indicating the number of trials. It can also be a vector with the number of trials (if x is a vector of successes), or it can be NULL (if x is a vector of 0 e 1).

proportion

a number between 0 e 1 indicating the value in the null hypothesis. Default value is 0.5.

alternative

a character string specifying the alternative hypothesis, must be one of ‘"two.sided"’ (default), ‘"greater"’ or ‘"less"’. You can specify just the initial letter.

conf_level

a number indicating the confidence level to compute the confidence interval. If conf_level = NULL, then the confidence interval is not included in the output. Default value is NULL.

sig_level

a number indicating the significance level to use in the General Procedure for Hypotheiss Testing.

na.rm

a logical value indicating whether NA values should be removed before the computation proceeds.

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.

proportion

a number indicating the true value of the proportion.

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(con_level).

upper_ci

upper bound of the confidence interval. It is presented only if !is.null(con_level).

Examples

sample <- rbinom(1, size = 100, prob = 0.75)
ht_1pop_prop(sample, proportion = 0.75, 100, conf_level = 0.99)

sample <- c(rbinom(1, size = 10, prob = 0.75),
rbinom(1, size = 20, prob = 0.75),
rbinom(1, size = 30, prob = 0.75))
ht_1pop_prop(sample, c(10, 20, 30), proportion = 0.99, conf_level = 0.90, alternative = 'less')

sample <- rbinom(100, 1, prob = 0.75)
ht_1pop_prop(sample, proportion = 0.01, conf_level = 0.95, alternative = 'greater')

statBasics documentation built on June 29, 2024, 1:07 a.m.