This Java™ applet does nonparametric Monte Carlo tests for the blocks and treatments design. The number of blocks must be six or more, or there will be no useful power. The applet uses Tukey’s pairs of treatments, but it does not assume the normal model. It uses sign reversal instead of shuffling. Sign reversal causes correct behavior in the presence of heteroskedasticity. The AWT controls in order are a single-line TextField to hold the many integer, a multi-line TextArea which I will call the upper text area, a Button called “goReverse,” a faded Button called “percent,” a faded Button called “stop,” a Button called “goRankAndReverse,” and a multi-line TextArea which I will call the lower text area.
When loading is finished, many is already set to its default value: one million. Nothing prevents the user from changing this. (This many is the total number of genuine and fake samples.) From the copyrighted Web page http://www.liquidasset.com/report65.html I copy the table
6. 3. 5. 7. 8. 4. 1. 2. 6. 2. 1. 7. 8. 3. 4. 5. 6. 7. 2. 1. 4. 8. 3. 5. 8. 7. 2. 1. 6. 3. 4. 5. 5. 3. 2. 1. 8. 7. 4. 6. 7. 4. 1. 5. 6. 8. 2. 3. 5. 1. 4. 2. 8. 7. 6. 3. 1. 5. 3. 4. 7. 8. 6. 2.This is not exactly the table on that page, because I have removed the names of the wine judges and left only the rank numbers. Each column is a wine, and each row is the ranks of one judge. This is a blocks and treatments design, with columns for treatments and rows for blocks. The null hypothesis says that in each block all the treatment distributions are symmetric around a common center of symmetry for that block, but the distributions in that block may otherwise be different. Of course, different blocks may have different centers of symmetry and different symmetric distributions.
I respectfully suggest that the reader select the table with the mouse, copy it, move the mouse to the inside of the upper text area, paste into that text area, and click with the mouse on the “goReverse” button. The “goReverse” and “goRankAndReverse” buttons will vanish, and the remaining two buttons will unfade. The lower text area will have the word “Working” in it for some seconds, and then the lower text area will change to
or the like. The list of p-values occurs three times: sorted by p-values, sorted by “a,” and sorted by “b.” The number of seconds and the p-values will vary, but the other numbers will not. If the p-values for some pairs of treatments are small enough to reject the null hypothesis, then we may infer that the two treatments of each such pair are different from each other, treatment “a” being more postive than treatment “b.” If the α value of this wine test is five percent, then we may say that wine number 4 is more positive than wine number 2, because 0.007567 is smaller than our α. In the experiment the judges gave smaller ranks to better wines, so we ought to serve wine number 2 to our guests rather than wine number 4. Remember always that the leftmost treatment of the big rectangle is number zero. The other p-values are larger than five percent, so there are no other inferences to be made from this experiment.
When the normal model is true, the “Tukey” test has less power than the usual sum-of-squares test, but the latter cannot tell us which treatments to use (which wines to drink.)
to Top
How do I stop the program?
It may happen that the program is working and working and shows no sign of stopping. This is a good time to click the mouse on the “percent” button. The percent of work done will be printed on the lower text area. If the percent is near one hundred, then the user may just wait a small time and the answers will be printed.
If on the other hand the percent is small, then just please click the mouse on the “stop” button. Then please change the many to something smaller, and click the “goReverse” button again.
to Top
The goRankAndReverse button
From here on, all the data are fictitious. Here is a sample where each block is completely correlated with each other block:
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9The results from it are
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 333 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9The result is
The experimenter ought to click the “goReverse” or “goRankAndReverse” button only once. (Running the program ten times and taking the smallest p-value is clearly cheating.) Students will perhaps be told by their teacher how many times they may click.
The present applet can work on non-ranked data. In the wine test the judges wrote ranks on their papers, but in science and engineering the lab book often contains measured numbers having decimal digits after the point. If the measurements belong to a nearly Gaussian population, then ranking pulls down the power of the test. On the other hand, for very heavy-tailed populations ranking improves the power.
to Top
Which browsers?
All the famous modern browsers can do this page correctly, but the “zoom” must be set to 100% or reset to zero, depending on the browser. The zoom control will commonly be on the “view” dropdown menu. If the zoom is wrong, then the “layout” of the Java applet will be wrong.
However, the program can work only if Java is installed and Java is turned on. If there is no Java or if Java has been turned off, then the text field and the text areas and the “goReverse” and “percent” and “stop” and “goRankAndReverse” buttons will not even be visible. In that case, the user is respectfully requested to download and install Java and/or to turn Java back on. Users who have trouble doing this are respectfully asked to get help from their classmates, children, spouses, or teachers.
to Top
Download
A reader or user wishing to download the files of this applet is respectfully invited to click on
BlockTreatTukey.jar
to save the “jar” file. All the other BlockTreatTukey files are zipped into it, so it can be unzipped after download to see and change them all. Yes, a “jar” file is merely a special kind of “zip” file.
If the browser’s downloader renames the “jar” file to a “zip” file, please be sure to rename it back to a “jar”. I know a browser which takes too much on itself in this way.
to Top
The “Tukey” statistic and its use
First is the explanation of the “Tukey” statistic as I first wrote it:
“For each treatment, total all the numbers to get a footTotal value. Then take all the differences of the footTotal values. This set of differences is the statistic. First calculate the statistic for the genuine sample. For each difference, make a number called right equal to unity. Now we have two sets, a set of genuine differences and a set of numbers called right.
“Next we need to work the fake samples, many-1 of them. To make a fake sample, for each block either do or do not reverse all the signs of its numbers. The probability of reversing should be one half. Then calculate a fake statistic by totaling in each treatment and by taking differences of the totals. Now find the maximum fake difference. For each genuine difference, if the maximum fake difference is greater than or equal to that genuine difference, then increment the right for that genuine difference. When all the fake samples have been used, the p-value of each genuine difference is the ratio of its right to many.”
Then I found out about stepdown procedures, as in E. L. Lehmann and Joseph P. Romano, Testing Statistical Hypotheses,, Springer, Third Edition, Corrected at fourth printing, 2008. The place to start reading about stepdown is chapter 9, “Multiple Testing and Simultaneous Inference.” The word stepdown is defined on page 351, about the middle of the page. I have altered my “Tukey” program to step down, so as to make some of the p-values decrease. No p-values increase.
to Top
Averages and the Simpson paradox
In this section I present a fictitious example of what is called “Simpson’s Paradox.” In our fair city we are justly proud that we host a big, famous music conservatory. Last week one of those bureaucrats from upstate went through our salary records with a calculator and asked the dean why the women on the faculty were getting paid less, on the average, than the men. The dean drew a blank, so the bureaucrat showed her the numbers: in thousands of dollars a year the average salary for women was 49.444444444444 and the average for men was 58.888888888889. The dean said she would get back to him, so she asked me, her statistician, to find out what was going on. Well, of course the faculty are divided into different departments to teach different things, such as fiddle, banjo, singing, jug, washboard, and so on and so forth. There are eight departments, and here are the salaries with women on the left, in curly braces, and men on the right:
{ 100 } { 90,90,80,80,70,70,70,60 }
{ 90,90 } { 80,80,70,70,60,60,60 }
{ 80,80,70 } { 70,70,60,60,50,50 }
{ 70,70,70,60 } { 60,60,60,50,50 }
{ 60,60,60,50,50 } { 50,50,50,40 }
{ 50,50,50,40,40,40 } { 40,40,40 }
{ 40,40,40,40,30,30,30 } { 30,30 }
{ 30,30,30,30,20,20,20,20 } { 20 }
The reader can see that I have put the high-paying departments at the top and the low-paying departments at the bottom. Taking average salaries for women and men, in each of the eight departments, I got
100 76.25 90 68.571428571429 76.666666666667 60 67.5 56 56 47.5 45 40 35.714285714286 30 25 20Please notice, in each department the average for women is more than the average for men. Not only that, if the reader will be pleased to select those sixteen averages with the mouse, and click to copy, and paste into the upper text area, and click on the “goReverse” button, the program will print
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15shows strong correlation, so the p-value of at least one pair of treatments ought to be small. Instead, the “goReverse” button gives
On the other hand, the “goReverse” or “goRankAndReverse” test cannot be used when the number of blocks is small.
The noun “heteroskedasticity” and its adjective “heteroskedastic” were first used for “normal” distributions. The words refer to normal distributions which have the same μ value but different σ values. Sometimes the words are spelled with a “c” instead of a “k,” so that one may read “heteroscedasticity” and “heteroscedastic.”
If no block can have ties and we use the “goRankAndReverse” button, the applet works correctly in the presence of unsymmetry, provided that the distributions in the same block are exchangeable. By “correctly” I mean that the true size of the test is less than or equal to the nominal size.
to Top
A note to developers
Statisticians who do not plan to change or repair the program need not read this. The attention of developers is respectfully drawn to the line
final boolean debugging=false;in the BlockTreatTukey.java file. The debugging variable is used in the try/catch statement
try
{
parse();
}
catch( Throwable thro )
{
String temp="";
temp+=thro.getClass().getCanonicalName();
temp+="\n\n";
temp+=thro.getMessage();
temp+="\n";
lowerTextArea.setText( temp );
if( debugging )
{
StackTraceElement[] ste=thro.getStackTrace();
int n=ste.length;
for( int j=0;j<n;j++ )
{
lowerTextArea.append( "\n"+ste[j] );
}
}
}
where I have bolded and bigged the line where debugging is used. When debugging is true, the StackTraceElements will be shown in the lower text area. That is, the program will say not only what happened, but also where it happened. Doubtless the professional Java programmers know about this already, but I am an amateur and I just found out. After the program is changed or repaired, the value of debugging can of course be set back to false.
The GetRanks.java file contains the getRanks method, which calculates ranks for an array of double. Ties are handled correctly.
The SortPointer.java file contains the sortPointer method which sorts an array of double without moving any numbers in the array. Instead it creates an array of int pointing to the array of double. That is, pointer[0] points to the most negative double, pointer[1] points to the next most negative, and so on. This trick makes it easy for my program to work the “steps” in parallel instead of sequentially, saving much computer resource. I refer especially to the gamble method and the partialMaximum variable in the BlockTreatTukey.java file. Notice please that genuineFlat is sorted, but fakeFlat is not sorted.
to Top
Revision date, licenses, and e-mail address
This program and its files are revised 12 January 2010.
The numerical table for wine tasting is Copyright (c) 1995-2003 Richard E. Quandt, V. 1.65 .
All the rest of this file and all of the other files which I include with it are in the public domain.
The Java™ language is the property of Sun.
Any mistakes in my programs or documentation are my own. They are certainly not the mistakes of Lehmann, Romano, or Tukey.
Please send all criticism, both constructive and destructive, to me, Harold M. Kaplan,
at dot
smtw2gh toadmail com
to Top