Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Plot Pearson and deviance residuals for poisson
- pearson <- influence(model.best)$pear.res/ sqrt(1 - influence(model.best)$hat)
- summary(pearson)
- deviance <- influence(model.best)$dev.res/ sqrt(1 - influence(model.best)$hat)
- summary(deviance)
- xb <- predict(model.best)
- plot(pearson~xb) #Over 30
- plot(pearson^2~xb) # LArger than 1200 XD This is terrible
- abline(4,0, col = "red", lty = 3)
- plot(deviance~xb) # Over 20
- abline(2,0, col = "red", lty = 3)
- abline(-2,0, col = "red", lty = 3)
- # Plot Pearson and deviance residuals for negative binomial
- pearson <- influence(model.gneg_cars)$pear.res/ sqrt(1 - influence(model.gneg_cars)$hat)
- summary(pearson)
- deviance <- influence(model.gneg_cars)$dev.res/ sqrt(1 - influence(model.gneg_cars)$hat)
- xb <- predict(model.gneg_cars)
- plot(pearson~xb) #Over 6
- plot(pearson^2~xb) # Larger than 40. Not good, but miles ahead of Poisson
- abline(4,0, col = "red", lty = 3)
- plot(deviance~xb) #Over 3, not good
- abline(2,0, col = "red", lty = 3)
- abline(-2,0, col = "red", lty = 3)
- # Cooks distance for poisson
- cd <- cooks.distance(model.best)
- n <- 500
- plot(cd~xb) # very weird
- abline(h = c(1, 4 / n), col = "red", lty = 3) # Largest 3.5
- # Cooks distance for negative binomial
- cd <- cooks.distance(model.gneg_cars)
- n <- 500
- plot(cd~xb) # very weird
- abline(h = c(1, 4 / n), col = "red", lty = 3) # smaller than 0.05
- # Conclusion: Dont use Poisson in this case
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement