The Scheirer–Ray–Hare test is a nonparametric test used for a two-way factorial design. It appears to be not well documented, but it is discussed in Sokal and Rohlf (1995). In my experience, in some cases the Scheirer–Ray–Hare test is less likely to find the interaction effect significant than would an ordinary least squares analysis of variance, aligned ranks transformation ANOVA, normal scores ANOVA, or permutation tests. In some cases, these tests may be preferred alternatives.
It has been suggested that the observations should be balanced and that each cell in the interaction should have at least five observations.
Note that for unbalanced designs, the scheirerRayHare function uses a type-II sum-of-squares approach by default. There is an option to use type-I sum-of-squares.
Appropriate data
• Two-way data arranged in a factorial design
• Dependent variable is ordinal, interval, or ratio
• There are two treatment or group independent variables. Each is a factor with two or more levels
• Observations are independent. That is, they are not paired or repeated measures
Post-hoc tests
Appropriate post-hoc tests might be Dunn test for each significant factor or interaction
Packages used in this chapter
The packages used in this chapter include:
• rcompanion
• FSA
The following commands will install these packages if they are not already installed:
if(!require(rcompanion)){install.packages("rcompanion")}
if(!require(FSA)){install.packages("FSA")}
Scheirer–Ray–Hare test examples
Midichlorians example
### Assemble the data
Location = c(rep("Olympia" , 6), rep("Ventura", 6),
rep("Northampton", 6), rep("Burlington", 6))
Tribe = c(rep(c("Jedi", "Sith"), 12))
Midichlorians = c(10, 4, 12, 5, 15, 4, 15, 9, 15, 11, 18, 12,
8, 13, 8, 15, 10, 17, 22, 22, 20, 22, 20, 25)
Data = data.frame(Tribe, Location, Midichlorians)
str(Data)
### Scheirer–Ray–Hare test
library(rcompanion)
scheirerRayHare(Midichlorians ~ Tribe + Location,
data = Data)
DV: Midichlorians
Observations: 24
D: 0.9917391
MS total: 50
Df Sum Sq H p.value
Tribe 1 8.17 0.1647 0.68487
Location 3 746.58 15.0560 0.00177
Tribe:Location 3 315.58 6.3642 0.09517
Residuals 16 70.17
### Post-hoc test
### Order groups by median
Data$Location = factor(Data$Location,
levels=c("Burlington", "Ventura",
"Northampton", "Olympia"))
levels(Data$Location)
### Dunn test
library(FSA)
DT = dunnTest(Midichlorians ~ Location,
data=Data,
method="bh") # Adjusts
p-values for multiple comparisons;
# See
?dunnTest for options
DT
### Compact letter display
PT = DT$res
PT
library(rcompanion)
cldList(P.adj ~ Comparison,
data = PT,
threshold = 0.05)
Group Letter MonoLetter
1 Burlington a a
2 Northampton b b
3 Olympia b b
4 Ventura b b
Groups sharing a letter not signficantly different
(alpha = 0.05).
Example from Sokal and Rohlf
### Assemble the data
Value = c(709,679,699,657,594,677,592,538,476,508,505,539)
Sex = c(rep("Male",3), rep("Female",3),
rep("Male",3), rep("Female",3))
Fat = c(rep("Fresh", 6), rep("Rancid", 6))
Sokal = data.frame(Value, Sex, Fat)
str(Sokal)
### Scheirer–Ray–Hare test
library(rcompanion)
scheirerRayHare(Value ~ Sex + Fat,
data=Sokal)
DV: Value
Observations: 12
D: 1
MS total: 13
Df Sum Sq H p.value
Sex 1 8.333 0.6410 0.42334
Fat 1 108.000 8.3077 0.00395
Sex:Fat 1 5.333 0.4103 0.52184
Residuals 8 21.333
Example from Real Statistics Using Excel
This example from
real-statistics.com/two-way-anova/scheirer-ray-hare-test/.
### Assemble the data
Wheat = c(123,156,112,100,168,135,130,176,120,155,156,180,147,146,193)
Corn = c(128,150,174,116,109,175,132,120,187,184,186,138,178,176,190)
Soy = c(166,178,187,153,195,140,145,159,131,126,185,206,188,165,188)
Rice = c(151,125,117,155,158,167,183,142,167,168,175,173,154,191,169)
Yield = c(Wheat, Corn, Soy, Rice)
Fert = rep(c(rep("Blend X",5), rep("Blend Y",5),
rep("Blend Z",5)),4)
Crop = c(rep("Wheat",15), rep("Corn",15), rep("Soy",15),
rep("Rice",15))
Real.stats = data.frame(Yield, Fert, Crop)
str(Real.stats)
### Scheirer–Ray–Hare test
library(rcompanion)
scheirerRayHare(Yield ~ Fert + Crop,
data=Real.stats)
DV: Yield
Observations: 60
D: 0.9997221
MS total: 305
Df Sum Sq H p.value
Fert 2 4004.4 13.1329 0.001407
Crop 3 1339.0 4.3915 0.222175
Fert:Crop 6 2893.6 9.4900 0.147839
Residuals 48 9752.9
### Post-hoc test
### Order groups by median
Real.stats$Fert = factor(Real.stats$Fert,
levels=c("Blend Z", "Blend Y",
"Blend X"))
levels(Real.stats$Fert)
### Dunn test
library(FSA)
DT = dunnTest(Yield ~ Fert,
data=Real.stats,
method="bh") # Adjusts
p-values for multiple comparisons;
# See
?dunnTest for options
DT
### Compact letter display
PT = DT$res
PT
library(rcompanion)
cldList(P.adj ~ Comparison,
data = PT,
threshold = 0.05)
Group Letter MonoLetter
1 BlendX a a
2 BlendY a a
3 BlendZ b b
Groups sharing a letter not signficantly different
(alpha = 0.05).
Example with unbalanced design
The following example is taken from Klasson in the References section. Note that because the design is not balanced, type-I sum-of-square results differ from those with type-II sum-of-squares.
### Assemble the data
Gambling = c(3.0, 2.8, 3.0, 5.1, 4.7, 4.9, 5.2, 4.9, 5.0, 2.1, 2.0, 1.9,
1.8, 2.3, 2.1, 2.4, 3.9, 3.8, 4.1, 1.2, 1.1, 1.3, 1.1, 1.0)
Gender = c(rep("Male", 13), rep("Female", 11))
Athletic = c(rep("Current", 3), rep("Former", 6),
rep("Non", 4),
rep("Current", 3), rep("Former", 3),
rep("Non", 5))
ARS = data.frame(Gender, Athletic, Gambling)
### Use type-II sum-of-squares
library(rcompanion)
scheirerRayHare(Gambling ~ Gender + Athletic, data=ARS)
DV: Gambling
Observations: 24
D: 0.9982609
MS total: 50
Df Sum Sq H p.value
Gender 1 100.89 2.0214 0.15510
Athletic 2 850.69 17.0434 0.00020
Gender:Athletic 2 2.18 0.0437 0.97837
Residuals 18 39.85
### Use type-I sum-of-squares
library(rcompanion)
scheirerRayHare(Gambling ~ Gender + Athletic, data=ARS, type=1)
DV: Gambling
Observations: 24
D: 0.9982609
MS total: 50
Df Sum Sq H p.value
Gender 1 255.27 5.1143 0.02373
Athletic 2 850.69 17.0434 0.00020
Gender:Athletic 2 2.18 0.0437 0.97837
Residuals 18 39.85
References
Klasson, K.T. 2020. Two-way ANOVA for Unbalanced Data: The Spreadsheet Way. USDA–ARS. www.ars.usda.gov/ARSUserFiles/60540520/Two-wayANOVAspreadsheet.pdf.
Sokal, R.R. and F.J. Rohlf. 1995. Biometry, 3rd ed. W.H. Freeman. New York.