02/04/2024

Statistical Hypotheses

A method of statistical inference used to decide whether the data at hand sufficiently supports a particular hypothesis.

  • A hypothesis test is a statement about a population parameter of one or more populations.
  • Used to mathematically evaluate the likelihood that a statement is likely true.

Results of Hypothesis Testing

Sample data from a given population of interest must result in one of two possible conclusions:

  1. If sample data is consistent with the hypothesis, then we fail to reject the null hypothesis.
  2. If sample data is inconsistent with the hypothesis, then we reject the null hypothesis.

The Null & Alternative Hypotheses

Hypothesis tests are composed of two population statements:

  1. Null hypothesis (H0)
    • Assumed to be true unless the sample data suggests otherwise.
  2. Alternative hypothesis (H1)
    • Used to construct the test statistic.

H0: Difference in mean return between A and B is zero.
H1: Difference in mean return between A and B is greater than zero.

One & Two Sided Hypothesis Tests

A two-sided, or two-tailed, hypothesis test, will test on both sides, that is, testing whether the data from sample A is significantly greater than, and significantly less than, the data from sample B.

Visualizing The T Distribution

Hypothesis Testing in R

One-sided t-test

t.test(x, y = NULL,
       mu = 0,
       alternative = c("data1", …),
       paired = FALSE,
       var.equal = TRUE,
       conf.level = 0.99, …)
    • x, y: The samples of data to be used.
    • mu: The true mean value of the sample data.
    • alternative: The alternative hypothesis test.
    • paired: Perform a paired t-test or not.
    • var.equal: Sample variances to be equal or not.
    • conf.level: The level of confidence to be used.

Hypothesis Testing in R Continued

Example 1: Two Sample t-test

# Creates randomized sample data
data1 <- sample(x = c(10, 15, 12, 21, 6, 12, 17, 20, 19), size = 9)
data2 <- sample(x = c(14, 8, 5, 11, 19, 16, 14, 9, 17, 13), size = 9)
# Performs a Welch Two Sample t-test
t.test(x = data1, y = data2)
    Welch Two Sample t-test

data:  data1 and data2
t = 1.2997, df = 15.125, p-value = 0.2132
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -1.774421  7.329976
sample estimates:
mean of x mean of y 
 14.66667  11.88889 

Visualizing Sample Data