Goodness-of-fit test for discrete data

This macro performs a Goodness-of-Fit test between observed frequencies and a hypothesized discrete probability distribution, using both the chi-square and likelihood-ratio (G) statistics. Exact p-values can be requested for small sample sizes when no parameters are estimated. Otherwise, the chi-square approximation is used.

This macro performs a Goodness-of-Fit test between observed frequencies and a hypothesized discrete probability distribution, using both the chi-square and likelihood-ratio (G) statistics. Exact p-values can be requested for small sample sizes when no parameters are estimated. Otherwise, the chi-square approximation is used.

Download the Macro

Be sure that Minitab knows where to find your downloaded macro. Choose File > Options > General. Under Macro location browse to the location where you save macro files.

Important

If you use an older web browser, when you click the Download button, the file may open in Quicktime, which shares the .mac file extension with Minitab macros. To save the macro, right-click the Download button and choose Save target as.

Required Inputs

  • Column containing the observed frequencies (integer counts).
  • Column containing either the expected numbers or the hypothesized probabilities. If expected numbers are used, the sum of values in this column must equal the sample size. If probabilities are used, the sum must equal 1.0.

Optional Inputs

ESTIMATE K
Use to specify the number (K) of parameters estimated from the data so that the degrees of freedom of the test statistic can be decreased accordingly. The default value for K is zero.
EXACT
Use to calculate an exact P-value for the chi-square statistic based on the multinomial distribution. The exact test should be invoked only when there are relatively few categories (2 or 3) and/or the sample sizes are so small that the chi-square approximation is unreliable. Because this routine invokes built-in Minitab functions many times, it is highly inefficient and will require a large amount of time to execute if sample sizes or the number of categories are too large. In the special case of two categories, the chi-square statistic is calculated both without and with the Yates correction for continuity.

Running the Macro

Suppose the observed frequencies are in C1, the expected numbers are in C2. To run the macro, choose View > Command Line/History and type:

%GOF C1 C2

Click Run.