#Variability around ybar and around the fitted line: #Access the data: a <- read.table("http://www.stat.ucla.edu/~nchristo/statistics13/soil_complete.txt", header=TRUE) #Run simple regression of log(lead) on log(zinc): q <- lm(log(a$lead) ~ log(a$zinc)) #Construct the scatterplot of log(lead against log(zinc) and show the fitted line and the ybar line: #Scatterplot: plot(log(a$zinc), log(a$lead), pch=19) #Add fitted line" abline(q) #Add yabr line: abline(h=mean(log(a$lead))) #Show variability around ybar line: segments(log(a$zinc),log(a$lead), log(a$zinc), mean(log(a$lead))) #Show variability around fitted line: segments(log(a$zinc),log(a$lead), log(a$zinc), q$coef[1]+q$coef[2]*log(a$zinc), col="blue", lwd=5) arrows(4.65,4.82, 4.86,5.05, angle=10, length=.15) text(5.0,5.10, "mean(log(a$lead))") #What do you observe?