21
STA248 week 9 1 Hypothesis Testing – Introduction Hypothesis: A conjecture about the distribution of some random variables. For example, a claim about the value of a parameter of the statistical model. A hypothesis can be simple or composite. A simple hypothesis completely specifies the distribution. A composite does not. There are two types of hypotheses: The null hypothesis, H 0 , is the current belief. The alternative hypothesis, H a , is your belief; it is what you want to show. We treat the hypotheses being considered as contradictory.

Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 1

Hypothesis Testing – Introduction

• Hypothesis: A conjecture about the distribution of some random variables. For example, a claim about the value of a parameter of the statistical model.

• A hypothesis can be simple or composite.

• A simple hypothesis completely specifies the distribution. A composite does not.

• There are two types of hypotheses:

The null hypothesis, H0, is the current belief. The alternative hypothesis, Ha, is your belief; it is what you want

to show.

• We treat the hypotheses being considered as contradictory.

Page 2: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 2

ExamplesEach of the following situations requires a significance test about a population mean . State the appropriate null hypothesis H0 and alternative hypothesis Ha in each case.

(a) The mean area of the several thousand apartments in a new development is advertised to be 1250 square feet. A tenant group thinks that the apartments are smaller than advertised. They hire an engineer to measure a sample of apartments to test their suspicion.

(b) Larry's car consume on average 32 miles per gallon on the highway. He now switches to a new motor oil that is advertised as increasing gas mileage. After driving 3000 highway miles with the new oil, he wants to determine if his gas mileage actually has increased.

(c) The diameter of a spindle in a small motor is supposed to be 5 millimeters. If the spindle is either too small or too large, the motor will not perform properly. The manufacturer measures the diameter in a sample of motors to determine whether the mean diameter has moved away from the target.

Page 3: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 3

Testing Process• Hypothesis testing is a proof by contradiction.• The testing process has four steps:• Step 1: Assume H0 is true. • Step 2: Use statistical theory to make a statistic (function of the

data) that includes H0. This statistic is called the test statistic. • Step 3: Find the probability that the test statistic would take a value

as extreme or more extreme than that actually observed. Think of this as: probability of getting our sample assuming H0 is true.

• Step 4: If the probability we calculated in step 3 is high it means that the sample is likely under H0 and so we have no evidence against H0. If the probability is low it means that the sample is unlikely under H0. This in turn means one of two things; either H0 is false or we are unlucky and H0 is true.

Page 4: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 4

Test Statistic• The test is based on a statistic that estimate the parameter that

appears in the hypotheses. Usually this is the same estimate we would use in a confidence interval for the parameter. When H0 is true, we expect the estimate to take a value near the parameter value specified in H0.

• Values of the estimate far from the parameter value specified by H0give evidence against H0. The alternative hypothesis determines which directions count against H0.

• A test statistic measures compatibility between the null hypothesis and the data.

• We use it for the probability calculation that we need for our test of significance

• It is a random variable with a distribution that we know.

Page 5: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 5

Example• An air freight company wishes to test whether or not the mean weight

of parcels shipped on a particular root exceeds 10 pounds. A random sample of 49 shipping orders was examined and found to have average weight of 11 pounds. Assume that the stdev. of the weights () is 2.8 pounds.

• The null and alternative hypotheses in this problem are:H0: μ = 10 ; Ha: μ > 10 .

• The test statistic for this problem is the standardized version of

• Decision: ?

X

/XZ n

Page 6: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 6

Example

• An old production process is known to have 10% rat of defective .

• A new process was established to improve the defective rat.

• Let p be the probability that an item is defective.

• The hypotheses to test here are:

• Suppose we took a sample of 200 items.

• The appropriate test statistic to use in this case is….

Page 7: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 7

Graphical Representation

• Let Sn be the set of all possible samples of size n from the population we are sampling from.

• Let C be the set of all samples for which we reject H0. It is called the critical region.

• is the set of all samples for which we fail to reject H0. It is called the acceptance region.

• Question: how to choose a rejection region?

C

Page 8: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 8

Decision Errors

• When we perform a statistical test we hope that our decision will be correct, but sometimes it will be wrong. There are two possible errors that can be made in hypothesis test.

• The error made by rejecting the null hypothesis H0 when in fact H0is true is called a type I error.

• The error made by failing to reject the null hypothesis H0 when in fact H0 is false is called a type II error.

Page 9: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 9

Size of a Test

• The probability that defines the critical region is called the size of the test and is denoted by α.

• The size of the test is also the probability of type I error.

• Example...

Page 10: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 10

Power

• The probability that a fixed size test will reject H0 when H0 is false is called the power of the test.

• Power is not about an error. A powerful test has a large probability of rejecting H0 when we should.

• Example…

Page 11: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 11

Decision Rules

• A hypothesis test is a decision made where we attach a probability of type I error and fix it to be α.

• However, for any set up there are lots of decision rules with the same size.

• The Neyman-Pearson lemma: fix α at the largest value that can be tolerated and choose the rejection region that provide the highest power.

• Typical values of α are 0.05, 0.01, 0.1. This is called the “significant level” of the test.

Page 12: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 12

Test for Mean of Normal Population σ2 is known

• Suppose X1, …, Xn is a random sample from a N(μ, σ2) distribution where σ2 is known. We are interested in testing hypotheses about μ.

• The test statistics is the standardized version of the sample mean .

• We could test three sets of hypotheses…

X

Page 13: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 13

Example• The Pfft Light Bulb Company claims that the mean life of its 2 watt

bulbs is 1300 hours. Suspecting that the claim is too high, Nalph Rader gathered a random sample of 64 bulbs and tested each. He found the average life to be 1295 hours. Test the company's claim using = 0.01. Assume = 20 hours.

Page 14: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 14

Exercise• A standard intelligence examination has been given for several years

with an average score of 80 and a standard deviation of 7. If 25 students taught with special emphasis on reading skill, obtain a mean grade of 83 on the examination, is there reason to believe that the special emphasis changes the result on the test? Use = 0.05.

Page 15: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

Notes about P-values

• P-value is the probability of getting the value of the test statistic we have observed or more extreme than it assuming H0 is correct.

• Small P-values are evidence against H0. The smaller the P-value, the stronger the evidence.

• Guideline for how small is “small”:

P-value > 0.1 provides no evidence against H0. 0.05 < P-value < 0.1 provides weak evidence against H0. 0.01 < P-value < 0.05 provides moderated evidence against H0. P-value < 0.01 provides strong evidence against H0.

STA248 week 9 15

Page 16: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

Power Calculations - Example

STA248 week 9 16

Page 17: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 17

Test for Mean of Normal Population σ2 is unknown

• Suppose X1, …, Xn is a random sample from a N(μ, σ2) distribution where σ2 is unknown, n is small and we are interested in testing hypotheses about μ.

• The test statistics is...

Page 18: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 18

Example

• In a metropolitan area, the concentration of cadmium (Cd) in leaf lettuce was measured in 6 representative gardens where sewage sludge was used as fertilizer. The following measurements (in mg/kg of dry weight) were obtained. Cd: 21 38 12 15 14 8

• Is there evidence that the mean concentration of Cd is higher than 12?

Page 19: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

R- Example

• Data from the US federally mandated maximum speed limits in 1995 were obtained. In 1996, 32 stated increased speed limits. Data on the percent change in traffic fatalities (1995-1996) in these 32 states on interstate highways were obtained.

• The parameter of interest is the, µ, the mean of % change in fatalities.

• The hypothesis of interest here are…

STA248 week 9 19

Page 20: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 20

Test for Mean of a Non-Normal Population

• Suppose X1, …, Xn are iid from some distribution with E(Xi)=μ and Var(Xi)= σ2. Further suppose that n is large and we are interested in testing hypotheses about μ.

• Since n is large the CLT applies to the sample mean and the test statistics is again the standardized version of the sample mean , that is we use the z-test.

• If the variance of the population is unknown the result of the test is approximately correct.

X

Page 21: Hypothesis Testing – Introductionfisher.utstat.toronto.edu/~hadas/STA248/Lecture notes/week9.pdf · Hypothesis Testing – Introduction • Hypothesis: A conjecture about the distribution

STA248 week 9 21

Example –Binomial Distribution

• Suppose X1,…,Xn are random sample from Bernoulli(θ) distribution.

• We are interested in testing hypotheses about θ…