I chose to use the africa data. To see if poission reggression was right for this data I created a histogram of coups. The histogram is very skewed right which means poisson regression is a good fit.
hist(africa$miltcoup)
fullmod<- glm(africa$miltcoup~africa$oligarchy+africa$pollib+africa$parties+africa$pctvote+africa$popn+africa$numelec+africa$numregim,family = poisson)
summary(fullmod)
##
## Call:
## glm(formula = africa$miltcoup ~ africa$oligarchy + africa$pollib +
## africa$parties + africa$pctvote + africa$popn + africa$numelec +
## africa$numregim, family = poisson)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.3331 -0.9768 -0.2003 0.5297 1.7477
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -0.552324 0.903536 -0.611 0.54101
## africa$oligarchy 0.066744 0.034111 1.957 0.05039 .
## africa$pollib -0.701259 0.271330 -2.585 0.00975 **
## africa$parties 0.032119 0.011169 2.876 0.00403 **
## africa$pctvote 0.014033 0.009808 1.431 0.15249
## africa$popn 0.008972 0.006666 1.346 0.17836
## africa$numelec -0.027105 0.064708 -0.419 0.67530
## africa$numregim 0.198305 0.230035 0.862 0.38865
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 65.945 on 35 degrees of freedom
## Residual deviance: 29.281 on 28 degrees of freedom
## (11 observations deleted due to missingness)
## AIC: 110.09
##
## Number of Fisher Scoring iterations: 6
mod1<- glm(africa$miltcoup~africa$oligarchy+africa$pollib+africa$parties,family = poisson)
Here I performed a drop in deviance test. I started by taking the summary of my current mod and found parties to be the least significant, so I would test to see if it was a good variable. I will be testing it at the .05 significance level. Since the p value is greater than the significance level it is ok to drop parties.
summary(mod1)
##
## Call:
## glm(formula = africa$miltcoup ~ africa$oligarchy + africa$pollib +
## africa$parties, family = poisson)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.4495 -1.0868 -0.3699 0.5723 1.7526
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.27416 0.36432 0.753 0.45172
## africa$oligarchy 0.09892 0.02012 4.916 8.82e-07 ***
## africa$pollib -0.51592 0.19511 -2.644 0.00819 **
## africa$parties 0.01641 0.00865 1.897 0.05778 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 79.124 on 41 degrees of freedom
## Residual deviance: 42.242 on 38 degrees of freedom
## (5 observations deleted due to missingness)
## AIC: 123.92
##
## Number of Fisher Scoring iterations: 5
mod2<-glm(africa$miltcoup~africa$oligarchy+africa$pollib,family = poisson)
teststat<-deviance(mod2)-deviance(mod1)
pchisq(teststat,df=1,lower.tail = FALSE)
## [1] 0.07118606
Here I performed a 95% confidence interval
confint(mod2,parm=2,level=.95)
## Waiting for profiling to be done...
## 2.5 % 97.5 %
## 0.06218165 0.13982861
Lastly I calculated the dispersion parameter of my model. The DP ending up being about 1.12 which means the variance is 1.12 times larger than the mean.
dp<-sum(residuals(mod2,type="pearson")^2/mod2$df.res)
dp
## [1] 1.119648