7. Hypothesis Testing Flashcards
Hypothesis test: z test
Z(obs) = x̅-μ0 / σ/sqrt(n)
p-value = 2(1 - Φ|Zobs| )
Hypothesis test: t test
Use this when variance is unknown.
t(obs) = x̅-μ0 / s/sqrt(n)
p-value = 2(1 - Φ|Zobs| )
R code for hypothesis test using standard normal distribution.
pnorm( z(obs), 0, 1)
R code for hypothesis test using t distribution.
pt( t(obs), n-1)
Type 1 error
Reject H0 when it is true.
p(type 1 error) = α
where α is the significance level being tested.
Type 2 error
Accept H0 when it is false.
p(type 2 test) = 1 - power
What is the power of a hypothesis test?
power = 1 - p(type 2 error)
= Φ(-Zcrit - (μ-μ0)/ σ/sqrt(n) ) +1 - Φ(Zcrit - (μ-μ0)/ σ/sqrt(n) )
Testing with a fixed significance level, α. When do we reject H0?
We reject H0 if
|Z(obs)| > Φ^-1( 1 - α/2)
Two sample hypothesis tests when the samples are dependent.
Define a new random variable: Di = Xi - Yi. Then Di and Dj are independent.
(d-bar) = (x-bar) - (y-bar).
Then continue with t as normal.
Two sample hypothesis tests when the samples are independent and variance is unknown.
We can work with the raw data. We compare:
T = (Xbar - Ybar) - μ0 / sqrt( Sx^2/nx + Sy^2/ny)
with the T distribution it would have if H0 were true.
Two sample confidence interval for μ when the samples are independent and variance is unknown.
(xbar - ybar) +- T(v, 1-α/2) sqrt(S x^2/nx + Sy^2/ny)
Plus four / Wilson confidence interval for a proportion.
Replace p^=x/n with p~=(x+2) / (n+4)