Hypothesis Testing ST551 Lecture 8

Inference: Hypothesis Tests

Key Components

  • Hypotheses
    • Null Hypothesis
    • Alternative Hypothesis
  • Test Statistic

  • Reference Distribution (Null Distribution)
    • Rejection Region

Possible outcomes

H0 is true HA is true
Reject Null Type I error Correct decision
Fail to reject Null Correct decision Type II error

Balancing Type I and Type II error

Hypothesis tests are designed to control Type I error

The significance level, α is the probability of a Type I error: α=P(Reject H0 when H0 is true)=PH0(Reject H0)

Common choices: α=0.05, α=0.01

Power

The power, of a test is probability of correctly rejecting the null hypothesis (H0), but is a function of some actual parameter value (θ1).

Power(θ1)=P(Reject H0 when θ1 is true)=Pθ1(Reject H0)=1β(θ1) for θ1HA where β(θ1) = Probability of Type II error

Statistic

Test statistic: A statistic T(Y1,,Yn) (i.e. a function of the sample values) that is used to make the decision on whether or not to reject the null hypothesis.

We want the test statistic to capture the evidence the data provides about the hypotheses.

Null Distribution/Rejection Region

Reference Distribution (Null distribution) The distribution the test statistic will be compared to.

Usually, the distribution of the test statistic when the null hypothesis is true.

Rejection region: values of the test statistic that will result in rejecting the null hypothesis.

How do we find it? Consider values of the test statistic which are most unusual and would be more typical if the alternative were true.

Example: rejection region calculation

Ex: Would you reject H0:μ=30 in favor of HA:μ<30 if your sample of 100 OSU freshman had a sample mean hours spent preparing for class:

Y¯=31?

Y¯=25?

Y¯=29.2?

To decide we need to use the sampling distribution of the sample mean.

(We will assume, for now, that the population variance σ2=25 is known)

Critical value

The rejection region is of one of these forms:

  • Reject H0 if T>cU
  • Reject H0 if T<cL
  • Reject H0 if T>cU or T<cL

cU cL are called critical values for the test and are chosen to obtain the desired significance level (i.e. to control the Type I error rate).

Example: continued

Consider values of the test statistic which are most unusual and would be more typical if the alternative were true.

If null hypothesis were true: Y¯˙N(,)

More typical values under the alternative would be on the low side of the distribution.

Example: continued

Rejection region will be of the form: Reject H0 if T<cL

cU cL are are chosen to obtain the desired significance level.

What value of cL, gives PH0(Reject H0)=α=0.05?

qnorm(0.05, mean = 30, sd = sqrt(25/100)) = 29.18

Example: continued

Reject H0 if Y¯<29.18

Ex: Would you reject H0:μ=30 in favor of HA:μ<30 if your sample of 100 OSU freshman had a sample mean hours spent preparing for class:

Y¯=31? No

Y¯=25? Yes

Y¯=29.2? No

Z-test

If we wanted to use a Standard Normal as the reference distribution, we would standardize the sample mean by its mean and standard deviation under the null.

I.e. subtract the hypothesized mean μ0 and divide by σ2/n

Z(μ0)=Y¯μ0σ2/n

Z-test

Leads to the Z-test.

To test a hypothesis about population mean when population variance is known.

To test H0:μ=μ0

  1. Find test statistic: Z(μ0)=Y¯μ0σ2/n

  2. Compare to Standard Normal

Z-test: Critical values

  • HA:μ>μ0, reject H0 when Z(μ0)>z1α
  • HA:μ<μ0, reject H0 when Z(μ0)<zα
  • HA:μμ0 reject H0 when Z(μ0)<zα/2 or Z(μ0)>z1α/2, equivalently |Z(μ0)|>z1α/2

zα, is the value z such that P(Z<z)=α where ZN(0,1), can find with in R qnorm(alpha).

Z-test: Recap

Data Setting One sample, no explanatory variable Y1,,Yn i.i.d from population with known variance σ2

Null hypothesis H0:μ=μ0

Test statistic Z(μ0)=Y¯μ0σ2/n

Reference distribution Z(μ0)˙N(0,1)

Rejection Region

One sided HA:μ<μ0 Two sided HA:μμ0 One sided HA:μ>μ0
Z(μ0)<zα |Z(μ0)|>z1α/2 Z(μ0)>z1α

How do we know if a hypothesis test is good?

Exactness Is the actual rejection probability equal to the significance level α?

  • Finite sample exactness: For finite samples of size n is P(Reject H0)=α when null is true?
  • Asymptotic exactness: As n goes to infinity does P(Reject H0)α when null is true?

A test is finite-sample exact if reference distribution is exactly the sampling distribution for test statistic when null is true.

A test is asymptotically exact if reference distribution is the asymptotic sampling distribution for test statistic when null is true.

Your turn

Is the Z-test:

  • finite sample exact?

    When is the sampling distribution of Y¯ exactly N(μ0,σ2/n)?

    Only when population distribution is Normal, i.e YN(μ0,σ2)

  • asymptotic exact?

    When does the sampling distribution of Y¯ approach N(μ0,σ2/n) as n?

    ALWAYS! Thanks to the CLT.

How do we know if a hypothesis test is good?

Consistency

For any fixed setting where alternative is true, does the rejection probability tend to one as sample approaches infinity?

Power(θ1)p1,for any θ1HA

(If we can take an infinite sample are we guaranteed to reject null when alternative is in fact true.)

Is the Z-test consistent?

What is the power of the test? μ=μAμ0

Depends on rejection region (let’s do one sided upper):

P(Z(μ0)>z1α)=P(Y¯μ0σ2/n>z1α)=P(Y¯>z1ασ2/n+μ0)=P(Y¯μAσ2/n>z1α+μ0μAσ2/n)=P(Y¯μAσ2/n>z1αn(μAμ0)σ2)

Is the Z-test consistent?

Upper alternative μAμ0>0, as n subtracting a bigger and bigger term from critical value. So, term on right gets smaller as n gets larger.

1Φ(z1αn(μAμ0)σ2)

1Φ()=10=1

Yes, Z-test is consistent