Testing For Equal Variance

This is the sixth and penultimate step in constructing the oneway advisor.  The advisor automates four tests associated with the assumptions of a oneway analysis of variance.  In this step a test will be performed to assess whether the data within each level of the grouping variable have equal variance. 

Testing For Equal Variance

This test is performed in JMP by selecting the Unequal Variance option from the red triangle option within the Oneway platform.  Here is some sample output:


It seems that our professors of statistics can’t quite agree on how to perform this test!  I can think of three ways of dealing with this table of information:

  1. Decide on a standard test .e.g Levene and only look at the p-value associated with this test
  2. Apply contextual knowledge – e.g. use the Bartlett test if the data have been demonstrated to be normally distributed, otherwise use the Levene test
  3. Take the worse-case outcome i.e. look at all the tests and select the lowest p-value

I’m going to choose to implement the third option.

A couple of points that will become relevant to the code implementation:

  • The above table is contained within an outline box called “Tests that the Variances are Equal”
  • If the grouping variable has more than two levels then the p-Value column takes the label “Prob > F” as illustrated below:


Checking the Number of Levels

Given that the output differs based on the number of levels within the grouping variable we’ll need some code to find the number of levels .  There are a lot of interesting ways to implement this in code and we could go on quite a tangent exploring all the methods – but to keep the discussion focussed I’m just going to state the following code without too much justification, other than it works:

Where dt is a reference to a data table and xCol is the string name of a column.  You can verify the code by opening the “Big Class” data table and running this code:

Here is the JMP log window output:


Test Equal Variances

Here is the code for the implementation of the user-defined function Test Equal Variances.  The code needs to be added to the file Analysis Components.jsl.

  • Lines 3 and 4 contain the code illustrated earlier for determining the number of levels in the x-variable
  • Lines 5 to 9 create a Oneway object
  • Line 8 is the code equivalent of selecting Unequal Variance option found under the red triangle
  • Line 10 creates the variable rep which is a reference to the window containing the Oneway results
  • Line 11 gets a reference to the outline box containing the tabulated results
  • Line 12 gets a reference to the table containing the results
  • Line 14 creates a variable cbPValue that references the p-value column in the results table, if the number of levels is 2
  • Line 16 creates a variable cbPValue that references the “Prob > F” column if the number of levels is not 2
  • Line 18 gets a list of p-values from the  column referenced by cbPValue
  • The variable lstPValues created in line 18 is a list.  The Min function identifies the smallest item in this list which is stored in the variable pValue

Implementing the Function

Now that the test is implemented in code and saved within the Analysis Components JSL file, it is available for use within the main code (step5.jsl) of the oneway advisor.  To use the function the same pattern of code is used as for the tests described in the last two posts.  The revisions are highlighted below:

One the revisions have been made the file should be saved as step6.jsl.

The Output

The oneway advisor is almost complete.  Here is what the output should look like:


Continue to step 7.

One thought on “Testing For Equal Variance”

Leave a Reply

Your email address will not be published. Required fields are marked *