Beginning R: An Introduction to Statistical Programming by Larry Pace

Beginning R: An Introduction to Statistical Programming by Larry Pace

Author:Larry Pace [Pace, Larry]
Language: eng
Format: epub, pdf
Tags: Computers, Statistics, Mathematical & Statistical Software, Business & Economics
ISBN: 9781430245544
Publisher: Apress
Published: 2012-10-17T04:00:00+00:00


Figure 10-1. Comparing F distributions with different degrees of freedom

Using the F Distribution to Test Variances

Because it is formed from the ratio of two variances, the F distribution can be used to test hypotheses about variances. In theoretical statistics books, students learn that the F and chi-square distributions have a mathematical connection, so it makes some sense that we develop confidence intervals for variances using the chi-square distribution and hypothesis tests about variances using the F distribution. In Chapter 9, you saw the use of the var.test function to compare two variances. Recall that the output of the var.test function is an F ratio.

Here is the result of the var.test function used to assess equality of variance from Chapter 9.

> var.test(PostTest ∼ Class)

F test to compare two variances

data: PostTest by Class

F = 0.3046, num df = 20, denom df = 15, p-value = 0.01435

alternative hypothesis: true ratio of variances is not equal to 1

95 percent confidence interval:

0.1105144 0.7836799

sample estimates:

ratio of variances

0.3045669

Note the F ratio is less than 1 because the smaller variance was divided by the larger one. Such an F ratio is perfectly legitimate, but many students and researchers are thrown off by a “left-tailed” probability value in the F distribution. An easy way to avoid this is simply to divide the larger variance by the smaller one to make F at least 1 and the p value a “right-tailed” one. Recall that the variances for the two classes were 77.46 and 254.34, respectively:

> tapply(PostTest, Groups, var)

1 2

77.46362 254.34028

Let us divide the larger variance by the smaller one to get an F ratio greater than one: 254.34028 / 77.46362 = 3.283351. We can also simply find the reciprocal of the F ratio reported by the var.test function:

> 1/.3045669

[1] 3.283351

The p value will be the same whether we divide the larger or the smaller variance by the other. Note that this is a two-tailed probability because the alternative hypothesis is that the variances are unequal. Thus, we would double the one-tailed p value reported by R when we use the pf() function to determine the p value. See the following R code:

> TwoTailedP <− 2*(1 - pf(3.283351, 15, 20))

> TwoTailedP

[1] 0.01435193

Note that we had to reverse the numerator and denominator degrees of freedom, as we are now dividing the larger variance by the smaller one. The two-tailed p value is indeed the same as that reported by R’s var.test function.

For the analysis of variance, we place 1 – α to the left of a critical value of F and α to the right of the critical value. This leads some teachers erroneously to conclude that the F test is one-tailed. The test of hypothesis is based on a ratio of two variances, and variances are based on squared deviations, as we discussed above. For that reason, a negative difference between two means and a positive difference between two means will both produce a positive squared deviation. Therefore the F ratio increases as the differences (both positive and negative) between means



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.