Data <- scan(what=list(verbal=0,ses=0)) 37.01 7.20 23.30 -12.86 26.51 -11.71 35.20 0.92 36.51 12.32 34.90 4.77 40.70 14.28 33.10 -0.96 37.10 6.31 22.70 -16.04 33.90 6.16 39.70 10.62 41.80 12.70 31.80 2.66 33.40 -0.17 31.70 -10.99 41.01 9.85 43.10 15.03 37.20 -0.05 41.01 12.77 Coleman <- data.frame(Data$verbal,Data$ses) names(Coleman)=c("Verbal_Score","SES") attach(Coleman) X <- cbind(rep(1,length(SES)),SES) y <- Verbal_Score XtransX <- t(X)%*%X XtransXinv <- solve(XtransX) Xtransy <- t(X)%*%y betahat <- XtransXinv%*%Xtransy Yhat <- X%*%betahat