Reputation: 23
I am trying to run glmm for my data and I have top models for all my target species. However, when I try to plot them with log odds, all the coefficients show up. When I try to select just one coefficient (for e.g. Predator and Aspect), one part of that coefficient is always missing from the graph (e.g. "Yes" shows up, "No" is missing, "NE" is missing from Aspect), drawing the intercept doesn't work as well because the intercept includes part of all other coefficients as well. I want to plot it like this
Dummy data is as follows:
Number <- c(25,16,16,13,12,9,15,25,4,5,230,259,224,259,588,604,583,576,599,664)
Location <- c("Borakolalo","Borakolalo","Borakolalo","Borakolalo","Bloemhof","Bloemhof","Bloemhof",
"Bloemhof","Boskop","Boskop","Boskop","Boskop","Kgaswane","Kgaswane","Kgaswane",
"Kgaswane","Mafikeng","Mafikeng","Mafikeng","Mafikeng")
Nitrogen<-c(0.0889,0.0406,0.0835,0.0737,0.0578,0.0806,0.0914,0.09630,0.0718,0.08955,1.0211,1.9489,
1.9808,1.0053,1.9682,1.9794,1.0959,1.0028,1.9281,1.9887)
Dist_water<- c(2156.0,3783.8,3285.8,2574.7,2242.3,2729.5,2418.1,2874.9,2869.0,2563.0,257.1,660.4,
440.4,417.7,562.6,528.5,426.5,591.2,435.9,306.5)
Predator<-c("Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes","No","No","No","No",
"No","No","No","No","No","No")
Aspect<-c("SE","S","S","NE","NW","S","SW","SE","S","S","NE",
"S","S","SE","SE","SE","SE","SE","SE","SE")
bles<-data.frame(Number,Location,Nitrogen,Dist_water,Predator,Aspect)
bles_sc <- transform(bles,
Nitrogen = drop(scale(Nitrogen)),
Dist_water = drop(scale(Dist_water)))
library(lme4)
mod<-glmer.nb(Number~Nitrogen + Dist_water + Predator+Aspect+(1|Location), data=bles_sc)
summary(mod)
I want to create coefficient plots for all my significant coefficients. I have tried coefplot, coefplot2, multiplot and effect_plot but nothing gives me the result like the image. With most plots, for selected coefficients, Number comes up on the Y-axis not log odds ratios. Any help would be appreciated.
cat_plot(mod, pred = Predator, modx = NULL, interval = TRUE)
coefplot(mod,vertical=FALSE, col="black", hoffset=0.4, horizontal = TRUE, coefficients=c("(Intercept)","PredatorYes","PredatorNo"), strict=TRUE,
ylab="Predator", xlab="Log Odd Ratios")
coefplot2(mod,vertical=FALSE, frame.plot=TRUE, var.las=1,cex.var=0.5,
intercept=TRUE, CI=1)
effect_plot(mod, pred = Predator, outcome.scale = "link",
interval = TRUE)
Upvotes: 0
Views: 131
Reputation: 226007
I think you might have a misconception.
Log-odds scales really don't make sense for negative binomial models, which are for count data where the range of the data is non-negative (in contrast to binomial models, which have ranges from 0 to 1 or 0 to a number of trials N
).
Negative binomial models almost have a logarithmic link (glmer.nb
doesn't offer you a choice), so the scale would be "log", not "log odds".
As for why "one level is missing", that's because models in R (and most statistical packages) for categorical predictors are parameterized relative to a reference level. That's why the example plot that you show at the top has just a dot, without confidence intervals, for the reference level.
I think the example plot is this:
from Mariotti, Elena, Francesca Parrini, Cornelius J. Louw, and Jason P. Marshal. “Habitat Use by a Large Herbivore Guild in a Fenced South African Protected Area.” African Journal of Wildlife Research 50, no. 1 (May 2020). https://doi.org/10.3957/056.050.0086
... but I think it's questionable. The caption says "Predicted estimates (±95% confidence interval) for landscape selection", but I don't really understand it. If it plots predictions, then the reference level (open grassland) should have error bars; if it's really a reference value, then I don't see why it's not at zero ...
Upvotes: 0