I am trying to make a prediction model and I would like to have the confidence intervals around these predictions
This is a mixed generalized logistic regression model
I tried to take the code here : Confidence intervals for predictions from logistic regression
I liked this format because I need to do a for loop,
Basically I'm working on a model of mortality due to fire with several variables (flame height, intensity, tree diameter)
And I would like to have the predicted mortality rate for each degree of fire intensity.
I managed to make a loop that makes predictions for each of these intensities, but I would like to have a confidence interval to better interpret my results.
But it doesn't seem to work when there are random effects.
I hope someone can help me
Here is the reproducible error:
foo <- mtcars[,c("mpg", "vs", "cyl")]; names(foo) <- c("x","y", "z")
## Working example data
mod <- glmer(y ~ x + (1|z), data = foo, family = binomial)
preddata <- with(foo, data.frame(x = seq(min(x), max(x), length = 100)))
fixed_z = 5
preddata2 <- data.frame ( x = preddata$x,
z = 6)
## want to fix a variable to see how the other react
preds <- predict(mod, newdata = preddata2, type = "link", se.fit = TRUE)
Then, there is no preds$fit
I saw that many questions on stackflow had answers but all were about glm. Is it possible to have a confidence interval on a glmer?
I tried this code here : Confidence intervals for predictions from logistic regression
I also tried the first one on this page, but in my datan the random factor is a character so
medEff = REquantile(mod, quantile = 0.5,
groupFctr = "ID",
term = "(Intercept)")
doesn't work