Script 5
#Exercise 5.1 #1 define improve improve <- (misdata$mis_arith1 - misdata$mis_arith0) misdata$improve <- improve #2. scatterplot plot(improve ~ misdata$mis_IQ) # relationship is linear, higher IQ score predicts larger improvement #3. ??lm #4. model1 <- lm(improve ~ misdata$mis_IQ); model1 #5.ask summary summary(model1) # IQ is a significant predictor of improvement on arithmetic test score #6. ??abline abline(model1) #7. model2 <- lm(improve~misdata$mis_IQ, na.action=na.exclude) ??na.exclude summary(model2) #there is no difference in the two models, hence na.exclude is the default #8. fittie <- fitted(model1); fittie fittie2<- fitted(model2); fittie2 resid <- resid(model1); resid resid2<-resid(model2); resid2 #model 1 does not include NAs anymore, they were deleted. model 2 does include NAs #so the function na.exclude just excludes the NAs from analysis but leaves them in #9. qqnorm(resid); qqline(resid) # residuals seem light taile...