[banner]

Summary and Analysis of Extension Program Evaluation in R

Salvatore S. Mangiafico

Scheirer–Ray–Hare Test

The Scheirer–Ray–Hare test is a nonparametric test used for a two-way factorial design.   It appears to be not well documented nor well-regarded.  In my experience, the Scheirer–Ray–Hare test is less likely to find the interaction effect significant than would an ordinary least squares analysis of variance.

 

It has been suggested that the observations should be balanced and that each cell in the interaction should have at least five observations.

 

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 or pairwise Mann–Whitney tests 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 www.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).


References

 

Sokal, R.R. and F.J. Rohlf. 1995.  Biometry, 3rd ed.  W.H. Freeman. New York.