I found that the predict
function is currently not implemented in cumulative link mixed models fitted using the clmm
function in ordinal
R package. While predict
is implemented for clmm2
in the same package, I chose to apply clmm
instead because the later allows for more than one random effects. Further, I also fitted several clmm
models and performed model averaging using model.avg
function in MuMIn
package. Ideally, I want to predict probabilities using the average model. However, while MuMIn
supports clmm
models, predict
will also not work with the average model.
Is there a way to hack the predict
function so that the function not only could predict probabilities from a clmm
model, but also predict using model averaged coefficients from clmm
(i.e. object of class "averaging")? For example:
require(ordinal)
require(MuMIn)
mm1 <- clmm(SURENESS ~ PROD + (1|RESP) + (1|RESP:PROD), data = soup,
link = "probit", threshold = "equidistant")
## test random effect:
mm2 <- clmm(SURENESS ~ PROD + (1|RESP) + (1|RESP:PROD), data = soup,
link = "logistic", threshold = "equidistant")
#create a model selection object
mm.sel<-model.sel(mm1,mm2)
##perform a model average
mm.avg<-model.avg(mm.sel)
#create new data and predict
new.data<-soup
##predict with indivindual model
predict(mm1, new.data)
I got the following error message:
In UseMethod("predict") :
no applicable method for predict
applied to an object of class "clmm"
##predict with model average
predict(mm.avg, new.data)
Another error is returned:
Error in predict.averaging(mm.avg, new.data) :
predict
for models 'mm1' and 'mm2' caused errors