Prepare data frame for plotting
berkeley <- as.data.frame(UCBAdmissions)
cellID <- paste(berkeley$Dept, substr(berkeley$Gender,1,1), '-',
substr(berkeley$Admit,1,3), sep="")
rownames(berkeley) <- cellID
using glm()
berk.mod <- glm(Freq ~ Dept * (Gender+Admit), data=berkeley, family="poisson")
summary(berk.mod)
##
## Call:
## glm(formula = Freq ~ Dept * (Gender + Admit), family = "poisson",
## data = berkeley)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.4776 -0.4144 0.0098 0.3089 2.2321
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 6.27557 0.04248 147.744 < 2e-16 ***
## DeptB -0.40575 0.06770 -5.993 2.06e-09 ***
## DeptC -1.53939 0.08305 -18.536 < 2e-16 ***
## DeptD -1.32234 0.08159 -16.207 < 2e-16 ***
## DeptE -2.40277 0.11014 -21.816 < 2e-16 ***
## DeptF -3.09624 0.15756 -19.652 < 2e-16 ***
## GenderFemale -2.03325 0.10233 -19.870 < 2e-16 ***
## AdmitRejected -0.59346 0.06838 -8.679 < 2e-16 ***
## DeptB:GenderFemale -1.07581 0.22860 -4.706 2.52e-06 ***
## DeptC:GenderFemale 2.63462 0.12343 21.345 < 2e-16 ***
## DeptD:GenderFemale 1.92709 0.12464 15.461 < 2e-16 ***
## DeptE:GenderFemale 2.75479 0.13510 20.391 < 2e-16 ***
## DeptF:GenderFemale 1.94356 0.12683 15.325 < 2e-16 ***
## DeptB:AdmitRejected 0.05059 0.10968 0.461 0.645
## DeptC:AdmitRejected 1.20915 0.09726 12.432 < 2e-16 ***
## DeptD:AdmitRejected 1.25833 0.10152 12.395 < 2e-16 ***
## DeptE:AdmitRejected 1.68296 0.11733 14.343 < 2e-16 ***
## DeptF:AdmitRejected 3.26911 0.16707 19.567 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
## Null deviance: 2650.095 on 23 degrees of freedom
## Residual deviance: 21.736 on 6 degrees of freedom
## AIC: 216.8
##
## Number of Fisher Scoring iterations: 4
Influence plot
influencePlot(berk.mod, id=list(n=3, labels=cellID))
## StudRes Hat CookD
## AM-Adm -4.1541239 0.9588091 22.3046668
## AM-Rej 4.1497537 0.9254346 11.8924974
## AF-Adm 4.0991865 0.6853494 2.0871343
## AF-Rej -4.4178464 0.4304068 0.7240710
## BM-Adm -0.5037122 0.9842940 0.8833704
## BM-Rej 0.5036947 0.9729710 0.5074049
## FM-Rej 0.6197342 0.9692308 0.6721646
op <- par(mfrow = c(2,2))
plot(berk.mod)
par(op)
IycgLS0tDQojJyB0aXRsZTogIkRpYWdub3N0aWMgcGxvdHMgZm9yIGJlcmtlbGV5IGRhdGEiDQojJyBhdXRob3I6ICJNaWNoYWVsIEZyaWVuZGx5Ig0KIycgZGF0ZTogImByIGZvcm1hdChTeXMuRGF0ZSgpKWAiDQojJyBvdXRwdXQ6DQojJyAgIGh0bWxfZG9jdW1lbnQ6DQojJyAgICAgdGhlbWU6IHJlYWRhYmxlDQojJyAgICAgY29kZV9kb3dubG9hZDogdHJ1ZQ0KIycgLS0tDQoNCiMrIGVjaG89RkFMU0UNCmtuaXRyOjpvcHRzX2NodW5rJHNldCgNCiAgd2FybmluZyA9IEZBTFNFLCAgICMgYXZvaWQgd2FybmluZ3MgYW5kIG1lc3NhZ2VzIGluIHRoZSBvdXRwdXQNCiAgbWVzc2FnZSA9IEZBTFNFDQopDQoNCmxpYnJhcnkoY2FyKQ0KDQojJyAjIyBQcmVwYXJlIGRhdGEgZnJhbWUgZm9yIHBsb3R0aW5nDQpiZXJrZWxleSA8LSBhcy5kYXRhLmZyYW1lKFVDQkFkbWlzc2lvbnMpDQpjZWxsSUQgPC0gcGFzdGUoYmVya2VsZXkkRGVwdCwgc3Vic3RyKGJlcmtlbGV5JEdlbmRlciwxLDEpLCAnLScsIA0KICAgICAgICAgICAgICAgIHN1YnN0cihiZXJrZWxleSRBZG1pd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