1

I have tried a few suggestions on here and other sites but none seem to work

My model looks like

model = glmer(cbind(live, dead)~cont1*cont2+ (1|random),
                family = binomial, data = all) 

cont1 and cont2 are both continuous explanatory variables, random is a random factor with about 8 levels

For a standard glm (i.e.)

model = glm(cbind(live, dead)~cont1*cont2, 
                   family = binomial, data = all) 

I had used this code to get predictions

plot(-100,-100,xlim=c(0,30),ylim=c(0,100),xlab='cont1',
   ylab='alive(%)',col.axis='black',col.lab='black')
   preds = predict(model,data.frame(cont1=0:30,cont2=0),type='response')*100
   lines(0:30,preds,lty=5,lwd=3,col='magenta')   
   preds = predict(model,data.frame(cont1=0:30,cont2=-0.25),type='response')*100
   lines(0:30,preds,lty=3,lwd=3,col='purple')

etc.

I have been able to get predictions using glmer, but I cannot get predictions for each level of cont2 such as in the standard glm.

I have tried to copy the code suggested here glmer - predict with binomial data (cbind count data)

predframe <- data.frame(cont1=(all$cont1), cont2=(all$cont2))
predframe$AlivePercent= predict(m1, newdata= predframe,type="response",REform=NULL)

However I get the error message

Error in `[[<-.data.frame`(`*tmp*`, i, value = integer(0)) : 
  replacement has 0 rows, data has 224

If anyone could suggest how I address this problem that would be hugely appreciated

Cheers, Dylan

Community
  • 1
  • 1

0 Answers0