1

Background For my thesis, I have conducted a pairwise cafeteria experiment in which pairs of fruit are presented to birds and it is recorded which they chose. From the research, I have found that the appropriate model to analyse this data is a Bradley Terry model. I am not a statistician and am relatively new to R so any help would be appreciated

Issue Using the package BradleyTerry2

my data frame looks like this in which fruit1 and Fruit2 represent Player 1 and 2 and the coresponding frequencys of wins and looses for player1 vsplayer 2

Following https://cran.r-project.org/web/packages/BradleyTerry2/vignettes/BradleyTerry.pdf

I am using the code

R>prefModel<-BTm(cbind(win1,win2),fruit1,fruit2,~fruit,id="fruit",data=df)

This produces an error of

Error in Diff(player1, player2, formula, id, data, separate.ability, refcat,  : 
'player1$fruit' and 'player2$fruit' must be factors with the same levels

Trying something else also produced the same error

BTm(outcome=cbind(win1,win2),player1=fruit1,player2=fruit2,
formula=~fruit,id="fruit",)

(!is.factor(df$fruit1) || !is.factor(df$fruit2) ||
!identical(levels(df$fruit1), levels(df$fruit2)))

returned [TRUE]

Heather Turner
  • 3,264
  • 23
  • 30
Lwes
  • 11
  • 1

0 Answers0