# Lab 3 Exercise Key # 1. Which model comparison? # Augmented: Wk4IAT = b0 + b1*Trainhours + e # Compact: Wk4IAT = bo + e # We care about the test of b1. # 2. lm mEx = lm(Wk4IAT ~ 1 + Trainhours, data=d) # 3. modelSummary(mEx, t=F) # 4. # a. People who have spent 0 hours at diversity trainings have, on average, a non-zero IAT # score at week 4 (M = .541). # b. Every one hour increase of time spent in diversity training predicted a .04 point decrease # in week 4 IAT scores. # c. Both the parameters are statistically significant (have less than a 5% probability of occurring # by chance if the null hypothesis is true). # d. Yep! # 5. modelEffectSizes(mEx) # peta2 = .0592. Training hours explains about 6% of the variance in week 4 IAT scores. # 6. d$TrainhoursC = d$Trainhours - mean(d$Trainhours) mExC = lm(Wk4IAT ~ 1 + TrainhoursC, data=d) # 7. modelSummary(mExC, t=F) # a. Only the estimate for the intercept parameter. # b. b1 is the same. b0 now represents the predicted week 4 IAT score for someone who has spent # an average number of hours in diversity training. # c and d Cs = data.frame(Trainhours = c(2,6)) modelPredictions(mEx, Cs) # .527 for someone who has attended 2 hours, .357 for someone who has attended 6 hours. ################## #### GRAPHING #### ################## plotEx = ggplot(d, aes(x = Trainhours, y = Wk4IAT)) plotEx plotEx = plotEx + geom_point(position=position_jitter(.1)) plotEx pY = data.frame(Trainhours = seq(min(d$Trainhours),max(d$Trainhours), length=100)) pY = modelPredictions(mEx, pY) plotEx = plotEx + geom_smooth(data=pY, aes(ymin=CILo, ymax=CIHi, x = Trainhours, y = Predicted), stat='identity', color='green') plotEx plotEx = plotEx + labs(x = "Hours of diversity training", y= "IAT scores at week 4") + theme_bw(base_size = 14) plotEx # The researchers hypothesized that diversity training lowers IAT scores. Participants indicated how # many hours they had spent at diversity trainings and then, 4 weeks later, completed an IAT. The # more time participants spent at diversity training, the lower their implicit bias as measured by # the IAT, F(1,76) = 4.78, p = .032. This variable explained 5.9% of the variance in IAT scores.