Multiple Factor Nonparametric Tests - R#

Aligned Rank Transform for Between Subjects (ART)#

  • Samples: ≥2

  • Levels: ≥2

  • Between or Within Subjects: Between

  • Reporting: “Figure 10 shows boxplots for all levels of X1×X2. A nonparametric analysis of variance based on the Aligned Rank Transform indicated no statistically significant effect on Y of X1 (F(1, 56) = 1.98, n.s.), or of X2 (F(1, 56) = 0.81, n.s.), but there was a statistically significant X1×X2 interaction (F(1, 56) = 13.65, p < .001).”

# Example data
# df has subjects (S), two between-Ss factors (X1,X2) each w/levels (a,b), and continuous response (Y)
df <- read.csv("data/2F2LBs.csv")
head(df, 20)
A data.frame: 20 × 4
SX1X2Y
<int><chr><chr><dbl>
1 1aa 8.236467
2 2ab12.965256
3 3ba10.782947
4 4bb 7.385979
5 5aa12.041681
6 6ab12.779924
7 7ba11.581190
8 8bb 9.529899
9 9aa12.658464
1010ab14.159172
1111ba 9.548367
1212bb 7.859910
1313aa10.395678
1414ab10.385932
1515ba12.512831
1616bb 8.080291
1717aa10.252031
1818ab12.052793
1919ba13.768800
2020bb11.417579
# library(ARTool)
# df$S = factor(df$S) # Subject id is nominal (unused)
# df$X1 = factor(df$X1) # X1 is a 2-level factor
# df$X2 = factor(df$X2) # X2 is a 2-level factor
# m = art(Y ~ X1*X2, data=df)
# anova(m)

Generalized Linear Model (GLM)#

  • Samples: ≥2

  • Levels: ≥2

  • Between or Within Subjects: Between

  • Reporting: “The median of ‘a’ was 11.92 (IQR = 2.35) and of ‘b’ was 10.74 (IQR = 2.29). This difference was statistically significant according to a Wilcoxon signed-rank test (Z = 2.11, p < .05).”

See Generalized Linear (Mixed) Models: Distributions and Canonical Links

Aligned Rank Transform for Within Subjects (ART)#

  • Samples: ≥2

  • Levels: ≥2

  • Between or Within Subjects: Within

  • Reporting: “Figure 11 shows boxplots for all levels of X1×X2. A nonparametric analysis of variance based on the Aligned Rank Transform indicated no statistically significant effect on Y of X1 (F(1, 42) = 1.85, n.s.) or of the X1×X2 interaction (F(1, 42) = 1.93, n.s.), but there was a statistically significant effect of X2 (F(1, 42) = 24.97, p < .0001).”

# Example data
# df has subjects (S), two within-Ss factors (X1,X2) each w/levels (a,b), and continuous response (Y)
df <- read.csv("data/2F2LWs.csv")
head(df, 20)
A data.frame: 20 × 4
SX1X2Y
<int><chr><chr><dbl>
11aa13.177771
21ab13.299755
31ba 9.909350
41bb16.457684
52aa11.770180
62ab14.804296
72ba 9.819264
82bb13.907344
93aa 8.535872
103ab12.210064
113ba12.448765
123bb12.204888
134aa10.287867
144ab16.082883
154ba 9.196968
164bb 9.614437
175aa 9.040155
185ab16.885613
195ba10.184381
205bb14.435134
# library(ARTool)
# df$S = factor(df$S) # Subject id is nominal
# df$X1 = factor(df$X1) # X1 is a 2-level factor
# df$X2 = factor(df$X2) # X2 is a 2-level factor
# m = art(Y ~ X1*X2 + (1|S), data=df) # S is a random factor
# anova(m)

Generalized Linear Mixed Model (GLMM)#

  • Samples: ≥2

  • Levels: ≥2

  • Between or Within Subjects: Within

  • Reporting: “The median of ‘a’ was 11.92 (IQR = 2.35) and of ‘b’ was 10.74 (IQR = 2.29). This difference was statistically significant according to a Wilcoxon signed-rank test (Z = 2.11, p < .05).”

See Generalized Linear (Mixed) Models: Distributions and Canonical Links