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
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]