The χ²GOF-Test( Command

Command Summary

Performs a χ² goodness-of-fit test.

Command Syntax

χ²GOF-Test(observed,expected,df)

Menu Location

While editing a program, press:

  1. STAT to access the statistics menu.
  2. LEFT to access the tests submenu.
  3. ALPHA D to select χ²GOF-Test(.

(outside the program editor, this will select the χ²GOF-Test… interactive solver)

Calculator Compatibility

TI-84+/SE, OS 2.30 or higher

Token Size

2 bytes

The χ²GOF-Test( command performs a χ² goodness-of-fit test. Given an expected ideal distribution of a variable across several categories, and a sample from this variable, it tests the hypothesis that the variable actually fits the ideal distribution. As a special case, you could take the ideal distribution to be evenly divided across all categories. Then, the goodness-of-fit test will test the hypothesis that the variable is independent of the category.

The command takes three arguments:

  • An observed list with an element for each category: the element records the number of times this category appeared in the sample.
  • An expected list with an element for each category: the element records the frequency with which the category was expected to appear.
  • The degrees of freedom — usually taken to be one less than the number of categories.

The output is two-fold:

  • The test statistic, χ². If the null hypothesis (that the variable fits the distribution) is true, this should be close to 1.
  • The probability, p, of the observed distribution assuming the null hypothesis. If this value is low (usually, if it's lower than .05, or lower than .01) this is sufficient evidence to reject the null hypothesis, and conclude that the variable fits a different distribution.

Sample Problem

Working as a sales clerk, you're wondering if the number of customers depends on the day of week. You've taken a count of the number of customers every day for a week: 17 on Monday, 21 on Tuesday, 18 on Wednesday, 10 on Thursday, 24 on Friday, 28 on Saturday, and 24 on Sunday. Store this observed count: {17,21,18,10,24,28,24} to L1.

There were a total of sum(L1)=142 customers. So the expected number of customers on each day was 142/7. Store all the expected counts: {142/7,142/7,142/7,142/7,142/7,142/7,142/7} to L2 (as a shortcut, you can store 142/7{1,1,1,1,1,1,1}).

Since there are 7 days, there are 6 (one less) degrees of freedom. So the resulting command is χ²GOF-Test(L1,L2,6).

The output will give a χ² of 10.32394366, and a p value of 0.1116563376. This is higher than 5%, so the test is not significant on a 95 percent level. It's perfectly possible, in other words, that the number of customers is independent of the day of week.

(Note that in this case, if you suspected the number of customers to be higher on weekends, you could use a more sensitive test for only two categories: 2-SampTTest)

Advanced Uses

The χ²GOF-Test( command is only on TI-84 Plus and newer calculator models. However, it's possible to use the χ²cdf( command to simulate it on the other calculators: see the χ² Goodness-of-fit Test routine.

Formulas

The formula for calculating the test statistic is as follows (Oi is the observed count of the ith category, and Ei is the expected count):

(1)
\begin{align} \chi_{n-1}^2 = \sum_{i=1}^n \frac{(O_i-E_i)^2}{E_i} \end{align}

The p-value, then, is the probability that the χ² statistic would be this high, using the χ²cdf( command with the appropriate value for degrees of freedom.

Error Conditions

  • ERR:DIM MISMATCH is thrown if the two lists are of different length.
  • ERR:DOMAIN is thrown if they only have one element, or if df is not a positive integer.

Related Commands

See Also

.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.