ht_1pop_mean: Hypothesis testing for the mean (normal distribution)

View source: R/ht_1pop_mean.R

ht_1pop_meanR Documentation

Hypothesis testing for the mean (normal distribution)

Description

Hypothesis testing for the mean (normal distribution)

Usage

ht_1pop_mean(
  x,
  mu = 0,
  sd_pop = NULL,
  alternative = "two.sided",
  conf_level = NULL,
  sig_level = 0.05,
  na.rm = TRUE
)

Arguments

x

a (non-empty) numeric vector.

mu

a number indicating the true value of the mean. Default value is 0.

sd_pop

a number specifying the known standard deviation of the population. If sd_pop == NULL, we use the t-ttest. If !is.null(sd_pop), we use the z-test. Default value is NULL.

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 Hypothesis Testing.

na.rm

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

Details

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>.

Value

a tibble with the following columns:

statistic

the value of the test statistic.

p_value

the p-value of the test.

critical_value

critical value in the General Procedure for Hypothesis Testing.

critical_region

critical region in the General Procedure for Hypothesis Testing.

mu

a number indicating the true value of the mean.

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 <- rnorm(1000, mean = 10, sd = 2) #t-test
ht_1pop_mean(sample, mu = -1) # H0: mu == -1

sample <- rnorm(1000, mean = 5, sd = 3) # z-test
ht_1pop_mean(sample, mu = 0, sd_pop = 3, alternative = 'less') # H0: mu >= 0

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