Mathematics 241 The P -value October 18 Goals for the day: 1. Words: 2. R: P -value t.test 3. Big idea: the P -value measures the strength of the evidence against the null hypothesis How strong is the evidence for H1 over against H0 ? The logic of hypothesis testing is this: we assume that H0 is true and we ask whether our data is sufficient evidence to abandon that assumption in favor of believing H1 . There are a lot of misunderstandings of hypothesis testing – here are some things that we are not doing. 1. We are not trying to prove H0 is true. We assume it is true and try to find sufficient evidence that it is false. 2. We do not ask whether the evidence merely favors H1 over H0 . We ask whether it is sufficient to abandon H0 in favor of H1 . Body temperature of Calvin students Do Calvin students have the same average body temperature as that reported for all humans? H0 : H1 : µ = 98.2 µ 6= 98.2 We have a sample of n = 130 Calvin students. > xbar=mean(normtemp$Temp) > xbar [1] 98.249 Our question is this: ”Is our sample mean (98.249) so far away from 98.2 (our hypothesized mean) that we should doubt the null hypothesis?” Here are the steps in hypothesis testing. 1. Compute a test statistic that measures how far away x̄ is from the hypothesized value of H0 . We could use x̄ − 98.2 in this case but it is far better to use T = because “far away” is relative to the variation in x̄. > xbar=mean(normtemp$Temp) > s=sd(normtemp$Temp) > n=length(normtemp$Temp) > T = (xbar-98.2)/(s/sqrt(n)) > T [1] 0.76559 x̄ − 98.2 √ s/ n Page 2 2. If H0 is true, how often would you expect to see a value of T at least as far away from 0 as this value (.76559)? If H0 is true, T has a t-distribution with n − 1 = 129 degrees of freedom. > curve(dt(x,129),-3,3,ylab='',xlab='T',main='T distribution (df 139)') 0.0 0.1 0.2 0.3 0.4 T distribution (df 139) −3 −2 −1 0 1 2 3 We can see from the graph that .77 is not a surprising value of the T statistic even if H0 is true. In fact > 1-pt(T,n-1) [1] 0.22266 Even if H0 is true, 44% of the time we would get a value of T at least this far away from what is expected if H0 is true. (Why do we double the 22% that we computed?) 3. Draw a conclusion. We don’t have sufficient evidence to abandon H0 in favor of H1 . These data would not be at all surprising if H0 were true. We complete the following sentence: If H0 is true, we could expect to see a T value at least as extreme as this in 44% of all random samples of this size. Therefore we do not have enough evidence to reject H0 in favor of H1 . The t-test is the statistical test that we have just completed. The steps are automated in the R function t.test. > t.test(normtemp$Temp, mu=98.2) One Sample t-test data: normtemp$Temp t = 0.7656, df = 129, p-value = 0.4453 alternative hypothesis: true mean is not equal to 98.2 95 percent confidence interval: 98.122 98.376 sample estimates: mean of x 98.249 The numbers in this output that are important to us are the value of the T-statistic, the degrees of freedom, and the P -value. Page 3 Thickness of aircraft engine mount pads Six measurements are made of the thickness pads designed for use in aircarft engine mounts. Data are in ex6_4_6$Thickness. The target thickness is 41.2 mm. Is it plausible that these parts were made to that specification? H0 : H1 : 1. Compute the value of the T -statistic: 2. Compute the P -value: 3. Fill in the blanks: If H0 is true, we could expect to see a T -value at least as extreme as ours ( ) in % of the random samples of this size. Therefore we [ DO DO NOT ] have enough evidence to reject H0 in favor of H1 . Filling machine for candy bags A machine is supposed to fill candy bags with 16 oz of candy. A random sample of 10 bags yields data found in ex6_4_3$weight. H0 : H1 : 1. Compute the value of the T -statistic: 2. Compute the P -value: 3. Fill in the blanks: If H0 is true, we could expect to see a T -value at least as extreme as ours ( ) in % of the random samples of this size. Therefore we [ DO DO NOT ] have enough evidence to reject H0 in favor of H1 . If you want to use t.test to do this, you will need to specify that the alternate hypothesis is one sided (your’s was, wasn’t it?). To do that use the optional argument alternate=’greater’ or alternate=’less’. Page 4 Length of Baseball games Major league baseball says that the average baseball game last 2.5 hours. Having sat through many three hour games, you doubt this. You happen to have the length in minutes of all baseball games played in 2003 (there are 2430 of them). The data are in bballgames03$timemin in the M241 package. H0 : H1 : 1. Compute the value of the T -statistic: 2. Compute the P -value: 3. Fill in the blanks: If H0 is true, we could expect to see a T -value at least as extreme as ours ( ) in % of the random samples of this size. Therefore we [ DO DO NOT ] have enough evidence to reject H0 in favor of H1 . The speed of light In 1887, Michelson and Morley did their classic experiment to measure the speed of light. We now know that the speed of light is 299,792,456 m/s, exactly. Are the 100 measurements of Michelson and Morley consistent with this number? The data are in morley$speed and the number is expressed in km/s after 299,000 km/sec is substracted. Did Michelson and Morley get it right (to the level of significance that they measured?) H0 : H1 : 1. Compute the value of the T -statistic: 2. Compute the P -value: 3. Fill in the blanks: If H0 is true, we could expect to see a T -value at least as extreme as ours ( ) in % of the random samples of this size. Therefore we [ DO DO NOT ] have enough evidence to reject H0 in favor of H1 .
© Copyright 2025 Paperzz