GLM in R: Normal Q-Q Plot with the 95% confidence interval

Viewed 756

I'd like a function or package to plot the Normal Q-Q Plot with the 95% confidence interval, but I don't find for GLM, only GAM models and for response variables in package car. In my example:

#Data set example
p <- read.csv("https://raw.githubusercontent.com/Leprechault/PEN-533/master/bradysia-greenhouse.csv")

#Quasi Poisson GLM
m1 <- glm(bradysia ~ area + mes, family="quasipoisson", data=p)

#Normal Q-Q Plot 
plot(m1, which = 2)

pl1

#Normal Q-Q Plot with the confidence interval

pl2

I'll like a plot like above for GLM models, it is possible? There are any function or package?

1 Answers

There are two types of confidence intervals: 1.confidence interval for prediction (what you have shown in your plot 2) and 2. confidence interval for regression. To fit confidence interval for regression to the residuals of the glm model you can use car package like

library(car)
qqPlot(m1$resid, ylab="Residuals", xlab="Theoretical Quantiles")

enter image description here

Related