4
Edited
When we use a traditional logistic regression and make a prediction in R for example:
library(dplyr)
n = 300
xx<-c("r1","r2","r3","r4","r5")
xxx<-c("e1","e2","e3")
p=0.3
df1 <- data_frame(
xx1 = runif(n, min = 0, max = 10),
xx2 = runif(n, min = 0, max = 10),
xx3 = runif(n, min = 0, max = 10),
School = factor(sample(xxx, n,re=TRUE)),
Rank = factor(sample(xx, n,re=TRUE)),
yx = as.factor(rbinom(n, size = 1, prob = p))
)
df1
mm<-glm(yx ~ xx1 + xx2 + xx3 + School + Rank,binomial,df1)
n11 = data.frame(School="e3",Rank="r2",xx1=8.58,xx2=8.75,xx3=7.92)
predict(mm, n11, type="response") #No meu caso especifico
or Predict(mm, N11)
depending on what we’re interested in, no problem.
But when we work with GLMM, for example
library(lme4)
mm2 <- glmer(yx ~ xx1 + xx2 + xx3 + Rank + (Rank | School), data = df1,
family = "binomial",control = glmerControl(calc.derivs = FALSE))
predict(mm2, n11, type="response") #No meu caso especifico
shows the error
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrastes podem ser aplicados apenas a fatores com 2 ou mais níveis
I tried to do so
predict(m2,n11, re.form=(~Rank|School))
and presents the error
Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "glmmadmb"
What would be the correct form of prediction in R in GLMM?
Cleber, I apologize for being nosy, but I took a look at your history here at Stack Overflow. There were six questions asked most do not have answers. I suspect this happens because your codes are not reproducible. Take a look at this link and see how to ask a reproducible question on
R
, so that the people who want to help you can do this in the best possible way.– Marcus Nunes
@I never graded the attention, I changed the question, I hope you’re better. Thank you very much.
– Cleber Iack