Table of Contents.

Introduction.
Suitable browsers.
Sun Java for Microsoft Windows users.
Downloads.
A simple example.
     Missing value(s).
     Setting notepad for programming in Windows XP.
Interlude for non-beginners or non-Microsoft-Windows users.
Only two treatments: matching.
     Right side instead of two-sided.
     Supernumerary value(s).
Only two blocks: independence.
Only one block: k-sample test.
License, revision date, and e-mail address.

Introduction.

This file describes the BlockTreat program, a general frequentist Monte Carlo program for block and treatment tests, tests with matching, k-sample tests, and tests for independence of a random variable from another random variable. The tests are nonparametric, but there is no ranking. The designs may be incomplete and unbalanced, or even have supernumerary entries. The tests are, like other Monte Carlo tests, exact. All that the BlockTreat program does is randomly shuffle the values within the blocks and see how the statistic changes.

I thank Dr. Arvind Nath for finding an important bug in the program. The bug was repaired on 12 March 2007. Users who downloaded this software on or before 12 March 2007 are asked to download again, so as not to have the bug. Actually, the only files needing to be changed are this file that you are reading, which is BlockTreat.htm, and the actual BlockTreat program, which is BlockTreat.java. New users please ignore this paragraph.

BlockTreat is not an applet. It is a stand-alone console program. One of the arrays in BlockTreat usually has a length of one million, and applets scale up to that size poorly. To top.

Suitable browsers.

The sample programs in this file have tab characters in them. If the user plans to select and copy some of these programs, so as to paste them into an editor and save them into a file, the web browser ought to be a Microsoft Internet Explorer or one of its relatives, or else a Netscape browser or one of its relatives, or else Opera 9 or later. The relatives of Netscape include Mozilla and Mozilla Firefox.

The Netscape 4 browser is out of date, and it is unable to show English quotation marks correctly in the text. One ought to use a recent browser. To top.

Sun Java for Microsoft Windows users.

In order to get up speed, the program uses the Java™ language of Sun. It is likely that the user has it. The new Macintoshes come with it. Linux users mostly know where to get it. Therefore I direct my remarks to Microsoft Windows users. Let the Microsoft Windows user “open a dos box.” The surest way to do this is to click on Start at the lower left of the monitor, and then click on Run. When Run opens its box, type cmd into the box and click on the OK button. A dos box may open, or instead a little window may open saying that cmd cannot be found. In that case, click on the OK button of the little window to close it. Then delete cmd and instead type command into the box, and click on the OK button again. This time the dos box ought to open. The type size can be adjusted at the upper left hand corner. Then type at the prompt
java
and push the Enter key. If Java is present, it will print a long list of usages and options. If Java is not present, the computer will print 'java' is not recognized as an internal or external command, operable program or batch file or Bad command or file name. If Java is not present, the user ought to click back to the present file and click on http://www.java.com/en/download/manual.jsp and then follow directions for downloading to Microsoft Windows, taking all the defaults. Then type
java
again at the dos prompt and push Enter, to check if the installation succeeded. (I have never known it to fail.) To top.

Downloads.

Java being present already or newly installed, let the user click back to the dos box and type at the prompt
c:
cd \
mkdir myjavas
pushing the Enter key at the end of each of the three lines. This myjavas is the folder where the downloads ought to go. Click back to the present file. From the present file click on BlockTreat.java using the right mouse button (not the left button,) and click to save. The user’s computer will suggest a folder to which to download. This folder will be wrong. Be sure to change the download folder to the newly created folder named c:\myjavas, or else the download will get lost in the depths of the hard disc. Then finish the download. Similarly download Temp.java, b.bat, jaco.jar, and BlockTreat.htm. Then click back to the dos box and type
cd myjavas
dir
using the Enter key as before. The dir command ought to show the five files that have been downloaded. If the user is using Microsoft Internet Explorer, then the jaco.jar file may have had its name changed to jaco.zip, but this is nothing to worry about, because the b.bat file will change the name back. For other discrepancies the user is respectfully advised to consult a colleague, spouse, friend, relative, classmate, or teacher. (My daughters give me excellent advice.)

The five files are as follows: BlockTreat.java is the program to do the block and treatment tests. Temp.java is a program to call BlockTreat.java and give it some data to work on. The b.bat file is a batch file to call a compiler to compile Temp.java and BlockTreat.java, and then to start the compiled class file. The jaco.jar file is a small but sturdy compiler for the Java language. It is written by Matthias Zenger, Ph.D. His site is http://zenger.org/jaco/. He does not assert copyright, but neither does he say “public domain,” so I suppose he gets his common law copyright. BlockTreat.htm is the file you are now reading. I will explain to Microsoft Windows users how to use all these in paragraphs below. Users of other systems are respectfully requested to make suitable mental changes to what I say. To top.

A simple example.

I quote from Gottfried E. Noether, Introduction to Statistics, A Fresh Approach, Houghton Mifflin Company, Boston, 1971. On his page 148 he says, “Here we have the average number of miles per gallon of gasoline that cars built by three different manufacturers achieved in a well-publicized economy run:”
Gasoline Mileage for Various Cars
manufacturer
model
G
F
C
compacts 20.3 25.6 24.0
intermediate 6’s 21.2 24.7 23.1
intermediate 8’s 18.2 19.3 20.6
full size 8’s 18.6 19.3 19.8
sports cars 18.5 20.7 21.4
The three manufacturers are the treatments, and the five models are the blocks. The decimal points are not allowed in the BlockTreat program, so each number must be multiplied by ten. This is because an exact test requires exact arithmetic. Also, BlockTreat requires that each gasoline mileage value be accompanied by its treatment number, so as to allow for possible missing values and supernumeraries. The treatments are numbered from 0 to 2, inclusive. Here is what the Temp.java file looks like:
class Temp
{
	public static void main( String[] args )
	{

	int[][] y=
	{
	{203, 256, 240},
	{  0,   1,   2},

	{212, 247, 231},
	{  0,   1,   2},

	{182, 193, 206},
	{  0,   1,   2},

	{186, 193, 198},
	{  0,   1,   2},

	{185, 207, 214},
	{  0,   1,   2}
	};

	int treatments=3;
	int seed=132035465;
	int many=(int)1e6;
	String sided="two";

	BlockTreat.report( y,treatments,seed,many,sided );
	}
}
The treatments integer is the number of treatments. The seed integer is the seed of the pseudorandom numbers used in the shuffle. The user may choose it arbitrarily, and it should be changed when the user changes to another experiment. The many integer is how many times the statistic is calculated. I have set it to a million, but the user may of course alter it. The sided String is the sidedness of the alternative hypothesis. For more than two treatments it must be two. The file is a Java class, so the user must follow the grammatical rules of Java. Also, it is a good idea to be a neat freak and use the space bar and the tab key to line up commas and curly braces in columns. The empty lines made by the Enter key are not required, but they do make the program easier to read.

This first time, the user need not actually type the Temp.java file, because I have already typed it and the user has downloaded it. The dos box still being open, the user may type

b
at the prompt and push Enter. Unless I have made a mistake, the computer will print
Compile has succeeded.
p-value is 0.01155
normalized negated logarithm of p-value is 4.48794616311194

(un-normalized negated logarithm of p-value is only 4.461069842014335)
(normalizer is 0.9940114430697696)
and stop. On my computer this takes about three and a half seconds. The user knows already what a p-value is. For an explanation and example of normalized negated logarithm of p-value in Bayesian meta-analysis, I respectfully invite the user to click on http://www.toad.net/~jkaplan2/martMean.htm#Discrete. . To top.
Missing value(s).
Sometimes things are less simple. With apologies to Noether and his publisher, I suppose that my dog chewed on the gasoline mileage table before I got to see it, so that the left-most gasoline mileage value for intermediate 6’s cannot be read. The other two values in that block ought still to be used. Here is the new program:
class Temp
{
	public static void main( String[] args )
	{

	int[][] y=
	{
	{203, 256, 240},
	{  0,   1,   2},

	{     247, 231},
	{       1,   2},

	{182, 193, 206},
	{  0,   1,   2},

	{186, 193, 198},
	{  0,   1,   2},

	{185, 207, 214},
	{  0,   1,   2}
	};

	int treatments=3;
	int seed=132035465;
	int many=(int)1e6;
	String sided="two";

	BlockTreat.report( y,treatments,seed,many,sided );
	}
}
The user is respectfully invited to click to the dos box and type
notepad Temp.java
at the prompt. The Microsoft Windows Notepad editor will open containing the Temp.java file. The user can then make the change as I have shown and drop the file menu and click to save. Then the user can click back to the dos box and type
b
and push Enter as before. This time the computer will print
Compile has succeeded.
p-value is 0.043309
normalized negated logarithm of p-value is 3.158512509204047

(un-normalized negated logarithm of p-value is only 3.139394813377972)
(normalizer is 0.9939472470758418)
The p-value and its normalized negated logarithm are much different from before, but at least we have something to show. Perhaps now it is lunch time, so the user may click on the big X at the upper right corner of the Notepad editor to close it, and similarly close the dos box, and get something to eat. To top.
Setting notepad for programming in Windows XP.
If there is a mistake in a Java program, the compiler will report what kind of mistake it seems to be and what line of the file the mistake seems to be on. It is not really necessary for an XP user to count the lines from the top, because the new notepad editor on Windows XP can help with this. Let the user please open the Format menu of notepad and see if the Word Wrap is checked or unchecked. We wish it to be unchecked, so, if there is a check mark showing, please click on it. Then please open the View menu and see if the Status is checked or not. We wish it to be checked. If it is not checked, please click on it. After these two things are made right, the line number in the file and the character number in the line will show in the status bar at the bottom of the notepad window. It is then easy to find the offending mistake by moving the insert cursor up or down with the up and down arrows until the cursor is on the offending line. To top.

Interlude for non-beginners or non-Microsoft-Windows users.

There is nothing unique about the JaCo compiler for Java. Advanced users will know about Javac and maybe even about Janino, Jikes and Pizza. I picked on JaCo because it is small and easy to use. Actually, the JaCo compiler will work on Linux and Macintosh. It is a Java Archive file, and it will work any place where there is a Java version 1.2 or later. My statistical programs do not require more. Maybe yours do. Be warned: JaCo is not clever about recompiling library files whose source has changed. That is the reason that the b.bat file deletes the BlockTreat.class file. The deletion forces recompilation, just in case a statistician has altered the BlockTreat.java file and forgot to recompile it. Javac is clever and does not need this kind of help.

The Notepad editor exists only on Microsoft Windows, so users on other platforms will be using something else. For Microsoft Windows there are many other good freeware editors, but I am trying to keep things simple for beginners on Windows. I hope advanced users on Microsoft Windows know about Metapad. It can do block indentation, something many competitors can’t.

I do not know if the b.bat file will suit Linux, but Linux users can easily change it. I have no idea what Macintosh users will need to do about b.bat. To top.

Only two treatments: matching.

Lunch being over, I specialize to the case of only two treatments. They may be, for example, a proposed new drug and a placebo. Fourteen volunteers are matched into pairs by, say, height. That is, we ask the volunteers to stand in order of height, and we take them from the short end, two at a time. The two volunteers matched together are a block. For each block an honest coin is tossed to decide which volunteer gets the drug and which the placebo. Then the drug or placebo is administered for three weeks, and afterwards the improvement in dyne-seconds is calculated for each volunteer. Let the placebo be treatment 0 and the drug be treatment 1. Then the Temp.java file may look like this:
class Temp
{
	public static void main( String[] args )
	{

	int[][] y=
	{
	{12, 32},
	{ 0,  1},

	{13, 10},
	{ 0,  1},

	{19, 28},
	{ 0,  1},

	{15, 19},
	{ 0,  1},

	{22, 31},
	{ 0,  1},

	{24, 26},
	{ 0,  1},

	{29, 30},
	{ 0,  1}
	};

	int treatments=2;
	int seed=756486721;
	int many=(int)1e6;
	String sided="two";

	BlockTreat.report( y,treatments,seed,many,sided );
	}
}
Let the user “open a dos box” as before with Start and Run. This is a good time to make sure the downloaded copy of the present file is working. Just type
start BlockTreat.htm
at the prompt and push Enter. Now there will be a second copy of the present file. The user can close one of the copies. This drill is meant to prepare the user for the time when the Internet connection fails. Now at the dos prompt type
c:
cd \
cd myjavas
notepad Temp.java
(The myjavas folder still exists from before, so we do not try to make it again.) The Notepad editor will open with the file we were using before. It is easy to erase the old file by dropping down the Edit menu and clicking on Select All and then pushing the Backspace key. It is too tedious for the user to type in the new program, so the user may just select and copy it from the present file. Then click over to the Notepad editor and drop down the Edit menu and click on Paste. Then drop down the File menu and click on Save. Then click to the dos box and type
b
as before. The computer will print
Compile has succeeded.
p-value is 0.078511
normalized negated logarithm of p-value is 2.778705477495855

(un-normalized negated logarithm of p-value is only 2.5445165366221647)
(normalizer is 0.9157201283941977)
To top.
Right side instead of two-sided.
That p-value is a bit large. But, wait, we are using a two-sided alternative. We should rather be looking only to the right side. Let the user click to the Notepad editor and delete the "two" and replace it by "right". The file will then look like
class Temp
{
	public static void main( String[] args )
	{

	int[][] y=
	{
	{12, 32},
	{ 0,  1},

	{13, 10},
	{ 0,  1},

	{19, 28},
	{ 0,  1},

	{15, 19},
	{ 0,  1},

	{22, 31},
	{ 0,  1},

	{24, 26},
	{ 0,  1},

	{29, 30},
	{ 0,  1}
	};

	int treatments=2;
	int seed=756486721;
	int many=(int)1e6;
	String sided="right";

	BlockTreat.report( y,treatments,seed,many,sided );
	}
}
Saving the file again and typing
b
again at the prompt, we find that the p-value is much smaller now:
Compile has succeeded.
p-value is 0.039273
normalized negated logarithm of p-value is 3.4103368463736667

(un-normalized negated logarithm of p-value is only 3.2372180191160655)
(normalizer is 0.9492370299310214)
To top.
Supernumerary value(s).
There were meant to be 14 volunteers in the design of the experiment. Let us imagine now that a mistake has been made, and 15 volunteers have been gathered up. Coming to the tall end of the line, we find 3 volunteers standing before us instead of only 2. It would be rude to send one away, so let that last block, the block at the tall end, have three volunteers instead of only two, and let one of the volunteers in that block be chosen to have the drug by rolling an honest die: 1 dot or 2 dots for the first volunteer, 3 dots or 4 dots for the second, 5 dots or 6 dots for the third. Perhaps the resulting program looks like
class Temp
{
	public static void main( String[] args )
	{

	int[][] y=
	{
	{12, 32},
	{ 0,  1},

	{13, 10},
	{ 0,  1},

	{19, 28},
	{ 0,  1},

	{15, 19},
	{ 0,  1},

	{22, 31},
	{ 0,  1},

	{24, 26},
	{ 0,  1},

	{29, 28, 30},
	{ 0,  0,  1}
	};

	int treatments=2;
	int seed=756486721;
	int many=(int)1e6;
	String sided="right";

	BlockTreat.report( y,treatments,seed,many,sided );
	}
}
The computer prints
Compile has succeeded.
p-value is 0.03132
normalized negated logarithm of p-value is 3.639945969959652

(un-normalized negated logarithm of p-value is only 3.4634984078595346
)
(normalizer is 0.9515246754879514)
There, the p-value is a little smaller as a result of using the supernumerary volunteer. To top.

Only two blocks: independence.

Perhaps we have a set of points with u and v coordinates. Then the u’s are one block and their v’s are the other block. The program may look like this:
class Temp
{
	public static void main( String[] args )
	{

	int[][] y=
	{
	{12, 13, 23, 24, 27, 34, 45, 56, 45, 67, 78},
	{ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10},

	{23, 12,  3, 56, 65, 58, 97, 88, 89, 90, 65},
	{ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10}
	};

	int treatments=11;
	int seed=947642168;
	int many=(int)1e6;
	String sided="two";

	BlockTreat.report( y,treatments,seed,many,sided );
	}
}
The computer prints
Compile has succeeded.
p-value is 0.005334
normalized negated logarithm of p-value is 5.234876897176044

(un-normalized negated logarithm of p-value is only 5.2336538532223145
)
(normalizer is 0.9997663662436094)
Is that a one-sided or a two-sided inference? It depends. If we are asking whether the treatments are identical or not, it is two-sided. However, if we are asking whether the blocks are independent or not, it is one-sided: the alternative hypothesis asserts that the u’s are positively correlated to the v’s. This remark also applies to more than two blocks. To top.

Only one block: k-sample test.

Perhaps we have three samples and the question arises whether they come from the same population or from different populations. The three samples are three treatments. Here is an example:
class Temp
{
	public static void main( String[] args )
	{

	int[][] y=
	{
	{12, 23, 24, 25, 16, 24, 25, 26, 27, 28, 31, 23, 30},
	{ 0,  0,  0,  0,  0,  1,  1,  1,  1,  1,  2,  2,  2}
	};

	int treatments=3;
	int seed=978654230;
	int many=(int)1e6;
	String sided="two";

	BlockTreat.report( y,treatments,seed,many,sided );
	}
}
This leads to
Compile has succeeded.
p-value is 0.045333
normalized negated logarithm of p-value is 3.130378984753771

(un-normalized negated logarithm of p-value is only 3.0937200348824043
)
(normalizer is 0.9882892933891038)
This is necessarily a two-sided test, because k is greater than 2. If k were equal to 2, we could also do a right- or left-sided test. To top.

License, revision date, and e-mail address.

The Java™ language is the property of Sun. The JaCo compiler is apparently copyrighted by Matthias Zenger. The Metapad editor is copyrighted by Alexander Davidson.

The quote and table from Noether are copyrighted by his publisher, Houghton Mifflin. The rest of the present file is in the public domain. The date of this revision is 16 April 2008. Criticism both constructive and destructive comes to me, Harold Kaplan,

       at        dot        
smtw2gh  toadmail   com
To top.
Harold Kaplan’s statistics.htm
John C. Pezzullo’s page