TC3 → Stan Brown → TI-83/84/89 → MATH200 Utilities
Revised 14 Oct 2013 (What’s New?)

MATH200A Program —
Statistics Utilities for TI-83/84

Copyright © 2008–2014 by Stan Brown, Oak Road Systems

Summary: This page presents a downloadable TI-83/84 program with easier versions of some calculator procedures plus new capabilities like Determining Necessary Sample Size. See Using the Program below for a full list of features.

Stan Brown’s MATH200 classes will use this program, but any statistics student should find it helpful.

Contents:

See also: Troubles? See TI-83/84 Troubleshooting.

See also: Advanced students might also want to download the program described in MATH200B Program — Extra Statistics Utilities for TI-83/84.

MATH200A Program Overview

Getting the Program

There are three methods to get the programs into your calculator:

Using the Program

MATH200A splash screen MATH200A program menu

Press the [PRGM] key. If you can see MATH200A in the menu, press its number; otherwise, scroll to it and press [ENTER]. When the program name appears on your home screen, press [ENTER] to run it. Check to make sure you have the latest version, as shown on the splash screen, then press [ENTER].

The menu at right shows what the program can do:

  1. Histograms etc: make a histogram or polygon, or overlay both, for a frequency distribution, a relative frequency distribution, a simple list of numbers, a binomial probability distribution, or a generic discrete probability distribution.
  2. Box-whisker: plot a box-whisker diagram, showing any outliers
  3. Binomial prob: compute probability or cumulative probability of a binomial distribution
  4. Normality chk: test whether your sample is drawn from a normal distribution
  5. Sample size: find the necessary sample size for a given confidence level and margin of error for binomial data (one or two populations) or numeric data (with population standard deviation σ known or unknown)
  6. GoF test: test goodness of fit for categorical data in one population
  7. Two-way table: test independence or homogeneity for categorical data in a two-way table

When running the program, be careful to select EXEC, not EDIT, on the screen: you don’t want to change the code accidentally. To look at the program source code, see MATH200A.PDF and MATH200Z.PDF in the downloadable MATH200A.ZIP file.

If you ever need to break out of the program before finishing the prompts, press [ON] [1].

Each procedure leaves its results in variables in case you want to use them for further computations. For details, please see the separate document MATH200A Program — Technical Notes.

Summary:

Making a histogram or frequency polygon using native TI-83/84 commands is kind of tedious, especially setting up the WINDOW screen. This part of the MATH200A program automates the process. The program can create a histogram or polygon, or both in overlay, for these distributions:

To use the program, put the class midpoints or ungrouped data in a statistics list and the frequencies (if applicable) in another. (Some people use the term class marks instead of class midpoints; they mean the same thing.)

Then press [PRGM], select MATH200A, and press 1:Histograms etc. The program will prompt you for the necessary information and will check silently to make sure your inputs are in valid form. Then it will ask whether you want a histogram, polygon, or both, and will produce your desired graph. (The program uses an algorithm to ensure that there are an appropriate number of dots vertically on the screen.)

Restrictions: If you have frequency data, the data list and frequency list must be the same length and the class widths in the data list must all be the same; the program checks this. The TI-83 and TI-84 won’t let you make a histogram with more than 47 classes, and the program also checks this. Finally, the program also won’t let you make a grouped frequency histogram with just one or two classes, because that’s silly.

Class
Boundaries
Class
Midpoints
Frequency
20 ≤ x < 302534
30 ≤ x < 403558
40 ≤ x < 504576
50 ≤ x < 6055187
60 ≤ x < 7065254
70 ≤ x < 8075241
80 ≤ x < 9085147

The grouped frequency distribution at right shows the ages reported by Roman Catholic nuns, from Johnson & Kuby, Elementary Statistics 9/e (Thomson, 2004), page 67. Show the data as a histogram and as a frequency polygon.

TI-83/84 data entry screen Solution: Your class marks (class midpoints) are 25, 35, up through 85, and your class width is 10. On the STAT EDIT screen, enter those class midpoints in one list and the frequencies in another. Here the class midpoints have been entered in L5 and the frequencies in L6.

TI-83/84 program run screen (2 of 3) TI-83/84 program run screen (1 of 3) Run the MATH200A program and select 1:Histograms etc. On the Data Arrangement screen, select [3] for grouped frequency distribution. Specify your list of class midpoints (class marks) and your frequency list.

TI-83/84 program run screen (3 of 3) Next, select which plots you want. In the illustration, I’m selecting both plots. If you’re not doing frequency polygons in your class, select [1] for just the histogram.

program output screen, frequency histogram only program output screen, frequency polygon overlaid on histogram The output is shown at right, once with the histogram and polygon on the same screen, and once with just the histogram.

polygon and histogram, tracing P1 (plot 1) You can trace the histogram by pressing [TRACE]. This lets you see the class boundaries and number of data points in each class.

Press [] and [] to move through the classes. To suppress the tracing information, press [GRAPH] again.

polygon and histogram, tracing P2 (plot 2) To trace the polygon, if you selected both, press [TRACE] []. This lets you see the class midpoints and number of data points in each class, instead of the class boundaries.

Why press []? When you press [TRACE], the calculator starts with a trace of Stat Plot 1. The up or down cursor key moves between plots. Since the frequency polygon is Stat Plot 2, you are tracing it when you see P2 in the upper left corner, as shown in the illustration.

 11 15 14 12
 9 5
 6 11 10 10.5
 12 11 13 2
 6 13.5

Suppose you want to make a histogram of the class performance on a 15-point quiz, where the scores are shown at left. You don’t want to bother to group these 19 scores by hand, so you enter them in a statistics list such as L1 and let the program do the grouping for you. (An alternative graphical display is the box-whisker plot.)

TI-83/84 program run screen (1 of 2) Run the MATH200A program and select 1:Histograms etc. When the program asks your data arrangement, select [1] for a plain list of numbers.

TI-83/84 program run screen (2 of 2) Then enter the name of the list that contains your numbers. For a plain list of numbers, the program needs to know how you want to group your data, so it asks you to specify the lower bound of the first class as well as the class width. Since 0 is the lowest possible grade, that’s the obvious lower bound for this example. The quiz has a possible maximum score of 15, and 10% of that is 1.5 points. This is a good class width because grades of D, C, B, and A will each be one bar of the histogram.

What if you’re not sure which class width to use? Try several class widths, one at a time, and see what the histograms look like. You can pick the class width that seems to display the shape of the data most clearly.

TI-83/84 output histogram At this point you may see a pause as the program computes the number of classes and places each data point into a class. (It uses statistics lists LD for the class midpoints (class midpoints) and LF for the computed frequencies.)

For a simple list of numbers, the program will make only a histogram, not a frequency polygon.

histogram, tracing P1 (plot 1), showing 4 students in the 10.5 to 12 class histogram, tracing P1 (plot 1), showing 1 student in the 15 to 16.5 class In first looking at that histogram, you might think there are four Ds, three Cs, two Bs, and one A. But when you check this by pressing [TRACE] you see that’s not correct. The highest class is the 15 to 16.5 class, since someone had a perfect score of 15. (Remember: when a value is right on a class boundary, it is always assigned to the higher class.) So the top two classes in the histogram represent As (three students), the next lower is the three Bs, the next lower (shown at right) is four Cs, the next lower is two Ds, and the rest are Fs.

Children
per
family
Freq.
09
16
210
32
42
51

You have recorded the numbers of children in 30 randomly selected families that used a community center in a given week, and you want to show a picture of the discrete distribution. There are only a few different values (numbers of children per family), so you choose an ungrouped frequency distribution.

Enter the data in two lists such as L3 and L4, run the MATH200A program, and select 1:Histograms etc. For Data Arrangement, select [2], ungrouped distribution. Enter your data list and frequency list as usual.

TI-83/84 program run screen (1 of 2)    TI-83/84 program run screen (2 of 2)

When prompted, select whether you want a histogram, a frequency polygon, or both. I’ve selected a histogram, and the results are shown below.

TI-83/84 program output histogram The vertical line in the histogram is the y axis — you can remove it, if you want, by pressing [2nd ZOOM makes FORMAT] and selecting AXES OFF. Also in the histogram, notice that the vertical rows of dots run through the center of each bar rather than along the edges. This reminds you that you should label the bars of an ungrouped frequency distribution under the centers, not the edges as you would label a grouped histogram.

If you want to trace the ungrouped frequency histogram, follow the same procedure as for tracing a grouped frequency histogram.

If you have a relative frequency distribution or probability distribution, you plot it in almost the same way as a frequency distribution. The main difference is that the relative frequencies or probabilities must add up to 1, and the program checks this for you.

(There’s a special case: the binomial probability distribution. For this, please see Histogram of a Binomial Distribution below.)

Number of
dice alike
Probability
1720/7776
25400/7776
31500/7776
4150/7776
56/7776

Here’s an example of a general discrete probability distribution, drawn from the rainy-day game Yahtzee. In Yahtzee you roll five dice and try to make various combinations. Shown at right are the probabilities for number of dice alike when you roll five standard six-sided dice. (Thanks to Paul Sperry for help with the probabilities.) You can make a histogram of this probability distribution.

Notice, by the way, that you’re more than twice as likely to roll three of a kind as to roll “none of a kind” or all five different: P(3) = 1500/7776, and P(1) = 720/7776. And you’re over seven times as likely to roll two of a kind (either two the same and three all different, or two pairs with the fifth die different): P(2) = 5400/7776. Of course, Yahtzee isn’t just about the initial roll. You get two tries to improve your combinations by re-rolling some of your dice.

TI-83/84 histogram run screen (2 of 2) TI-83/84 histogram run screen (1 of 2) As before, put the x’s (1–5 this time) in one list and the p’s in another. Run the MATH200A program and select 1:Histograms etc. The data arrangement this time is a probability distribution, so specify [4] and then enter your data list and probability list.

TI-83/84 histogram output screen The finished probability histogram is shown at right. (For a probability distribution, the program automatically makes a histogram, with no option to make a polygon.) Notice that the bar for two of a kind is much higher than any of the others.

If it wasn’t obvious from the numbers, you can see from the histogram that this distribution is skewed right. If you like, you can press the [TRACE] button and see the numerical value of the probability for each outcome. For example, P(2) = 0.6944, meaning that when you roll five dice you have almost a 70% chance of getting two of a kind.

What about two of a kind or better? This is a classic “at least” problem, and the complement is your friend. P(1) is 0.0926 and 1−P(1) = 0.9074. You have better than a 90% chance of getting at least two of a kind when rolling five dice.

A later section will show how to compute the binomial probability of a particular x or a range of x. But for an overview of a distribution, a histogram is most helpful. This part of the program creates one for you.

TI-83/84 binomial probability histogram inputs (1 of 2)
TI-83/84 binomial probability histogram inputs (2 of 2)

Example: Suppose 65% of registered voters in Dryden are Republicans. Plot the binomial probability histogram for the random variable “number of Republicans in a random sample of ten registered voters“.

Solution: Unlike the other cases, for the binomial probability histogram you don’t enter anything in statistics lists. Instead, the program will prompt you for the necessary numbers. Run the MATH200A program and select 1:Histograms etc. When the program asks your data arrangement, select 5 for a binomial probability distribution.

TI-83/84 binomial probability histogram The program will then ask for number of trials (n) and probability of success (p). You can select a histogram or polygon as usual; the histogram is shown at right.

Interpreting the histogram: The bars are each one unit wide, running from 0 to n (0 to 10, for this example), with the dots marking each integer and the y axis marking the minimum possible value of successes, 0. You can see that the most likely result for a sample of ten registered voters is seven Republicans, with six being just slightly less likely. Eight and five are next most likely, then nine and four. A sample of ten is quite unlikely to contain ten or three Republicans, and fewer than three Republicans are extremely unlikely.

To see the probabilities as numbers, trace the histogram, or use Probability of a Binomial Experiment to compute them.

 11 15 14 12
 9 5
 6 11 10 10.5
 12 11 13 2
 6 13.5

Here again is the set of quiz scores. You’ve already seen them graphed as a histogram, but a box-whisker plot is another way to get a sense of the shape of the data.

TI-83 menu for number of samples in box-whisker Enter the data in any statistics list and run the MATH200A program. Select 2:Box-whisker and you see a prompt for the number of samples. You can make a box-whisker plot of a single data set, or you can compare two or three data sets. The quiz scores are a single sample, so you choose [1].

Then the program asks whether you have a plain list of numbers or an ungrouped frequency distribution. Here you have a plain list of numbers, so you choose data arrangement [1]. Finally, the program asks you for your data list.

Caution: Never make a boxplot of a grouped frequency distribution. Only a simple list of numbers or an ungrouped frequency distribution is suitable for a box-whisker plot. If you have a grouped frequency distribution, a box-whisker plot won’t be accurate and you should be using a histogram.

TI-83 prompt for data arrangement in box-whisker       TI-83 prompt for data list in box-whisker

The box-whisker plot now appears (below left). You can see at a glance that it has no outliers, and that it’s slightly skewed left.

You can also trace the box-whisker, to see the five-number summary and the values of any outliers. Press the [TRACE] key and then use [] and [] to move left and right. In the illustration below right you can see that the median quiz score was 10.5.

TI-83 finished box-whisker plot of one sample       TI-83 finished box-whisker plot of one sample, showing the median using the TRACE key

 11 15 14 12
 9 5
 6 11 10 10.5
 12 11 13 2
 6 13.522

TI-83 box-whisker plot of one sample, with outlier What would an outlier look like on a box-whisker plot? Any outliers show up as isolated points separate from the main diagram.

For example, take the same set of data, but append a twentieth data point, 22. Now make the plot and you’ll see the result at right. The [TRACE] key and arrow keys will display the values of any outliers as well as the five-number summary.

Sullivan, Michael, Fundamentals of Statistics 3/e (Pearson Prentice Hall, 2011), page 168, shows data for two groups of rats. One group was sent into space; the control group was treated the same except for the space flight. Their red blood cell mass was measured in milliliters.

FlightControl
 8.59   6.87   7.00   6.39   7.43   9.79   9.30   8.64   7.89   8.80   7.54   7.21   6.85   8.03   8.65   7.62   7.33   7.14   8.40   8.55   9.88   6.99   7.44   8.58   9.14   9.66   8.70   9.94 

Plotting the two data sets as two boxplots on the same screen is a good way to get a sense of whether there is a difference between the samples.

(By the way, these two samples happen to be the same size, but you can just as well stack boxplots with samples of different sizes.)

setup screen 1 of 3 for stacked box-whisker plot Put the flight group in one statistics list and the control group in another. Then run the MATH200A program, select 2:Box-whisker, and select 2:Compare 2 smpl.

For each sample you’ll be asked your data arrangement. (That lets one sample be a plain list and the other an ungrouped frequency distribution, but in this example both are plain lists.) Enter the names of the two lists, as shown below right.

setup screen 2 of 3 for stacked box-whisker plot    setup screen 3 of 3 for stacked box-whisker plot

stacked box-whisker plot The results are shown at right. You can see that the flight group, as a group, had lower blood-cell mass than the control group, even though some individuals from the two groups had equal blood-cell mass. Look particularly at the medians: the median for the control group is about equal to the third quartile of the flight group, meaning that about three quarters of the flight rats had blood-cell mass lower than the median of the control group.

Is that enough to say that space flight lowers blood-cell mass in rats in general? Not yet. Later in the course, you’ll learn how to use a two-sample t test to tell whether space flight lowers blood-cell mass in rats — whether there is a difference between the populations of all space rats and all earthbound rats.

TI-89 users: Please see Binomial Probability Distribution on TI-89.

See also: You can also make a Histogram of a Binomial Distribution.

The program always asks you the number of trials n, the probability p of success on one trial, and the number of successes from and to. If you want a specific number of successes rather than a range, then from and to will be the same number.

Example 1: Larry’s batting average is .260. If he’s at bat four times, what is the probability that he gets exactly two hits?

Solution:

n = 4, p = 0.260, x = 2

Note: Some textbooks use r for number of successes, rather than x.

TI-83 output screen for this problem; see text TI-83 input screen for this problem; see text Here you want the probability of exactly two successes, so FROM and TO will both be 2. In other words, you are computing the probability of 2 through 2 successes. Run the MATH200A program, select 3:Binomial prob, and specify

n = 4, p = .26, from = 2, to = 2.

The input and output screens are shown at right.

Answer: P(2) = 0.2221

Caution: Sometimes the probability is very small and the calculator reports it in scientific notation, such as 5.4189E-6. The exponent is not a decoration, and you must not report the probability as simply 5.1489. Probabilities are never greater than 1!

Conventionally, we round probabilities to four decimal places. If the probability is smaller than 0.0001 (smaller than 1E-4), you can show it to two significant figures, such as 1.3×10-6, or report it as <0.0001. Or you can convert it to a decimal, 5.4189E-6 → 0.000 005.

Example 2: Larry’s batting average is .260. If he’s at bat four times, what is the probability that he strikes out all four times?

Solution: Four out of four strikeouts means no hits, so you’ll put these values into the program:

n = 4, p = 0.260, from = 0, to = 0

TI-83 output screen for this problem; see text The output screen is shown at right.

Answer: P(0) = 0.2999

Example 3: Suppose 65% of the registered voters in Dryden are Republicans. In a random sample of ten registered voters, what’s the probability of fewer than six Republicans?

TI-83 output screen for this problem; see text Solution: “Fewer than six” is zero through five.

n = 10, p = 0.65, 0 ≤ x ≤ 5

Run the MATH200A program, select 3:Binomial prob, and enter

n = 10, p = .65, from = 0, to = 5

Answer: 0.2485

There’s about one chance in four of getting fewer than six Republicans in a random sample of ten registered voters.

Example: Consider these vehicle weights (in pounds):

2500, 3250, 4000, 3500, 2900, 4500, 3800, 3000, 5000, 2200

Construct a plot to decide whether these vehicle weights seem to be normally distributed.

TI-83/84 normal probability plot showing points nearly on a straight line, then normality check showing n=10, r=.9936, crit=.9179 Solution: Put the data in any statistics list, then press [PRGM], scroll down to MATH200A, and press [ENTER] twice. Select 4:Normality chk.

The program will make the plot and display the sample size n and correlation coefficient r, as shown at right. If the points are clearly linear (close to a straight line), r is close to 1 and you know that the sample was nearly a normal distribution; if they are clearly not near a straight line, r is far from 1 and you know that the sample is non-normal.

How far from r=1 is too far? The program also displays “critical r”, from How Normal Probability Plots Work. If r≥crit, it’s close enough to 1; if r<crit, it’s too far from 1 and the data are not normally distributed. (That may not be the end of your analysis. Some statistical procedures, such as a t test, are still valid for moderate departures from normality.)

For this example, the program computed a correlation coefficient of 0.9936 and critical value of 0.9179 for n=10. If it weren’t already obvious from the plot, r≥crit would tell us that the original data are approximately normal.

See also: How Big a Sample Do I Need? gives the statistical concepts with examples of calculation “by hand”.

sub-menu for determining sample size When you run the MATH200A program and select 5:Sample size, you are prompted first for the type of data, then for the margin of error, prior estimate, and confidence level. The program can find the necessary sample size for binomial data for one or two populations, or for numeric data for one population whether the population standard deviation σ is known or not. (At present the program can’t find sample size for numeric data for two populations.)

Caution: There are other criteria for sample size. For example, with numeric data your sample should be at least 30 unless you know that the population is normally distributed. Always check that your sample will meet the requirements before you begin gathering data.

Sample Size to Estimate μ for Numeric Data

The key here is whether you know the standard deviation of the population or not. If you don’t know σ, as usually you don’t, then you use s but the computation of sample size is different

Example 1—numeric data with known σ.
You want to estimate the average hourly output of a machine to within ±1.5, with 90% confidence. Based on historical data, you have reason to believe that the standard deviation of the machine’s hourly output is 6.2. How large a sample do you need?

Solution: Note first that this is not a realistic situation. It’s pretty unlikely that you would know the standard deviation of a population but not know the mean of that population. However, statistics texts always begin with this case because it’s the simplest way to demonstrate the principles. You leave Perfectland and enter Realityville in the other cases. With that said—

output screen for sample size example 1; see text input screen for sample size example 1; see text Marshal your data: 1−α = .90, E = 1.5, and σ = 6.2. Run the MATH200A program and select 5:Sample size, then 1:Num known σ. Enter σ=6.2, E=1.5, and C-Level=.9 or 90. The output screen echoes back your inputs and tells you the critical z for that confidence level as well as the minimum necessary sample size.

Conclusion: If the standard deviation of the population is 6.2, then to get a 90% confidence interval about the population mean μ with a margin of error no greater than 1.5, you need a sample of at least 47.

Example 2—numeric data with unknown σ
This is the realistic case for estimating a population mean. Usually you don’t know the standard deviation of the population, and you make a small pilot study to estimate it or you use a prior estimate.

The MATH200A program uses the method shown in Sample Sizes Required in NIST/SEMATECH e-Handbook of Statistical Methods.

Here’s a modified form of the previous example. You want to estimate the average hourly output of a machine to within ±1.5, with 90% confidence. A small pilot study finds a sample standard deviation of the machine’s hourly output is 6.2. How large a sample do you need?

Solution: output screen for sample size example 2; see text input screen for sample size example 2; see text Marshal your data: 1−α is .90, E is 1.5, and s (not σ) is 6.2. Run the MATH200A program and select 5:Sample size and then 2:Num unknown σ. Enter s and E, then .9 or 90 for C-Level as before. There may be a delay, because the program must compute one or more inverse t numbers. The output screen echoes back your inputs and tells you the critical t as well as the minimum necessary sample size.

Conclusion: If you don’t know the standard deviation of the population, but you have a prior sample with a standard deviation of 6.2, then to get a 90% confidence interval about the population mean μ with a margin of error no greater than 1.5, you need a sample of at least 49.

Why the difference from the previous example? In the previous case you knew the population standard deviation, and here you don’t. Since an additional parameter is unknown, it takes a larger sample to get the same level of precision for an estimate of μ. Another way to look at it: with unknown σ, you’re using the t distribution, which is more spread out than the z (normal) distribution, and therefore t needs a lager sample to achieve the same margin of error.

Sample Size for Binomial Data

To Estimate p for One Population

The program helps you find the sample size for estimating a population proportion p (some books use π) for binomial data. Use a prior estimate in this computation if you have one; if you have no idea of the population proportion then use 0.5.

Example 3—binomial data for one population, with prior estimate
What percent of the voters would vote for your candidate if the election were held today? You want 95% confidence in your answer, with a margin of error no more than 3.5%. Last month’s poll showed your candidate had 42% support. How many voters do you need to survey?

output screen for sample size example 3; see text Solution: Here you have 1−α = 0.95, E = 0.035 (careful! not 0.35), and  = 0.42. (When you have a prior estimate, use it; otherwise use 0.5.) Run the MATH200A program and select 5:Sample size, then 3:Binomial. Enter your prior estimate, your margin of error, and your confidence level, and you get the output screen shown at right.

Conclusion: If the true population proportion is somewhere in the neighborhood of 42%, and you want a 95% confidence interval with a margin of error no more than 3.5%, you’ll need a sample of at least 764.

Example 4—binomial data for one population, with no prior estimate
output screen for sample size example 4; see text Suppose you didn’t have any idea of the proportion of the population that planned to vote for your candidate? In that case, you’d use 0.5 for your prior estimate, and you’d have the output shown at right. The necessary sample size would rise to 784.

To Estimate p1−p2 for Two Populations

With binomial data for two populations, you compute necessary sample size to estimate the difference between the two proportions. This is different from the sample size needed to estimate the proportion in either population on its own.

It’s not actually necessary to have the two sample sizes equal, but that’s the only way it’s possible to compute them when neither one is specified up front. Just as before, use prior estimates for the population proportions if you have them, and otherwise use 0.5.

Example 5—binomial data for difference of two population proportions, with prior estimates
Suppose you’d like to know how your candidate’s support differs between men and women. You know that overall support is 42%, and you think the candidate is 10 percentage points more popular among women versus men. How many of each sex must you survey to answer the question with 95% confidence and a margin of error no more than 3½%?

Do you have an estimate of p1 and p2? Yes, since the overall support is 42% you expect that men’s and women’s support is not too different from that. If women are 10% higher, then you estimate women at 47% and men at 37%.)

output screen for sample size example 5; see text input screen for sample size example 5; see text Solution: Here you have 1−α = 0.95, E = 0.035, 1 = 0.47, and 2 = 0.37. Run the MATH200A program and select 5:Sample size, then 4:2 pop binomial. Enter your prior estimates, your margin of error, and your confidence level, and you get the output screen shown at right.

Conclusion: If the true population proportions are somewhere in the neighborhood of 47% and 37%, and you want a 95% confidence interval on the difference with a margin of error no more than 3½%, you’ll need a sample of at least 1513 women and 1513 men.

Example 6—binomial data for difference of two population proportions, with no prior estimates
output screen for sample size example 6; see text And suppose this was the first poll and you had no idea of your candidate’s support among women and men? In that case you use 0.5 for both 1 and 2, with the results shown at right. With no prior estimate, to get a 95% confidence interval on the difference in support, with only a 3½% margin of error, you’d need 1568 women and 1568 men.

TI-89 users: Please see Testing Goodness of Fit on TI-89.

To perform a goodness-of-fit test, first put your model in L1 and your observed numbers in L2. Caution: the model is usually percentages or ratios, but the observed numbers are always the actual counts in whole numbers, never percentages. Then run the MATH200A program and select 6:GoF test. The program will ask you to confirm that you’ve filled the two lists, and then it will perform all computations for the χ² goodness of fit and show the results on a graph.

The expected numbers are left in L3, and you should verify that they meet the requirements for a χ² test: none of them <1, and no more than 20% of them <5.

Example 1—shifting populations from Sullivan, Michael, Fundamentals of Statistics 3/e (Pearson Prentice Hall, 2011), Example 3, pages 562–563.

Region2000
Census
current
sample
Northeast19.0%274
Midwest22.9%303
South35.6%564
West22.5%359

“An urban economist wonders if the distribution of residents in the United States is different today than it was in 2000. In 2000,” the proportions were as shown in the table. “The economist randomly selects 1500 households and obtains the frequency distribution shown. ... Conduct the appropriate test to determine if the distribution of residents in the United States is different today from the distribution in 2000, using the α = 0.05 level of significance.”

Solution: H0 is that the model is still good, and H1 is that the distribution of US population has changed. The model is the percentages shown, and you are determining whether the current sample is enough different from the model for you to conclude that the model is no longer correct.

input screen for Example 1; see text Put the percentages in L1; there’s no need to convert them to decimals but if you do then you must convert all of them. The current sample is the Observed numbers, and they go in L2.

Caution: The Observed numbers must always be actual counts; never convert them to percentages.

Caution: Some problems will give you total observations, but you never enter the totals in your calculator.

confirmation screen for Example 1; see text Run the MATH200A program, select 6:GoF test, and press [9] to confirm that you have data in the correct lists.

output screen for Example 1; see text The results screens are shown at right. None of the expected values are below 5, so that requirement for the goodness-of-fit test is met. There are three degrees of freedom (four categories minus one). The χ² test statistic is 8.25, and the p-value is 0.0410.

Conclusion: Since p<α, you reject H0 and accept H1. At the 0.05 level of significance, you conclude that the regional distribution of US residents is different today from what it was in 2000.

L3 through L4 outputs for Example 1; see text The screen gives a summary, but there’s useful information in L3 and L4.

L3 contains the expected numbers. Always check them after the computation to make sure that none of them are below 5. (Some authors use a looser requirement: no E’s below 1 and no more than 20% of them below 5.) Here, all are well above 5.

L4 shows how far off the Observed numbers are, taking into account the weights of Expected numbers in the model. Or you can say that L4 shows each category’s contribution to χ². You can see that the most important deviation is in the second category (4.78), and the least important is in the first category (0.42). The total of L4 is the χ² test statistic, which you’ve already seen has a value of 8.25 for this test.

As a rule of thumb, a value above 4 in a row of L4 means that that row’s observations are notably different from the model. Here the value L4(2) is the only one above 4. Look at observed and expected in the same row. L2(2) is 303 and L3(2) is 343.5: observed is less than expected. Row 2 is the Midwest, so the Midwest is significantly under what you would expect from the model.

Example 2—equal frequencies from Sullivan, Michael, Fundamentals of Statistics 3/e (Pearson Prentice Hall, 2011), Example 5, pages 564–565.

Sample of Birth Records
Day of
Week
Freq-
uency
Sunday57
Monday78
Tuesday74
Wednesday76
Thursday71
Friday81
Saturday63

“An obstetrician wants to know whether or not the proportion of children born each day of the week is the same. She randomly selects 500 birth records and obtains the data shown.” Clearly the frequencies in the sample vary from day to day, but do they vary enough that you can say babies in general are born with different frequencies on different days, at the 0.05 level of significance?

Solution: H0 is that babies are born with equal frequency on all days of the week, and H1 is that they are not. You’re not given a numerical model because “equal frequencies” means that all model numbers are the same. Since there are seven categories, your model is seven 1’s in L2. The Observed numbers go in L2, as usual.

output screen for Example 2; see text The results are shown at right. Here no E’s are < 5; in fact they are all about 71. df = 6 because there are seven categories. The χ² test statistic is 6.18, and the p-value is 0.4029. That is greater than α, and so you fail to reject H0.

Writing non-conclusions is problematic when p>α in a χ² test. Strictly speaking, the conclusion should be in neutral language as usual: you can’t determine from the data whether babies are born with equal frequency on all the days of the week or not. But traditionally, the conclusion is often stated in some words equivalent to “the data do not rule out the model”.

This is the scientific method. If the experiment is repeated multiple times and H0 is never rejected, we begin to have more and more confidence that H0 is actually true. We can’t accept H0 from a single experiment, but the more times it’s not rejected, the more we believe that it may never be rejected.

Example 2—side effects of drugs, adapted from Sullivan, Michael, Fundamentals of Statistics 3/e (Pearson Prentice Hall, 2011), pages 579–581: In clinical trials, patients with high cholesterol were randomly assigned to three groups. One group was given Zocor, one group was given a placebo, and one group was given cholestyramine (a generic drug). Below are the numbers of those in each group who did and did not experience abdominal pain. At the 0.01 significance level, is a person equally likely to have abdominal pain on all three regimes?

ZocorPlaceboCholestyramine
Abdominal pain 51516
No abdominal pain 1532152163

Solution: This is a test of independence. H0 is “abdominal pain is equally likely with all three treatments”, and H1 is “abdominal pain is not equally likely with all three treatments”—not just in this sample of patients, but in cholesterol patients generally.

input matrix; see text Press [2nd x-1 makes MATRIX] (on the classic TI-83, press [MATRX]), then [] [ENTER] to edit matrix A. You have 2 rows and 3 columns. (In this problem, row and column totals are not shown, but even if they were you would ignore them.)

results of chi-squared test; see text Run the MATH200A program and select 7:Two-way table. Matrix A is the only input; the program will immediately start computing and in a few seconds will display the results.

What is this screen telling you? First, requirements for the χ² test are checked. As you know, all expected values must be at least 5. (Some authors give a looser requirement: no more than 20% of E’s below 5, and no E’s below 1. When there are expected values below 5, MATH200A also shows the number of expected values that are below 1.) In this case no E’s are below 5, so you’re fine. The expected values themselves can be seen in matrix B.

There are two degrees of freedom (df = rows−1 times columns−1). The test statistic is χ² = 14.71, quite large for df=2. The p-value is therefore quite low, 6.4×10-4 or 0.0006. Conclusion: Whether you take Zocor, nothing, or cholestyramine does make a difference to your likelihood of experiencing abdominal pain.

The last two line tells you that the program has put additional information in matrix C, so let’s have a look there. Press [2nd x-1 makes MATRIX] (on the classic TI-83, press [MATRX]), then [] [3] to view matrix C. Unfortunately you can see only three columns at a time on your calculator, but I’ve pasted two screens together here for convenience:

matrix C, as described in text

The program dimensions matrix C two rows and two columns larger than input matrix A. This is what matrix C tells you:

Example 2—marital status and happiness, adapted from Sullivan, Michael, Fundamentals of Statistics 3/e (Pearson Prentice Hall, 2011), pages 575–576: In the 2006 General Social Survey, a random sample were asked their marital status and level of happiness, with the results below. Can you say, at the 0.05 significance level, that happiness level and marital status are dependent?

MarriedWidowedDivorced/
Separated
Never
Married
Totals
Very happy 60063112144919
Fairly happy 7201423554591676
Not too happy 9351119127390
Totals 14132565867302985

results of 2-way chi-squered test Solution: H0 is “marital status and happiness level are independent”, and H1 is that they are dependent (or associated, or not independent). Enter the numbers in 3×4 matrix A, run the MATH200A program, and select 7:Two-way table.

Careful! Even if you are given row or column totals, you are concerned only with the detailed numbers. You have three happiness levels and four marital statuses, so this is a 3×4 matrix.

Results: No expected values are below 5. The χ² statistic of 224.12 is enormous, and the p-value of 1.4×10-45 is correspondingly tiny, so you conclude that happiness level and marital status are indeed dependent.

Matrix C looks like this (again, after pasting two screens together):

results matrix C; see text discussion

Since matrix A is 3×4, the first 3 rows and 4 columns of matrix C are the χ² contributions, or squares of standardized residuals. Many of them are quite large, showing that “happiness is independent of marital status” fails badly as a model.

results matrix C with standardized residuals highlighted

The row and column totals are next, but in this case you already know the totals because they were given in the problem.

results matrix C with row and column totals highlighted

Finally, look at the row and column percentages. About 31% of the sample described themselves as very happy, 56% as fairly happy, and 13% as not too happy. If H0 is true, you would expect 31% of married people to be very happy, 56% of married people to be fairly happy, and 13% of married people to be not too happy; and you would expect those same percentages for widowed people, for divorced or separated people, and for never-married people. In fact, the percentages are quite different, as you can see if you calculate a few of them.

results matrix C with row and column percentages highlighted

The column percentages can be interpreted in the same way. About 47% of the sample was married, so if H0 is true you would expect 47% of very happy people, 47% of fairly happy people, and 47% of not-too-happy people to be married. (The same statement applies in the other columns, with their percentages.) Again, this is obviously not the case if you look at the original observed data.

What’s New

14 Oct 2013—program version 7:

27 Nov 2012—program version 6:

1 Aug 2012—program version 5:

(intervening changes suppressed)

Dec 2008: Program version 1.


This page is used in instruction at Tompkins Cortland Community College in Dryden, New York; it’s not an official statement of the College. Please visit www.tc3.edu/instruct/sbrown/ to report errors or ask to copy it.

For updates and new info, go to http://www.tc3.edu/instruct/sbrown/ti83/