###Q2(a) t.test(datps$Final~datps$Tutor) ###Q2(c) psmod1 <- glm(formula=Tutor~Sex+Year+Major+Participation+Midterm_out_of_40, family=binomial, data=datps) datps$ps1 <- exp(fitted(psmod1))/(1+exp(fitted(psmod1))) par(mfrow=c(1,2)) hist(datps$ps1[datps$Tutor==0]) hist(datps$ps1[datps$Tutor==1]) ###Q2(d) mod_match <- matchit(formula = Tutor ~ Midterm_out_of_40 + Year+Sex+Major+Participation, method="nearest",data=datps) dat.m <- match.data(mod_match) summary(mod_match) ###Q2(e) with(dat.m, t.test(Final ~ Tutor)) ###Q2(f) par(mfrow=c(1,2)) hist(dat.m$Midterm_out_of_40[dat.m$Tutor==0]) hist(dat.m$Midterm_out_of_40[dat.m$Tutor==1]) par(mfrow=c(1,2)) hist(dat.m$Participation[dat.m$Tutor==0]) hist(dat.m$Participation[dat.m$Tutor==1]) table(dat.m$Sex,dat.m$Tutor) table(dat.m$Year,dat.m$Tutor) table(dat.m$Major,dat.m$Tutor) ###Q2(g) plot(psmod1) par(mfrow=c(1,1)) hist(residuals(psmod1))