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.478 -0.414 0.010 0.309 2.232
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 6.2756 0.0425 147.74 < 2e-16 ***
## DeptB -0.4057 0.0677 -5.99 2.1e-09 ***
## DeptC -1.5394 0.0831 -18.54 < 2e-16 ***
## DeptD -1.3223 0.0816 -16.21 < 2e-16 ***
## DeptE -2.4028 0.1101 -21.82 < 2e-16 ***
## DeptF -3.0962 0.1576 -19.65 < 2e-16 ***
## GenderFemale -2.0333 0.1023 -19.87 < 2e-16 ***
## AdmitRejected -0.5935 0.0684 -8.68 < 2e-16 ***
## DeptB:GenderFemale -1.0758 0.2286 -4.71 2.5e-06 ***
## DeptC:GenderFemale 2.6346 0.1234 21.35 < 2e-16 ***
## DeptD:GenderFemale 1.9271 0.1246 15.46 < 2e-16 ***
## DeptE:GenderFemale 2.7548 0.1351 20.39 < 2e-16 ***
## DeptF:GenderFemale 1.9436 0.1268 15.32 < 2e-16 ***
## DeptB:AdmitRejected 0.0506 0.1097 0.46 0.64
## DeptC:AdmitRejected 1.2091 0.0973 12.43 < 2e-16 ***
## DeptD:AdmitRejected 1.2583 0.1015 12.40 < 2e-16 ***
## DeptE:AdmitRejected 1.6830 0.1173 14.34 < 2e-16 ***
## DeptF:AdmitRejected 3.2691 0.1671 19.57 < 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.154 0.959 22.305
## AM-Rej 4.150 0.925 11.892
## AF-Adm 4.099 0.685 2.087
## AF-Rej -4.418 0.430 0.724
## BM-Adm -0.504 0.984 0.883
## BM-Rej 0.504 0.973 0.507
## FM-Rej 0.620 0.969 0.672
op <- par(mfrow = c(2,2))
plot(berk.mod)
par(op)
IycgLS0tDQojJyB0aXRsZTogIkRpYWdub3N0aWMgcGxvdHMgZm9yIGJlcmtlbGV5IGRhdGEiDQojJyBhdXRob3I6ICJNaWNoYWVsIEZyaWVuZGx5Ig0KIycgZGF0ZTogImByIGZvcm1hdChTeXMuRGF0ZSgpKWAiDQojJyBvdXRwdXQ6DQojJyAgIGh0bWxfZG9jdW1lbnQ6DQojJyAgICAgdGhlbWU6IHJlYWRhYmxlDQojJyAgICAgY29kZV9kb3dubG9hZDogdHJ1ZQ0KIycgLS0tDQoNCiMrIGVjaG89RkFMU0UNCmtuaXRyOjpvcHRzX2NodW5rJHNldCgNCiAgd2FybmluZyA9IEZBTFNFLCAgICMgYXZvaWQgd2FybmluZ3MgYW5kIG1lc3NhZ2VzIGluIHRoZSBvdXRwdXQNCiAgbWVzc2FnZSA9IEZBTFNFDQopDQoNCmxpYnJhcnkoY2FyKQ0KDQojJyAjIyBQcmVwYXJlIGRhdGEgZnJhbWUgZm9yIHBsb3R0aW5nDQpiZXJrZWxleSA8LSBhcy5kYXRhLmZyYW1lKFVDQkFkbWlzc2lvbnMpDQpjZWxsSUQgPC0gcGFzdGUoYmVya2VsZXkkRGVwdCwgc3Vic3RyKGJlcmtlbGV5JEdlbmRlciwxLDEpLCAnLScsIA0KICAgICAgICAgICAgICAgIHN1YnN0cihiZXJrZWxleSRBZG1pdCwxLDMpLCBzZXA9IiIpDQpyb3duYW1lcyhiZXJrZWxleSkgPC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