fit.1<-glm(PCT_NON_MEDICAL_REFUSAL~PCT_BELOW_POV+TOTAL_POP+PCT_BA_OR_MORE+PCT_WHITE,data=schools_county,family=poisson)
summary(fit.1)
## 
## Call:
## glm(formula = PCT_NON_MEDICAL_REFUSAL ~ PCT_BELOW_POV + TOTAL_POP + 
##     PCT_BA_OR_MORE + PCT_WHITE, family = poisson, data = schools_county)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.3907  -1.0272  -0.3213   0.4192   4.0727  
## 
## Coefficients:
##                  Estimate Std. Error z value Pr(>|z|)  
## (Intercept)     2.820e-01  1.133e+00   0.249   0.8035  
## PCT_BELOW_POV  -3.561e-02  2.276e-02  -1.565   0.1176  
## TOTAL_POP      -1.799e-08  2.611e-07  -0.069   0.9451  
## PCT_BA_OR_MORE  7.447e-02  3.533e-02   2.108   0.0350 *
## PCT_WHITE       1.950e-02  1.135e-02   1.719   0.0857 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 92.883  on 38  degrees of freedom
## Residual deviance: 79.776  on 34  degrees of freedom
## AIC: Inf
## 
## Number of Fisher Scoring iterations: 5
fit.2<-glm(PCT_NON_MEDICAL_REFUSAL~PCT_BELOW_POV+TOTAL_POP+PCT_BA_OR_MORE+PCT_WHITE+BELOW_18_PCT_POV,data=schools_county,family=poisson)
summary(fit.2)
## 
## Call:
## glm(formula = PCT_NON_MEDICAL_REFUSAL ~ PCT_BELOW_POV + TOTAL_POP + 
##     PCT_BA_OR_MORE + PCT_WHITE + BELOW_18_PCT_POV, family = poisson, 
##     data = schools_county)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.2858  -1.0136  -0.0473   0.3718   3.9984  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)  
## (Intercept)      -3.755e-02  1.195e+00  -0.031   0.9749  
## PCT_BELOW_POV    -4.695e-02  2.674e-02  -1.756   0.0791 .
## TOTAL_POP         6.379e-08  2.737e-07   0.233   0.8157  
## PCT_BA_OR_MORE    8.107e-02  3.579e-02   2.265   0.0235 *
## PCT_WHITE         2.070e-02  1.143e-02   1.811   0.0701 .
## BELOW_18_PCT_POV  1.669e-02  1.872e-02   0.892   0.3725  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 92.883  on 38  degrees of freedom
## Residual deviance: 78.966  on 33  degrees of freedom
## AIC: Inf
## 
## Number of Fisher Scoring iterations: 5
fit.3<-glm(PCT_NON_MEDICAL_REFUSAL~PCT_BELOW_POV+TOTAL_POP+PCT_BA_OR_MORE+PCT_WHITE+BELOW_18_PCT_POV+PCT_FEMALE,data=schools_county,family=poisson)
summary(fit.3)
## 
## Call:
## glm(formula = PCT_NON_MEDICAL_REFUSAL ~ PCT_BELOW_POV + TOTAL_POP + 
##     PCT_BA_OR_MORE + PCT_WHITE + BELOW_18_PCT_POV + PCT_FEMALE, 
##     family = poisson, data = schools_county)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.6586  -0.9812  -0.0657   0.4483   3.5801  
## 
## Coefficients:
##                    Estimate Std. Error z value Pr(>|z|)  
## (Intercept)      -5.536e+00  4.390e+00  -1.261   0.2073  
## PCT_BELOW_POV    -3.485e-02  2.796e-02  -1.246   0.2127  
## TOTAL_POP         3.435e-08  2.760e-07   0.124   0.9010  
## PCT_BA_OR_MORE    7.110e-02  3.646e-02   1.950   0.0512 .
## PCT_WHITE         1.610e-02  1.204e-02   1.337   0.1811  
## BELOW_18_PCT_POV  1.784e-02  1.872e-02   0.953   0.3408  
## PCT_FEMALE        1.148e-01  8.824e-02   1.300   0.1934  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 92.883  on 38  degrees of freedom
## Residual deviance: 77.255  on 32  degrees of freedom
## AIC: Inf
## 
## Number of Fisher Scoring iterations: 5
aic<-round(c(
  fit.1$deviance+2*length(fit.1$coefficients),
  fit.2$deviance+2*length(fit.2$coefficients),
  fit.3$deviance+2*length(fit.3$coefficients)),2)

aic_table<-as.data.frame(aic)
schools_summary<-schools %>% dplyr::summarize(n_students=sum(K_12_enrollment),mean_vaccine_complete=mean(Percent_complete_for_all_immunizations),mean_refusal=mean(Percent_with_any_exemption))
schools_summary
##   n_students mean_vaccine_complete mean_refusal
## 1    1129795              85.35069     6.413801
plot(schools_county$PCT_NON_MEDICAL_REFUSAL,schools_county$PCT_BA_OR_MORE)
abline(glm(schools_county$PCT_NON_MEDICAL_REFUSAL~schools_county$PCT_BA_OR_MORE))

stargazer(schools_county,type="html")
Statistic N Mean St. Dev. Min Pctl(25) Pctl(75) Max
PCT_COMPLETE_ALL_IMMUNIZATION 39 83.525 8.500 50.127 79.945 88.978 96.233
PCT_ANY_EXEMPTION 39 7.251 4.606 1.689 4.308 8.739 23.813
PCT_NON_MEDICAL_REFUSAL 39 6.240 4.271 1.244 3.334 7.329 22.780
PCT_UNDERVACCINATED 39 9.224 4.889 0.400 5.973 12.015 26.060
PCT_BELOW_POV 39 15.649 4.286 9 12.6 16.9 30
BELOW_18_PCT_POV 39 20.454 4.949 11.700 17.300 23.000 31.300
TOTAL_POP 39 181,362.700 366,978.800 2,231 20,836.5 153,997 2,079,550
PCT_LESS_HS_GRAD 39 23.744 4.686 14.900 20.150 26.650 35.300
PCT_HS_GRAD 39 14.326 3.153 9.200 12.200 15.800 24.500
PCT_SOME_COLLEGE 39 11.544 2.964 7.400 9.400 13.350 18.900
PCT_BA_OR_MORE 39 5.764 2.344 2.800 4.200 6.500 14.300
PCT_WHITE 39 84.685 7.866 67.200 79.400 90.850 95.600
PCT_BLACK 39 1.349 1.447 0.000 0.500 1.800 6.700
PCT_NATIVE_AM 39 2.292 2.814 0.300 0.900 2.600 15.500
PCT_ASIAN 39 2.603 3.038 0.600 0.900 2.300 16.000
PCT_PACIFIC_ISLANDER 39 0.300 0.313 0.000 0.100 0.350 1.400
PCT_OTHER_RACE 39 4.826 6.576 0.000 1.000 3.950 23.700
PCT_TWO_OR_MORE_RACES 39 3.944 1.381 1.500 3.100 4.600 7.500
PCT_HISPANIC_ANY_RACE 39 13.744 14.319 3.000 5.700 14.850 61.900
PCT_AGE_5below 39 5.887 1.591 2.900 4.900 6.450 10.800
PCT_AGE_5-9 39 6.041 1.573 2.800 5.250 6.500 10.700
PCT_AGE_10-14 39 6.210 1.212 3.600 5.600 6.850 9.500
PCT_AGE_15-19 39 6.487 1.702 4.000 5.650 6.750 14.900
PCT_AGE_20-24 39 6.674 3.725 1 5.2 7.0 24
PCT_AGE_25-34 39 11.449 2.473 6.300 9.600 12.950 17.000
PCT_AGE_35-44 39 11.156 1.475 8.200 10.300 11.900 14.900
PCT_AGE_45-54 39 12.641 1.311 8.200 11.900 13.400 15.600
PCT_AGE_55-59 39 7.500 1.485 4.600 6.550 8.500 11.600
PCT_AGE_60-64 39 7.318 1.837 4.100 6.100 8.700 11.600
PCT_AGE_65-74 39 11.228 3.899 5.000 8.550 13.500 20.400
PCT_AGE_75-84 39 5.210 1.664 2.300 3.750 6.050 8.700
PCT_85plus 39 2.195 0.765 0.800 1.700 2.700 4.400
PCT_MALE 39 50.018 0.894 48.100 49.400 50.600 52.100
PCT_FEMALE 39 49.982 0.894 47.900 49.400 50.600 51.900