Three-way tests of independence

This macro fits log-linear models to three-way classification data (a contingency table). Likelihood-ratio tests for goodness of fit are performed for whole models and for individual terms.

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

  • Three factor columns, each containing the levels of the observation
  • A column containing the observed frequency or count for each combination of values in the factor columns
Note

The macro is limited to a maximum of 10 levels per factor. You can modify the macro code if more than 10 are needed. First, modify the upper suffix of the variables ABT, ACT, BCT, and JUNK in the declaration statements. Then modify the value of LMAX in the LET statement that follows. Modify this note in the code to show the new maximum value.

Running the Macro

Suppose the factor levels for the three way table are in C1, C2, and C3. The frequencies are in C4. To run the macro, choose View > Command Line/History and type:

%THREEWAY C1 C2 C3 C4

Click Run.

Note

The user should be cautioned that a test of an individual term is legitimate only if all terms that were omitted from the two models (between which the difference was taken) correspond to effects that are, in fact, absent.

More Information

In the output, each model tested is identified by a list of the terms that are included. The three factors are symbolized by the upper-case letters A, B, and C. Model terms are represented by the following simple rules:

A = main effect of factor A

AB = 2-way interaction between factors A and B

ABC = 3-way interaction between factors A, B, and C.

Models are strictly hierarchical, so that the inclusion of a specific term requires the inclusion of all lower-order terms that involve any subset of the same factors. Therefore, terms are not listed if their inclusion is implicit in higher-order terms that are listed. For example, the saturated three-way model is simply written as (ABC) because the inclusion of the three-way interaction implies the inclusion of all two-way interactions (AB, AC, and BC) and all main effects (A, B, and C).

The best-fit model is the simplest model for which the goodness of fit statistic is non-significant. Usually, this is the same as the model that includes only those terms whose individual effects are statistically significant. When the best-fit model has been identified, it is interpreted as follows:

(ABC) Each factor is dependent on the other two.

(AB AC BC) Each factor is dependent on the other two, although the pattern of dependence is less complex due to the absence of the 3-way interaction.

(AB BC) Factors A and C are conditionally independent, that is, they are independent for a fixed value of factor B.

(A BC) Factors B and C are jointly independent of factor A.

(A B C) Factors A, B, and C are mutually independent.