• Purpose of Statistics Package Exercises : The Probability & Statistics course focuses on the processes you use to convert data into useful information. This involves

1. Collecting data,

2. Summarizing data, and

3. Interpreting data.

• In addition to being able to apply these processes, you can learn how to use statistical software packages to help manage, summarize, and interpret data. The statistics package exercises included throughout the course provide you the opportunity to explore a dataset and answer questions based on the output using R, Statcrunch, TI Calculator, Minitab, or Excel. In each exercise, you can choose to view instructions for completing the activity in R, Statcrunch, TI Calculator, Minitab, or Excel, depending on which statistics package you choose to use.

• The statistics package exercises are an extension of activities already embedded in the course and require you to use a statistics package to generate output and answer a different set of questions.

1. To download R, a free software environment for statistical computing and graphics, go to: https://www.r-project.org/ This link opens in a new tab and follow the instructions provided.

• Using R

1. Throughout the statistics package exercises, you will be given commands to execute in R. You can use the following steps to avoid having to type all of these commands in by hand:

2. Highlight the command with your mouse.

3. On the browser menu, click "Edit," then "Copy."

4. Click on the R command window, then at the top of the R window, click "Edit," then "Paste."

5. You may have to press to execute the command.

• R Version

1. The R instructions are current through version 3.2.5 released on April 14, 2016. Instructions in these statistics package exercises may not work with newer releases of R.

2. For help with installing R for MAC OS X or Windows click here

• The objectives of this activity are:

1. To give you guided practice in carrying out the z-test for the population proportion (p).

2. To learn how to use statistical software to help you carry out the test.

• Background: This activity is based on the results of a recent study on the safety of airplane drinking water that was conducted by the U.S. Environmental Protection Agency (EPA). A study found that out of a random sample of 316 airplanes tested, 40 had coliform bacteria in the drinking water drawn from restrooms and kitchens. As a benchmark comparison, in 2003 the EPA found that about 3.5% of the U.S. population have coliform bacteria-infected drinking water. The question of interest is whether, based on the results of this study, we can conclude that drinking water on airplanes is more contaminated than drinking water in general.

1. Explanation :
Ho: p = 0.035 Ha: p > 0.035 As usual, Ho claims that "nothing special is going on" with the drinking water in airplanes—the contamination rate is the same as the contamination rate in drinking water in general. Ha represents what we suspect, or what we want to check. In this case, we want to check whether drinking water on airplanes is more contaminated than drinking water in general.

1. Explanation :
Let's check the conditions. The sample of airplanes is random. • n * po = 316 * 0.035 = 11.06 > 10. • n * (1 - po) = 316 * .965 = 304.94 > 10. Yes, it is safe to use the test

• R Instructions

1. In R , the default command for inference for proportions,

1. 
prop.test() 

2. does not use the traditional z-test , but instead uses a related test called a chi-square (χ2) test. Therefore, to conduct the z-test for the population proportion (p) using R, we must modify the output to acquire the z-test statistic.

3. From the background , we know that there are n=316 total airplanes, x=40 contaminate samples, and the baseline comparison (null value) is p=0.035 . Here are the basic commands:

1. 
p = prop.test(x=40,n=316,p=0.035,alternative="greater",conf.level=0.95, correct=FALSE);p 

4. The parameter alternative= may take on the values "greater" , "less" , or "two.sided" depending on the alternative hypothesis.

5. Notice that X-squared can be pulled from the output by entering the command

1. 
p$statistic  6. , referred to as the chi-square2) test statistic. The χ2 test statistic is equivalent to z2, so we can determine the z-test statistic by calculating $$z = \sqrt{X^2}$$ ). 1.  z = sqrt(p$statistic);z 

7. The provided p-value is equivalent to the p-value we might find from the z-test we hand calculate for proportions.

8. Note: The χ2-test statistic will always be positive so its square root will be positive in calculation, but that does not mean that the z-test statistic is positive. If the sample proportion is greater than the null proportion then the z-test statistic is positive. If the sample proportion is less than the null proportion then the z-test statistic is negative.

1. Explanation :
A lot of information is returned; let's review it item by item. The data we entered is echoed back: we have a random sample of 316 airplanes, out of which 40 were found to have contaminated water. The null hypothesis was that the proportion of planes with contaminated water is 0.035. The chi-squared statistic for the test was 78.472, with one degree of freedom. The most important result is next: the p-value of the test was 2.2e - 16, which is essentially 0. The alternate hypothesis for our test was that the proportion of planes with contaminated water was greater than 0.035.

1. Explanation :
In our case: • n = 316 • p̂ = 40/316 ≈ .127 • po = .035 And therefore, z = 8.9 means that assuming that the Ho is true (i.e., that the proportion of contaminated drinking water on airplanes is indeed .035, the same as drinking water in general), the results of our study provided a sample proportion that is 8.9 standard deviations above that proportion. Recall that the standard deviation rule for normal distributions tells us that 99.7% of normal values fall within 3 standard deviations of the mean. A sample proportion that falls 8.9 standard deviations above the true proportion is, therefore, extremely unlikely. As you'll see, this fact will also be expressed by the p-value.

1. Explanation :
A p-value that is so close to 0 tells us that it would be almost impossible to get a sample proportion of 12.5% (or larger) of contaminated drinking water had the true proportion been 3.5%. In other words, the airline industry cannot claim that this just happened to be a "bad" sample that occurred by chance. A p-value that is essentially 0 tells us that it is highly unlikely that such a sample happened just by chance. Our conclusion is therefore that we have an extremely strong reason to reject Ho and conclude that the proportion of contaminated drinking water on airplanes is higher than the proportion in general. On a technical level, the p-value is smaller than any significance level that we are going to set, so Ho can be rejected. Comment: In the original study, there were 158 randomly chosen airplanes, and in 20 of them the drinking water was found to be contaminated. As we mentioned, we based the context of this activity on these results, and we simply doubled the counts. Instead of 158 airplanes, we had 316; instead of 20 airplanes with contaminated drinking water, we had 40). We did that because technically, otherwise the conditions under which this test can be used would not have been met. Practically, the results of this study are so extreme that the fact that not all the conditions were met has no effect on the actual conclusion.

• The purpose of this activity is to give you guided practice exploring the effect of sample size on the significance of sample results, and help you get a better sense of this effect. Another important goal of this activity is to help you understand the distinction between statistical significance and practical importance.

• Background: - For this activity, we will use example 1. Here is a summary of what we have found:

• The results of this study 64 defective products out of 400—were statistically significant in the sense that they provided enough evidence to conclude that the repair indeed reduced the proportion of defective products from 0.20 (the proportion prior to the repair). Even though the results—a sample proportion of defective products of 0.16—are statistically significant, it is not clear whether the results indicate that the repair was effective enough to meet the company's needs, or, in other words, whether these results have a practical importance. If the company expected the repair to eliminate defective products almost entirely, then even though statistically, the results indicate a significant reduction in the proportion of defective products, this reduction has very little practical importance, because the repair was not effective in achieving what it was supposed to. To make sure you understand this important distinction between statistical significance and practical importance, we will push this a bit further.

• Consider the same example, but suppose that when the company examined the 400 randomly selected products, they found that 78 of them were defective (instead of 64 in the original problem):

• R Instructions

1. From the background we know that there are n=400, x=78 , and the null value is p=0.20

2. . Here are the basic commands:

1. 
p = prop.test(x=78,n=400,p=0.20,alternative="less",conf.level=0.95, correct=FALSE);p

3. To calculate z , enter the following command. (Since the sample proportion is less than p = 0.2 , we know that z will be negative, so we take the negative square root.)

1. 
z = -sqrt(p\$statistic);z

4. The provided p-value is equivalent to the p-value we might find from the z-test we hand calculate for proportions.

1. Explanation :
Based on the large p-value (0.401) we conclude that the results are not statistically significant. In other words, the data do not provide evidence to conclude that the proportion of defective products has been reduced.

• Consider now another variation on the same problem. Assume now that over a period of a month following the repair, the company randomly selected 20,000 products, and found that 3,900 of them were defective. Note that the sample proportion of defective products is the same as before, 0.195, which as we established before, does not indicate any practically important reduction in the proportion of defective products.

1. Explanation :
Even though the sample results are similar to what we got before (sample proportion of 0.195), since they are based on a much larger sample (20,000 compared to 400) now they are statistically significant (at the .05 level, since 0.039 is less than 0.05). In this case, we can therefore reject Ho and conclude that the repair reduced the proportion of defective products to below 0.20. Summary: This is perhaps an "extreme" example, yet it is effective in illustrating the important distinction between practical importance and statistical significance. A reduction of 0.005 (or .5%) in the proportion of defective products probably does not carry any practical importance, however, because of the large sample size, this reduction is statistically significant. In general, with a sufficiently large sample size you can make any result that has very little practical importance statistically significant. This suggests that when interpreting the results of a test, you should always think not only about the statistical significance of the results but also about their practical importance.