Hypothesis test

The ASTA team

Statistical inference: Hypothesis and test

Concept of hypothesis

Significance test

Null and alternative hypothesis

Test statistic

\(P\)-value

Significance level

Significance test for mean

Two-sided \(t\)-test for mean:

Example: Two-sided \(t\)-test

library(mosaic)
1 - pdist("t", q = 1.89, df = 3)

## [1] 0.07757725

One-sided \(t\)-test for mean

The book also discusses one-sided \(t\)-tests for the mean, but we will not use those in the course.

Agresti: Overview of \(t\)-test

Significance test for proportion

Approximate test

Example: Approximate test

count <- 1200 * 0.52 # number of individuals preferring tax increase
prop.test(x = count, n = 1200, correct = F)
## 
##  1-sample proportions test without continuity correction
## 
## data:  count out of 1200
## X-squared = 1.92, df = 1, p-value = 0.1659
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4917142 0.5481581
## sample estimates:
##    p 
## 0.52

Binomial (exact) test

Example: Binomial test

lower_tail <- pdist("binom", q = 13, size = 30, prob = 0.3)

1 - lower_tail
## [1] 0.04005255

Binomial test in R

Chile <- read.delim("https://asta.math.aau.dk/datasets?file=Chile.txt")
binom.test( ~ sex, data = Chile, p = 0.5, conf.level = 0.95)
## 
## 
## 
## data:  Chile$sex  [with success = F]
## number of successes = 1379, number of trials = 2700, p-value =
## 0.2727
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.4916971 0.5297610
## sample estimates:
## probability of success 
##              0.5107407
prop.test( ~ sex, data = Chile, p = 0.5, conf.level = 0.95, correct = FALSE)

(note the additional argument correct = FALSE).

Agresti: Overview of tests for mean and proportion