# R help for the topic 13 assignment 1. How do I compute a least-squares fit, residuals, and predicted values? The basic syntax is fit=lm(response~predictor) This won't print anything, but you can get different summaries as follows. fit gives the intercept and slope fit$residuals is a vector of residuals fit$fitted is a vector of fitted values abline(fit) adds the least-squares fit to the current graph 2. Standardized residuals? Assuming that you already have stored the least-squares fit in the variable fit ... rstandard(fit) compares standardized residuals 3. How do I do a scatterplot with different symbols or colors? In the homework, you wish to plot Miles against TravTime with different symbols for the different directions. TravDir (the direction) is coded -2, -1, 0, 1, 2 If you want to plot with different symbols for direction ... plot(Miles, TravTime, pch=TravDir+3) Or if you wish to use different colors .. plot(Miles, TravTime, col=TravDir+3) Actually, I prefer solid dots ... plot(Miles, TravTime, col=TravDir+3, pch=19) Should also add a legend ... legend("topleft",legend=c("West","Somewhat West","North/South", "Somewhat East","East"), col=1:5,pch=19)