1
$\begingroup$

In my study, participants ranked a total of 5 designs (different lamp types) in their order of preference (absolute favourite, second favourite, etc.). Participants ranked all lamps, and lamps were presented in random order to participants. Participants could not give the same rank to two lamps. I now want to evaluate whether there are any differences in the participant preferences. My second step will be to test whether there are any differences between male / female participants.

To answer my initial question, I believe a Friedman Test is appropriate. As far as I understood, Friedman would transform my data to rank data (which it already is, as participants have indicated their preference order). As shown in the code below, using both 'raw' numeric values and 'ranked' numeric values (done manually by me) produce the same Friedman Test results. I previously made an error in creating the ranked table, but the code below showcases that the comparison between raw and ranked values produces identical results.

My question now focuses on the comparison between two groups (e.g., man/woman) in their lamp (order) preference. I'd like to know whether there is a significant difference between participant groups in their preference, but have no idea how to tackle this. Imagine that the group (e.g., gender) is an additional column in the dataframe.

I came across the Scheirer-Ray-Hare test online, although the test does not seem to be universally accepted. Thank you very much in advance for your time!

--

# load data. Letters are lamp designs (columns), numbers are individual participants (rows)
y <- structure(c(3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 
16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 
26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 
28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65), .Dim = c(6L, 
6L), .Dimnames = list(c("1", "2", "3", "4", "5", "6"), c("A", 
"B", "C", "D", "E", "F")))

y_ranked <- structure(c(6, 6, 5, 6, 5, 6, 2, 4, 4, 3, 2, 4, 4, 1, 3, 4, 4, 
1, 5, 5, 6, 5, 6, 5, 3, 3, 2, 1, 3, 3, 1, 2, 1, 2, 1, 2), .Dim = c(6L, 
6L), .Dimnames = list(c("1", "2", "3", "4", "5", "6"), c("A", 
"B", "C", "D", "E", "F")))


friedman.test(y)
> Friedman chi-squared = 23.333, df = 5, p-value = 0.0002915

friedman.test(y_ranked)
> Friedman chi-squared = 23.333, df = 5, p-value = 0.0002915
$\endgroup$
11
  • $\begingroup$ Your code doesn't run in a clean session; i.e. your example is NOT reproducible (reproducible means if I paste your code then what I see reproduces what you see). R does not come with a function called freidmanTest. Whatever package it's from (scmamp? PMCMRplus? something else?), try reading the help on that function (which should include examples for you to follow). However, R does come with a test called friedman.test and the example in the help there shows the two main ways to call it (the last two lines), each matching the calling syntax given at the top of the friedman.test help $\endgroup$
    – Glen_b
    Commented Aug 19, 2019 at 23:20
  • $\begingroup$ Having trouble making sense of what you're doing and asking: Please clarify-- (1) Are the letters A, B, C, ... the Groups (lamp designs) and the numbers 1, 2, 3, ... the Participants? Is that 5 or 6 of each? (2) Can you clarify exactly how you got matrix z from matrix y---with a row or col as an example to show it's right? (3) Do you know the difference btw friedman.test and friedmanTest? Does your test procedure expect matrix columns to be Groups or Participants? $\endgroup$
    – BruceET
    Commented Aug 19, 2019 at 23:26
  • $\begingroup$ @Glen_b Apologies, I tested both base-R and PMCMRplus Friedman test, have now changed my code back to base-R and it should be reproducible. Sorry for the oversight on my part. Thank you for your time. $\endgroup$
    – WalterB
    Commented Aug 20, 2019 at 6:22
  • 1
    $\begingroup$ Your ranks don't seem to relate to the original data. Please explain how you got them. $\endgroup$
    – Glen_b
    Commented Aug 20, 2019 at 8:58
  • 1
    $\begingroup$ I think you may be looking for a technique called ANACONDA. See my answer to a similar question here stats.stackexchange.com/questions/251691/… $\endgroup$
    – mdewey
    Commented Aug 20, 2019 at 10:22

1 Answer 1

1
$\begingroup$

It sounds like Friedman's test is an appropriate approach to answer the first question. And, yes, I would avoid the Scheirer-Ray-Hare test. It appears to not be well regarded from a theoretical standpoint, but also in my experience it will fail to find a significant interaction effect in cases where other tests will find one. For a model more complex than can be handled by Friedman or Kruskal-Wallis, you might look into aligned ranks transformation (ART) anova. The ARTool software for R and Windows makes the process relatively easy, but be sure to read the complete documentation. For example, all interactions should be included in the model, and handling post-hoc comparisons of interactions can be tricky. ART anova is a rank based method and allows for relatively complex models including repeated measures. Below I've given you the code of a possible model. There are some resources for ART at the bottom of this page, that you may want to review. (Caveat: I am the author of that page.) (At the time of writing this R code will run at rdrr.io).

### Load data. Letters are lamp designs (columns), 
###  numbers are individual participants (rows)

y <- structure(c(3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 
16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 
26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 
28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65), .Dim = c(6L, 
6L), .Dimnames = list(c("1", "2", "3", "4", "5", "6"), c("A", 
"B", "C", "D", "E", "F")))

y

### Transform data to long format

Data = reshape(as.data.frame(y), varying = LETTERS[1:6], 
       timevar = "Lamp", v.names="Score",
       times = LETTERS[1:6], 
       direction = 'long')

Data$Gender[Data$id==1]="Female"
Data$Gender[Data$id==2]="Female"
Data$Gender[Data$id==3]="Female"
Data$Gender[Data$id==4]="Male"
Data$Gender[Data$id==5]="Male"
Data$Gender[Data$id==6]="Male"

Data$Lamp   = factor(Data$Lamp)
Data$Gender = factor(Data$Gender)
Data$id     = factor(Data$id)

Data


### ART anova

if(!require(ARTool)){install.packages("ARTool")}
library(ARTool)

model = art(Score ~ Lamp + Gender + Lamp:Gender,
                data = Data)

anova(model)

### Post-hoc comparisons
### Be sure to read documentation about this topic.

model.lm = artlm(model, "Lamp")

if(!require(emmeans)){install.packages("emmeans")}
library(emmeans)

marginal = emmeans(model.lm, ~ Lamp)

CLD(marginal, adjust = "tukey", Letters=letters)
$\endgroup$
1
  • $\begingroup$ This is exactly what I was I looking for, thank you very much! Really appreciated. $\endgroup$
    – WalterB
    Commented Aug 23, 2019 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.