Archive for September, 2010
It’s A Math, Math World (Chi-Square Goodness-of-Fit Test)
In this week’s post, we will be analyzing categorical data. When dealing with categorical data, we are concerned with frequencies of each occurrence of the values of a random variable. We will be testing hypotheses of multiple proportions (more than 2 at a time). This technique we will use, called the Chi-Square Goodness of Fit Test, works for any set of proportions that add up to 1.
This test involves taking the observed frequencies (O) given in the problem and comparing these to the expected frequencies (E) which we calculate.
We are given, for example:
H0: p1 = 0.3, p2 = 0.2, p3 = 0.5; where 0.3 + 0.2 + 0.5 = 1
There are a total of n onbservartions so the expected frequencies are:
0.3 x n, 0.2 x n and 0.5 x n
If the observed frequencies differ too much from the expected frequencies, we would reject the null hypothesis.
We calculate the test statistic which is Χ^{2} = ∑ ((O-E)^{2}/E) which has the Chi-Square distribution. The properties of the Chi-Square are as follows:
- There is an infinite number of Chi-Square distributions, each one associated with a number called its degrees of freedom. We calculate df = k-1 where k is the number of categories. We use this number to specify which Chi-Square distribution we are using.
- The test statistic has a Chi-square distribution if the sample size is sufficiently large such that the expected value of each category is at least 5.
Ex. (From the textbook, General Statistics (2000), by Chase and Brown). We look at the production of electronic instruments. Four assembly lines are used to produce the same item. Each assembly line is equivalent in theory, so each should have the same rate of items produced that need servicing under warranty.
A decision was made to look at the next 100 instruments returned as defective and see how many came from each plant.
The observed values of returned instruments for plants 1 through 4 are respectively: 53,18,14,15.
Plant 1 operates two shifts per day, while the other 3 plants operate 1 shift per day each.
Carry out the test of equivalence of the assembly lines at 10% level of significance.
Hypothesis:
H0: p1 = 2/5 = 0.4, p2=p3=p4=1/5 = 0.2 (Because plant 1 operates 2 of the 5 shifts while the remaining plants each operate a single shift of the five)
Ha: H0 not true
We have to compare the observed frequencies (O) against the expected frequencies (E) using the Chi-Square Goodness of Fit Test:
Expected Frequencies
Assembly Line | P | NP = E |
1 | 0.4 | (100)(0.4) = 40 |
2 | 0.2 | (100)(0.2) = 20 |
3 | 0.2 | (100)(0.2) = 20 |
4 | 0.2 | (100)(0.2) = 20 |
Calculation of Test Statistic
Assembly Line | O | E | (O-E) | (O-E)^{2} | (O-E)^{2}/E |
1 | 53 | 40 | 13 | 169 | 4.225 |
2 | 18 | 20 | -2 | 4 | 0.200 |
3 | 14 | 20 | -6 | 36 | 1.800 |
4 | 15 | 20 | -5 | 25 | 1.250 |
χ^{2} = ∑ ((O-E)^{2}/E) = 7.457, df = k-1 = 4-1= 3 where k= number of groups. This value, χ^{2}, is the test statistic.
When df=3, χ^{2}(0.10) = 6.251 which we get from a Chi-Squared table or any software package. This is the critical value.
Since test statistic = 7.457 > 6.251 = critical value, we reject the null hypothesis, in a right tailed test, and conclude that the assembly lines are not equivalent.
NOTE: I will be taking the next few weeks off for vacation. I will be returning with my next blog post on Monday, October 18^{th}.
Like what you read? Get blogs delivered right to your inbox as I post them so you can start standing out in your job and career. There is not a better way to learn or review college level stats topics than by reading, It’s A Math, Math World
It’s A Math, Math World (ANOVA Part 2)
Email Marketing You Can Trust
It’s A Math, Math World (ANOVA Part1)
In previous weeks, we learned how to test a single hypothesis of the difference between two population means: i.e., test whether two means u1 and u2 are equal. What if we have more than two populations are we want to see if the means are equal? We want to compare more than 2 population means at the same time. This process is called Analysis of Variance (ANOVA).
Note we could conduct multiple pair-wise tests of the equality of means, but this would multiply the error rate considerably. In the ANOVA case, we test the following hypothesis:
H_{0}: u_{1} = u_{2} = u_{3} = … = u_{k}
H_{A}: not all the means are equal
The methodology is as follows (we are assuming EQUAL sample sizes in this example).This example is from the textbook General Statistics (2000) by Chase and Bown:
A large chemical company uses 4 manufacturing plants to produce the same fertilizer. The plants were built to be equivalent, so the mean output of fertilizer from each plant should be the same and have the same variability. We want to test that the weekly mean output (tons of fertilizer produced) is the same for each plant. This will of course vary week to week, but we are interested in the true mean weekly production for a plant.
H_{0}: u_{1} = u_{2} = u_{3} = u_{4}
H_{a}: Not all means are equal (at least one is different)
Weekly Production Figures for 5 weeks for 4 Fertilizer Plants (weekly production is in tons)
PLANT 1 | PLANT 2 | PLANT 3 | PLANT 4 | |
574 | 546 | 580 | 585 | |
578 | 556 | 570 | 582 | |
573 | 549 | 577 | 581 | |
568 | 551 | 575 | 589 | |
572 | 553 | 573 | 588 | |
Sample mean | 573 | 551 | 575 | 585 |
Sample variance | 13 | 14.5 | 14.5 | 12.5 |
If the sample means are clustered close together, this would tend to support H0.
A great degree of variability among the sample- means would suggest that not all of the population means are equal, thus supporting H_{A}.
The key to testing for equality of several population means is to look at the variability between the sample means. A large amount of variability would suggest that not all of the population means are equal. Therefore, we would reject H_{0} in favor of H_{A}, otherwise we would not reject H0.
“Large” is a relative term and this variability must be measured in terms of something. We will define large as being the condition that the variability between the sample- means is large in relation to the variability within the samples. When this is the case, we reject H_{0} and conclude that the population means are not all the same.
First we assume that the population variance, σ^{2}, is the same for all the plants, whether the means are equal or not. From our sample data, we will calculate 2 estimates:
- The within-sample estimate of σ^{2}
- The between sample estimate of σ^{2}
Estimate #1: Within-Sample Estimate
We pool the estimates the estimates of the sample variances by averaging them:
Estimate 1 = (13+14.5+14.5+12.5)/4 = 13.625
Estimate #2: Between-Sample Estimate
Let us assume for the moment that H0 is true, and then we can view the samples of production figures as 4 samples of size 5 from the same population. The 4 sample means are values of the random variable x_bar. By the Central Limit Theorem, we know that the standard deviation of x_bar is:
σ_{x_bar }= sqrt (σ^{2}/m) or σ2 = m x (σ_{x_bar})^{2}
We use the sample variance of the 4 values of x_bar which I will call s^{2}x_bar as an estimate of this variance we have to find.
We first need to find the grand mean of the 4 sample means which is = (573 + 571 + 575 + 585)/4
= 571
We calculate the sample variance s^{2}x_bar as follows:
Sample Mean | Sample mean – grand mean | (Sample mean – grand mean)^{2} |
573 | 0 | 0 |
551 | -2 | 4 |
575 | 2 | 4 |
585 | 0 | 0 |
Grand mean = 571 | 8 = SUM |
S2x_bar = SUM/(4-1) = 8/3
Estimate 2 = m x (s2x_bar) = 5 x (8/3) = 13.333
We combine the estimates as follows:
F-stat = (Estimate #1)/ (Estimate #2) = 13.625/13.333 = 1.021
The statistic, F-stat, follows an F distribution with df1= k-1 and df2 = n-k degrees of freedom where:
n= # of data values in all the samples.
k = # of populations
We express the degrees of freedom as an ordered pair df = (k-1, n-k)
In our example F-stat = 1.021 and compare it to the F distribution at α=0.05 and df = (3, 16)
Our critical value is 3.24 (from the F distribution tables), since F-stat < critical value, we fail to reject the H0 and we conclude that there is no difference between the mean output of the 4 plants.
Like what you read? Get blogs delivered right to your inbox as I post them so you can start standing out in your job and career. There is not a better way to learn or review college level stats topics than by reading, It’s A Math, Math World