Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 758
Isabel Avatar asked Sep 16 '25 18:09

Isabel


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

like image 85
Bappa Das Avatar answered Sep 19 '25 10:09

Bappa Das