DEMO TOKEN SWAP TEST
DRAFT COPY ONLY.
© 2003-2006, G. William Moore, MD, PhD.
All Rights Reserved.
http://www.netautopsy.org/toknswap.htm
To perform a TOKEN SWAP TEST,
enter the cell totals in the four cell-boxes of the contingency table.
Then click on the SUBMIT button:
WHAT IS THE TOKEN SWAP TEST?
A 2 × 2 CONTINGENCY TABLE is a rectangular table,
consisting of two rows and two columns.
In a typical medical informatics application,
the rows represent Y/N for an existing standard ("gold standard"),
and columns represent a new test for a similar process.
The TOKEN SWAP TEST (TST) is a statistical-type significance test,
that is suitable for use on 2 x 2 contingency tables containing data
on retrospective medical databases. The TST does not depend upon
the usual statistical assumptions about repeated, random sampling
from a source population, as required by other contingency table tests,
such as the CHISQUARE TEST (CST) and
the FISHER EXACT TEST (FXT).
Token Swap Test: References.
1. Parfrey NA, Moore GW, Hutchins GM.
Is pain crisis a cause of death in sickle cell disease?
Am J Clin Pathol. 1985 Aug;84(2):209-212.
PMID: 4025226.
PubMed Entry
2. Moore GW, Hutchins GM, Miller RE.
Token swap test of significance for serial medical data bases.
Am J Med. 1986 Feb;80(2):182-190.
PMID: 3511687.
PubMed Entry
3. Moore GW, Hutchins GM, Miller RE.
A new paradigm for hypothesis testing in medicine,
with examination of the Neyman Pearson condition.
Theor Med. 1986 Oct;7(3):269-282.
PMID: 3798393.
PubMed Entry
4.
Heckering PS.
Token swap test revisited.
Comput Methods Programs Biomed. 2003 Mar;70(3):265-269.
PMID: 12581559.
PubMed Entry
Heckerling PS. Department of Medicine (M/C 787), University of Illinois,
840 South Wood Street, Chicago, IL 60612, USA. pshecker@uic.edu
"The token swap test measures the association between row and column
variables of a 2 x 2 table in sample misclassification space, and makes
no assumptions about repeated, random sampling from a source population."
5.
Osborn JF.
Chi 2 tests: how useful are they in the analysis
of medical research data?
Ann Ig. 1989 May-Aug;1(3-4):417-432.
PMID: 2483622
PubMed Entry
6.
Ryman N, Jorde PE.
Statistical power when testing for genetic differentiation.
Mol Ecol. 2001 Oct;10(10):2361-2373.
PMID: 11703649
PubMed Entry
7.
Kangave D.
More enlightenment on the essence of applying Fisher's Exact test
when testing for statistical significance using small sample data
presented in a 2 x 2 table.
West Afr J Med. 1992 Jul-Sep;11(3):179-184.
PMID: 1476961
PubMed Entry
8.
Karplus K, Karchin R, Shackelford G, Hughey R.
Calibrating E-values for hidden Markov models
using reverse-sequence null models.
Bioinformatics. 2005 Nov 15;21(22):4107-4115. Epub 2005 Aug 25.
PMID: 16123115
PubMed Entry
9.
Biggeri A, Bellini P, Terracini B; Italian MISA Group.
[Meta-analysis of the Italian studies
on short-term effects of air pollution]
Epidemiol Prev. 2001 Mar-Apr;25(2 Suppl):1-71. Italian.
PMID: 11515188
PubMed Entry
10.
Riou B, Landais P.
[Principles of tests of hypotheses in statistics: alpha, beta and P]
Ann Fr Anesth Reanim. 1998;17(9):1168-1180. French.
PMID: 9835991
PubMed Entry
11.
McConway KJ, Sims HJ.
A likelihood-based method for testing for nonstochastic variation
of diversification rates in phylogenies.
Evolution Int J Org Evolution. 2004 Jan;58(1):12-23.
PMID: 15058715
PubMed Entry
12.
Ohashi J, Tokunaga K.
Selecting a contingency table in a population-based association study:
allele frequency or positivity?
J Hum Genet. 1999;44(4):246-248.
PMID: 10429364
PubMed Entry
13.
Stolar MH.
Interpretation of research data: hypothesis testing.
Am J Hosp Pharm. 1980 Nov;37(11):1539-1545.
PMID: 7211860
PubMed Entry
14.
Cocatre-Zilgien JH, Delcomyn F.
Empirical evaluation of two-sample statistical tests for differences
of stepping phase during insect walking.
Biol Cybern. 1988;59(6):367-377.
PMID: 3207775
PubMed Entry
15.
Hansen JP.
Can't miss: conquer any number task by making
important statistics simple. Part 6. Tests of statistical significance
(z test statistic, rejecting the null hypothesis, p value),
t test, z test for proportions, statistical significance
versus meaningful difference.
J Healthc Qual. 2004 Jul-Aug;26(4):43-53.
PMID: 15352344
PubMed Entry
16.
Cerutti S.
Semantic models in medical record data-bases.
Med Inform (Lond). 1980 Jul-Sep;5(3):215-26.
PMID: 7464348
PubMed Entry
17.
Chow SL.
Precis of statistical significance: rationale, validity, and utility.
Behav Brain Sci. 1998 Apr;21(2):169-194; discussion 194-239. Review.
PMID: 10097013
PubMed Entry
18.
Risch N.
A new statistical test for linkage heterogeneity.
Am J Hum Genet. 1988 Feb;42(2):353-364.
PMID: 3341384
PubMed Entry
19.
McCann J, Horn L, Kaldor J.
An evaluation of Salmonella (Ames) test data in the published literature:
application of statistical procedures and analysis of mutagenic potency.
Mutat Res. 1984 Jul;134(1):1-47. Review.
PMID: 6379432
PubMed Entry
20.
Liu W, Weir BS.
Affected sib pair tests in inbred populations.
Ann Hum Genet. 2004 Nov;68(Pt 6):606-619.
PMID: 15598219
PubMed Entry
21.
Hirji KF, Tan SJ, Elashoff RM.
A quasi-exact test for comparing two binomial proportions.
Stat Med. 1991 Jul;10(7):1137-1153.
PMID: 1876801
PubMed Entry
22.
Gasko R.
Statistical hypothesis testing--how exact are exact p-values?
Bratisl Lek Listy. 2003;104(1):36-39.
PMID: 12830995
PubMed Entry
23.
Parker RA, Rothenberg RB.
Identifying important results from multiple statistical tests.
Stat Med. 1988 Oct;7(10):1031-1043.
PMID: 3206001
PubMed Entry
24.
Lu M, Ma CT.
Consistency in performance evaluation reports and medical records.
J Ment Health Policy Econ. 2002 Dec;5(4):141-152.
PMID: 14578548
PubMed Entry
25.
Bland JM.
Computer simulation of a clinical trial as an aid to teaching
the concept of statistical significance.
Stat Med. 1986 Mar-Apr;5(2):193-197.
PMID: 3520739
PubMed Entry
26.
Gaddis GM, Gaddis ML.
Introduction to biostatistics: Part 4, statistical inference techniques
in hypothesis testing.
Ann Emerg Med. 1990 Jul;19(7):820-825.
PMID: 2389867
PubMed Entry
27.
Ludbrook J, Dudley H.
Issues in biomedical statistics: statistical inference.
Aust N Z J Surg. 1994 Sep;64(9):630-6. Review.
PMID: 8085981
PubMed Entry
28.
Ottenbacher KJ.
The chi-square test: its use in rehabilitation research.
Arch Phys Med Rehabil. 1995 Jul;76(7):678-81.
PMID: 7605189
PubMed Entry
29.
Millenbaugh NJ, Wientjes MG, Au JL.
A pharmacodynamic analysis method to determine the relative importance
of drug concentration and treatment time on effect.
Cancer Chemother Pharmacol. 2000;45(4):265-272.
PMID: 10755313
PubMed Entry
30.
Nanivadekar AS, Kannappan AR.
Statistics for clinicians. 2. Nominal data (I).
J Assoc Physicians India. 1990 Dec;38(12):931-935, 974.
PMID: 2096131
PubMed Entry
31.
Machtay M, Glatstein E.
"Just Another Statistic"
Oncologist. 1998;3(3):III-IV.
PMID: 10388105
PubMed Entry
32.
Neely JG, Hartman JM, Forsen JW Jr, Wallace MS.
Tutorials in clinical research: VII. Understanding comparative statistics
(contrast)--part B: application of T-test, Mann-Whitney U, and chi-square.
Laryngoscope. 2003 Oct;113(10):1719-1725.
PMID: 14520096
PubMed Entry
33.
Yano Y, Beal SL, Sheiner LB.
Evaluating pharmacokinetic/pharmacodynamic models
using the posterior predictive check.
J Pharmacokinet Pharmacodyn. 2001 Apr;28(2):171-192.
PMID: 11381569
PubMed Entry
34.
Bejerano G, Friedman N, Tishby N.
Efficient exact p-value computation for small sample, sparse,
and surprising categorical data.
J Comput Biol. 2004;11(5):867-886.
PMID: 15700407
PubMed Entry
35.
Yarandi HN.
Hypothesis testing.
Clin Nurse Spec. 1996 Jul;10(4):186-8.
PMID: 8900794
PubMed Entry
36.
Schlenger WE, Corder LS.
Access to health care among aged Medicare beneficiaries.
Natl Med Care Util Expend Surv B. 1984 Apr;(3):1-31.
PMID: 10304188
PubMed Entry
37.
Johnson DC, Barnett GO.
MEDINFO--a medical information system.
Comput Programs Biomed. 1977 Sep;7(3):191-201.
PMID: 891158
PubMed Entry
38.
Kalemis A, Bailey DL, Flower MA, Lord SK, Ott RJ.
Statistical pixelwise inference models for planar data analysis:
an application to gamma-camera uniformity monitoring.
Phys Med Biol. 2004 Jul 21;49(14):3047-3066.
PMID: 15357181
PubMed Entry
39.
Lampl M, Johnson ML, Frongillo EA Jr.
Mixed distribution analysis identifies saltation and stasis growth.
Ann Hum Biol. 2001 Jul-Aug;28(4):403-411.
PMID: 11459238
PubMed Entry
40.
Lydersen S, Laake P.
Power comparison of two-sided exact tests for association in 2 x 2
contingency tables using standard, mid p and randomized test versions.
Stat Med. 2003 Dec 30;22(24):3859-71.
PMID: 14673943
PubMed Entry
41.
Fung KP, Lee J.
Extension of Fisher's exact test to 2-by-k contingency tables:
a computer program in BASIC.
Comput Methods Programs Biomed. 1989 Mar;28(3):195-196.
PMID: 2702812
PubMed Entry
42.
Hsueh HM, Liu JP, Chen JJ.
Unconditional exact tests for equivalence or noninferiority
for paired binary endpoints.
Biometrics. 2001 Jun;57(2):478-483.
PMID: 11414572
PubMed Entry
43.
Rabinowitz D.
Adjusting for population heterogeneity: a framework for characterizing
statistical information and developing efficient test statistics.
Genet Epidemiol. 2003 May;24(4):284-290.
PMID: 12687645
PubMed Entry
44.
Hamilton PW, Bartels PH, Anderson N, Thompson D, Montironi R, Sloan JM.
Case-based prediction of survival in colorectal cancer patients.
Anal Quant Cytol Histol. 1999 Aug;21(4):283-91.
PMID: 10560505
PubMed Entry
45.
Jenny JY.
[Beta risk: an unrecognized risk of statistical error]
Rev Chir Orthop Reparatrice Appar Mot. 2001 Apr;87(2):170-172. French.
PMID: 11319429
PubMed Entry
46.
Friedman RB.
Gathering diagnostic statistics.
J Med Syst. 1978;2(1):25-30.
PMID: 10297244
PubMed Entry
47.
Bethell CD, Read D, Brockwood K; American Academy of Pediatrics.
Using existing population-based data sets to measure the American Academy
of Pediatrics definition of medical home for all children and children
with special health care needs.
Pediatrics. 2004 May;113(5 Suppl):1529-1537.
PMID: 15121922
PubMed Entry
48.
Lee J, Lee HP, Fong NP.
A SAS procedure for exact probability testing of difference
between sample and population proportion.
Comput Biol Med. 1989;19(2):137-143.
PMID: 2706948
PubMed Entry
49.
Carney PA, Poor DA, Schifferdecker KE, Gephart DS, Brooks WB, Nierenberg DW.
Computer use among community-based primary care physician preceptors.
Acad Med. 2004 Jun;79(6):580-590.
PMID: 15165980
PubMed Entry
50.
Orf J, Thomas SH, Ahmed W, Wiebe L, Chamberlin P, Wedel SK, Houck C.
Appropriateness of endotracheal tube size and insertion depth
in children undergoing air medical transport.
Pediatr Emerg Care. 2000 Oct;16(5):321-327.
PMID: 11063359
PubMed Entry
51.
Blum RL.
Computer-assisted design of studies using routine clinical data.
Analyzing the association of prednisone and cholesterol.
Ann Intern Med. 1986 Jun;104(6):858-868.
PMID: 3486618
PubMed Entry
52.
Burton PR, Gurrin LC, Campbell MJ.
Clinical significance not statistical significance:
a simple Bayesian alternative to p values.
J Epidemiol Community Health. 1998 May;52(5):318-323.
PMID: 9764283
PubMed Entry
53.
Holmes AP, Blair RC, Watson JD, Ford I.
Nonparametric analysis of statistic images
from functional mapping experiments.
J Cereb Blood Flow Metab. 1996 Jan;16(1):7-22. Review.
PMID: 8530558
PubMed Entry
54.
Sadygov RG, Liu H, Yates JR.
Statistical models for protein validation using tandem mass spectral data
and protein amino acid sequence databases.
Anal Chem. 2004 Mar 15;76(6):1664-1671.
PMID: 15018565
PubMed Entry
55.
Piver MS.
Prophylactic Oophorectomy: Reducing the U.S. Death Rate
from Epithelial Ovarian Cancer. A Continuing Debate.
Oncologist. 1996;1(5):326-330.
PMID: 10388011
PubMed Entry
56.
Nurminen M.
Statistical significance--a misconstrued notion in medical research.
Scand J Work Environ Health. 1997 Jun;23(3):232-235.
PMID: 9243735
PubMed Entry
57.
Skipper BJ, McGuffee LJ.
Statistical significance tests for autoradiographic data.
Anat Rec. 1985 Feb;211(2):126-132.
PMID: 4038858
PubMed Entry
58.
Horn SD, Pozen MW.
An interpretation of implicit judgments in chart review.
J Community Health. 1977 Summer;2(4):251-258.
PMID: 617624
PubMed Entry
59.
Lun KC.
Harnessing information technology to revolutionise teaching,
research and consultative service in health statistics.
Ann Acad Med Singapore. 1990 Sep;19(5):640-648.
PMID: 2260818
PubMed Entry
60.
Teresi JA, Kleinman M, Ocepek-Welikson K.
Modern psychometric methods for detection of differential
item functioning: application to cognitive assessment measures.
Stat Med. 2000 Jun 15-30;19(11-12):1651-83.
PMID: 10844726
PubMed Entry
61.
Almeida R, Ledberg A.
Exact multivariate tests for brain imaging data.
Hum Brain Mapp. 2002 May;16(1):24-35.
PMID: 11870924
PubMed Entry
62.
Sim J, Reid N.
Statistical inference by confidence intervals:
issues of interpretation and utilization.
Phys Ther. 1999 Feb;79(2):186-195. Review.
PMID: 10029058
PubMed Entry
63.
Wassertheil-Smoller S, Bell B, Blaufox MD.
Computer-aided management of hypertensive patients.
Med Care. 1975 Dec;13(12):1044-1054.
PMID: 1195905
PubMed Entry
64.
Guyatt G, Jaeschke R, Heddle N, Cook D, Shannon H, Walter S.
Basic statistics for clinicians: 1. Hypothesis testing.
CMAJ. 1995 Jan 1;152(1):27-32. Review.
PMID: 7804919
PubMed Entry
65.
Liddell FD.
Simple exact analysis of the standardised mortality ratio.
J Epidemiol Community Health. 1984 Mar;38(1):85-88.
PMID: 6707569
PubMed Entry
66.
Loria A, Salas R.
[Patient data for evaluating reference values]
Rev Invest Clin. 1989 Oct-Dec;41(4):381-5. Spanish.
PMID: 2631172
PubMed Entry
67.
Stratmann WC, Goldberg AS, Haugh LD.
The utility for audit of manual and computerized
problem-oriented medical record systems.
Health Serv Res. 1982 Spring;17(1):5-26.
PMID: 6978872
PubMed Entry
68.
Boyle P, Flowerdew R, Williams A.
Evaluating the goodness of fit in models of sparse medical data:
a simulation approach.
Int J Epidemiol. 1997 Jun;26(3):651-656.
PMID: 9222792
PubMed Entry
69.
Lipsitz SR, Fitzmaurice GM.
The score test for independence in R x C contingency tables
with missing data.
Biometrics. 1996 Jun;52(2):751-762.
PMID: 8672711
PubMed Entry
70.
Jackson RA.
Interpretation of research data: selected statistical procedures.
Am J Hosp Pharm. 1980 Dec;37(12):1673-1680.
PMID: 7446542
PubMed Entry
71.
Andersen B.
[Principles of medical statistics. II. What is a significance test?]
Nord Med. 1969 Sep 11;82(37):1143-1145. Danish.
PMID: 5354524
PubMed Entry
72.
Lyon HC Jr, Healy JC, Bell JR, O'Donnell JF, Shultz EK,
Wigton RS, Hirai F, Beck JR.
Significant efficiency findings while controlling for
the frequent confounders of CAI research in the PlanAlyzer project's
computer-based, self-paced, case-based programs in anemia
and chest pain diagnosis.
J Med Syst. 1991 Apr;15(2):117-132.
PMID: 1757751
PubMed Entry
73.
Applegate KE, Tello R, Ying J.
Hypothesis testing III: counts and medians.
Radiology. 2003 Sep;228(3):603-608. Epub 2003 Jul 24.
PMID: 12881587
PubMed Entry
74.
Shao XM, Tsau Y.
Measure and statistical test for cross-correlation
between paired neuronal spike trains with small sample size.
J Neurosci Methods. 1996 Dec 28;70(2):141-152.
PMID: 9007753
PubMed Entry
75.
Mamelak AN, Lopez N, Akhtari M, Sutherling WW.
Magnetoencephalography-directed surgery in patients
with neocortical epilepsy.
J Neurosurg. 2002 Oct;97(4):865-873.
PMID: 12405375
PubMed Entry
76.
Sigurdsson G, Einarsson I, Josafatsson JI, Magnusson G, Olafsson O,
Sigvaldason H, Thorarinsson S, Tulinius H.
A medical record and information system for primary health care
in Iceland. The Egilsstadir Project.
Scand J Prim Health Care. 1984 Nov;2(4):159-161.
PMID: 6336200
PubMed Entry
77.
Sheehan TJ.
The medical literature. Let the reader beware.
Arch Intern Med. 1980 Apr;140(4):472-474.
PMID: 7362375
PubMed Entry
78.
Brookes ST, Whitley E, Peters TJ, Mulheran PA, Egger M, Davey Smith G.
Subgroup analyses in randomised controlled trials:
quantifying the risks of false-positives and false-negatives.
Health Technol Assess. 2001;5(33):1-56. Review.
PMID: 11701102
PubMed Entry
79.
Ritter L, Solomon K, Sibley P, Hall K, Keen P, Mattu G, Linton B.
Sources, pathways, and relative risks of contaminants in surface water
and groundwater: a perspective prepared for the Walkerton inquiry.
J Toxicol Environ Health A. 2002 Jan 11;65(1):1-142. Review.
PMID: 11809004
PubMed Entry
80.
Antezana MA, Hudson RR.
Type I error and the power of the s-test: old lessons from a new,
analytically justified statistical test for phylogenies.
Syst Biol. 1999 Jun;48(2):300-16.
PMID: 12066709
PubMed Entry
81.
Adlassnig KP, Kolarz G.
Representation and semiautomatic acquisition of medical knowledge
in CADIAG-1 and CADIAG-2.
Comput Biomed Res. 1986 Feb;19(1):63-79.
PMID: 3512161
PubMed Entry
82.
Chapireau F.
[Old and new long stay patients in French psychiatric institutions:
results from a national random survey with two-year follow-up]
Encephale. 2005 Jul-Aug;31(4 Pt 1):466-476. French.
PMID: 16389714
PubMed Entry
83.
Driscoll P, Lecky F, Crosby M.
An introduction to statistical inference--3.
J Accid Emerg Med. 2000 Sep;17(5):357-363.
PMID: 11005409
PubMed Entry
84.
Basu S, Basu A.
Comparison of several goodness-of-fit tests for the kappa statistic
based on exact power and coverage probability.
Stat Med. 1995 Feb 28;14(4):347-356.
PMID: 7746976
PubMed Entry
85.
Lee YJ, Quan H.
P-values after repeated significance testing:
a simple approximation method.
Stat Med. 1993 Apr 15;12(7):675-684.
PMID: 8511443
PubMed Entry
86.
Bowie J.
Methods of implementation of the MUMPS global data-base.
Med Inform (Lond). 1979 Jul-Sep;4(3):151-64.
PMID: 513890
PubMed Entry
87.
Burns T, Knapp M, Catty J, Healey A, Henderson J, Watt H, Wright C.
Home treatment for mental health problems: a systematic review.
Health Technol Assess. 2001;5(15):1-139. Review.
PMID: 11532236
PubMed Entry
88.
Shih JH, Louis TA.
Tests of independence for bivariate survival data.
Biometrics. 1996 Dec;52(4):1440-1449.
PMID: 8962462
PubMed Entry
89.
Krummenauer F.
[IV: Significance tests -- when to apply which one?]
Klin Monatsbl Augenheilkd. 2002 Nov;219(11):817-820. German.
PMID: 12494375
PubMed Entry
90.
Mozes B, Easterling MJ, Sheiner LB, Melmon KL, Kline R, Goldman ES, Brown AN.
Case-mix adjustment using objective measures of severity:
the case for laboratory data.
Health Serv Res. 1994 Feb;28(6):689-712.
PMID: 8113053
PubMed Entry
91.
Kelen GD, Brown CG, Ashton J.
Statistical reasoning in clinical trials: hypothesis testing.
Am J Emerg Med. 1988 Jan;6(1):52-61. Review.
PMID: 3275456
PubMed Entry
92.
Szurkowska M, Szybinski Z, Nazim A, Szafraniec K, Jedrychowski W.
[Prevalence of type II diabetes mellitus in population of Krakow]
Pol Arch Med Wewn. 2001 Sep;106(3):771-779. Polish.
PMID: 11928585
PubMed Entry
93.
Lachenbruch PA.
Comparisons of two-part models with competitors.
Stat Med. 2001 Apr 30;20(8):1215-1234.
PMID: 11304737
PubMed Entry
94.
Gordon D, Ott J.
Assessment and management of single nucleotide
polymorphism genotype errors in genetic association analysis.
Pac Symp Biocomput. 2001;:18-29.
PMID: 11262939
PubMed Entry
95.
Malay DS.
Some thoughts about data type, distribution,
and statistical significance.
J Foot Ankle Surg. 2006 Nov-Dec;45(6):357-359.
PMID: 17145459
PubMed Entry
96.
Osborne IG.
An inexpensive token.
J Appl Behav Anal. 1969 Summer;2(2):100.
PMID: 16795205
PubMed Entry
97.
Metcalf MM.
The Opalindae and their significance.
Proc Natl Acad Sci U S A. 1929 May 15;15(5):448-452.
PMID: 16577201
PubMed Entry
Token Swap Test: Perl Source Code.
### (C) COPYRIGHT G. WILLIAM MOORE, MD, PhD, BALTIMORE, MD, 2003.
### toknswap.cgi: PERL script to perform the TOKEN SWAP TEST.
### Last modified: 8/31/2003, G. William Moore, MD, PhD.
###
### CONSTANTS.
$amp=chr(38);
###
### PRINT HEADER.
print qq| <html><head><title> DEMO TOKEN SWAP TEST. </title></head><body> |;
print qq|\n<!-- Last modified: 8/31/2003, G. William Moore, MD, PhD.-->|;
print qq|\n <h2><center> MODAL LOGIC INFERENCE THEORY. |;
print qq|\n <br> DEMO TOKEN SWAP TEST <br> DRAFT COPY ONLY. |;
print qq|\n <br><a href="http://www.netautopsy.org/toknswap.htm"> |;
print qq|\n http://www.netautopsy.org/toknswap.htm </a> |;
print qq|\n <br> © 2003, G. William Moore, MD, PhD,|;
print qq|\n <br> Baltimore, MD, 2003. |;
print qq|\n <br> All Rights Reserved. </center></h2> |;
###
### CAPTURE INPUT DATA FROM ENVIRONMENTAL VARIABLES.
$inpdt=lc($ENV{'QUERY_STRING'}); chop; $srqln=$amp.$inpdt.$amp;
###
### SPLIT THE INPUT QUERY BY AMPERSAND TO OBTAIN ARRAY @qin.
($scr,$clahi)=split(/cla=/,$srqln,2); ($clax,$scr)=split(/\&/,$clahi,2);
($scr,$clbhi)=split(/clb=/,$srqln,2); ($clbx,$scr)=split(/\&/,$clbhi,2);
($scr,$clchi)=split(/clc=/,$srqln,2); ($clcx,$scr)=split(/\&/,$clchi,2);
($scr,$cldhi)=split(/cld=/,$srqln,2); ($cldx,$scr)=split(/\&/,$cldhi,2);
$obs[1]=$clax-0; $obs[2]=$clbx-0; $obs[3]=$clcx-0; $obs[4]=$cldx-0;
$oba=$clax-0; $obb=$clbx-0; $obc=$clcx-0; $obd=$cldx-0;
###
### CALCULATE MARGINAL TOTALS.
$mgn[1]=$obs[1]+$obs[2]; $mgn[2]=$obs[3]+$obs[4];
$mgn[3]=$obs[1]+$obs[3]; $mgn[4]=$obs[2]+$obs[4];
$gtot=$obs[1]+$obs[2]+$obs[3]+$obs[4];
###
### ZERO THE PROBABILITY DISTRIBUTION.
$iii=-1; while($iii<1005){$iii++; $pdsn[$iii]=0;};
###
### PRINT MARGINAL TOTALS.
$ao=$obs[1]; $vx=$mgn[1]; $wx=$mgn[2]; $xx=$mgn[3]; $yx=$mgn[4]; $zx=$gtot;
###
### ERROR IF GRAND TOTAL, $gtot, IS GREATER THAN 1000.
if($gtot>1000){print qq|\n<br> ERROR: The grand total, $gtot, is too large.|;
print qq|\n It must be at most 500. <br> Job Terminated. |;
print qq|\n <hr> Last modified: 8/31/2003, G. William Moore, MD, PhD. |;
print qq| <br></body></html><br><br> \n\n\n\n |; exit;};
###
### ERROR IF MORE THAN ONE ZERO CELL VALUE.
$iii=0; $clv=0; while($iii<4){$iii++; $vli=$obs[$iii];if($vli<1){$clv++;};};
if($clv>1){print qq|\n<br> ERROR: At least three cell totals must be |;
print qq|\n greater than zero. <br> Job Terminated. |;
print qq|\n <hr> Last modified: 8/31/2003, G. William Moore, MD, PhD. |;
print qq| <br></body></html><br><br> \n\n\n\n |; exit;};
###
### CALCULATE EXPECTED VALUES.
$exv[1]=($mgn[1]*$mgn[3])/$gtot; $exv[2]=($mgn[1]*$mgn[4])/$gtot;
$exv[3]=($mgn[2]*$mgn[3])/$gtot; $exv[4]=($mgn[2]*$mgn[4])/$gtot;
###
### CALCULATE EXPECTED VALUES.
$exd[1]=int((10*$exv[1]))/10; $exd[2]=int((10*$exv[2]))/10;
$exd[3]=int((10*$exv[3]))/10; $exd[4]=int((10*$exv[4]))/10;
$ax=int($exv[1]); $bx=$vx-$ax; $cx=$xx-$ax; $dx=$yx-$bx;
###
### UNARY PROBABILITY DISTRIBUTION.
$pdsn[$ax]=1; $itera=0; while($itera<$gtot){$itera++;
$iii=0; while($iii<$gtot){$iii++; $ai=$iii; $bi=$vx-$ai; $ci=$xx-$ai;
$di=$yx-$bi; $ah=$iii-1; $bh=$vx-$ah; $ch=$xx-$ah; $dh=$yx-$bh;
$qh=($bh*$ch)/(($bh*$ch)+($ah*$dh)); $aj=$iii+1; $bj=$vx-$aj;
$cj=$xx-$aj; $dj=$yx-$bj; $qj=($aj*$dj)/(($bj*$cj)+($aj*$dj));
$pdsx[$iii]=($qh*$pdsn[$ah])+($qj*$pdsn[$aj]);};
$iii=0; while($iii<$gtot){$iii++;$pdsn[$iii]=$pdsx[$iii];};
if($pdsn[$ao]>0){$itera=$gtot;};}; $tknsw=$pdsn[$ao];
$itknswd=int($tknsw*10000000);
$tknswd=$itknswd/10000000;
if($itknswd<1){$tknswd="<0.00000001";};
###
### CALCULATE CHISQUARE TERMS.
$chv[1]=(($obs[1]-$exv[1])*($obs[1]-$exv[1]))/$exv[1];
$chv[2]=(($obs[2]-$exv[2])*($obs[2]-$exv[2]))/$exv[2];
$chv[3]=(($obs[3]-$exv[3])*($obs[3]-$exv[3]))/$exv[3];
$chv[4]=(($obs[4]-$exv[4])*($obs[4]-$exv[4]))/$exv[4];
$chisq=$chv[1]+$chv[2]+$chv[3]+$chv[4];
###
### PRINT INPUT DATA.
print qq|\n <hr><b>INPUT DATA</b>(exp. value): |;
print qq|\n <br> __________________________ |;
print qq|\n <br> <b>$obs[1]</b>($exd[1])|;
print qq|\n \| <b>$obs[2]</b>($exd[2])|;
print qq|\n <br> __________________________ |;
print qq|\n <br> <b>$obs[3]</b>($exd[3])|;
print qq|\n \| <b>$obs[4]</b>($exd[4])|;
print qq|\n <br> __________________________ |;
###
### PRINT OUTPUT VALUES: CHISQUARE, TOKENSWAP.
print qq|\n<hr><b>CHISQUARE:</b> $chisq, 1 d.f. |;
print qq|\n<br><b>TOKENSWAP, p: </b>$tknswd |;
###
### REPEAT TOKEN SWAP TEST.
print qq|\n<hr> To repeat the <b> TOKEN SWAP TEST, </b> enter |;
print qq|\n the revised cell totals in the four cell-boxes |;
print qq|\n of the contingency table. Then click |;
print qq|\n on the <b> SUBMIT </b> button: |;
print qq|\n<form method="get" |;
print qq|\n action="http://www.netautopsy.org/cgi-bin/toknswap.cgi"> |;
print qq|\n<br> __________________________ |;
print qq|\n<br> |;
print qq|\n<input type="text" name="aaaa" size=4 maxlength=4 value=$obs[1]>|;
print qq|\n |;
print qq|\n<input type="text" name="bbbb" size=4 maxlength=4 value=$obs[2]>|;
print qq|\n<br> __________________________ |;
print qq|\n<br> |;
print qq|\n<input type="text" name="cccc" size=4 maxlength=4 value=$obs[3]>|;
print qq|\n |;
print qq|\n<input type="text" name="dddd" size=4 maxlength=4 value=$obs[4]>|;
print qq|\n<br> __________________________ |;
print qq|\n<br><br><input type="submit" value="SUBMIT"><br></form> |;
###
### END JOB.
print qq| <br></body></html><br><br> \n\n\n\n |; exit;
Last Updated: December 21, 2006, by G. William Moore, MD, PhD.