runehaubo / ordinal

R package ordinal: Regression Models for Ordinal Data
Other
33 stars 12 forks source link

ranef function overwritten by loading ordinal package #48

Closed dwarton closed 2 years ago

dwarton commented 2 years ago
library(lme4)
fm1 <- lmer(Reaction ~ Days + (Days | Subject), data=sleepstudy)
ranef(fm1)
library(ordinal)
ranef(fm1)

The first call to ranef works, the second returns an error

Error in UseMethod("ranef") : 
  no applicable method for 'ranef' applied to an object of class "c('lmerMod', 'merMod')"

The reason for the error is that generic ranef function, rather than being imported to the ordinal package from nlme, is defined inside the package (at line 29 of clmm.ranef.R). Can you please delete these lines and instead add to NAMESPACE importFrom(nlme, ranef) (which is currently actually at lines 42-43 of the file, but it has been commented out).

runehaubo commented 2 years ago

Thanks. Should be fixed in the next version (though fixing it was not as easy as you described it ;-)