0

When running the MCMCglmm function I get the following error message:

fit_mcmc <- MCMCglmm(exchange ~ assocSRI,random=~mm(ID1 + ID2), data=within_dyad) Error in buildZ(rmodel.terms[r], data = data, nginverse = names(ginverse)) : terms involved in mm/str structures must have identical levels in the same order

All of the terms have the same number of levels, so I'm just not sure how to rectify the issue. I have 41 "obs" of 6 variables.

1 Answers1

0

You need to order the levels before you fire up the MCMCglmm command. One way to do this would be:

library(data.table)
setDT(within_dyad)
within_dyad <- within_dyad[order(level),]

#replace name of the level variable appropriately, then run the MCMCglmm command.
vivek
  • 301
  • 3
  • 13
  • Unfortunately that didn't work. I appreciate your help though! Do you know of any other fixes that might help? – Emma Chereskin Jul 27 '21 at 16:11
  • @EmmaChereskin can you provide an example of the data? – vivek Jul 27 '21 at 16:17
  • 'data.frame': 41 obs. of 6 variables: $ ID1 : chr "CEB" "CEB" "DEE" "BIG" ... $ ID2 : chr "DEE" "DNG" "DNG" "FRE" ... $ assocSRI: num 0.389 0.176 0.264 0.596 0.346 ... $ vocalSRI: num 0.0104 0.0606 0.0256 0 0.0125 ... $ alliance: chr "KS" "KS" "KS" "PD" ... $ exchange: int 0 6 1 0 1 0 1 0 0 1 ... – Emma Chereskin Jul 27 '21 at 20:55