# here we use the scan function to read in the data as a matrix, then # we convert it to a data frame. A blank line must occur at the end of the data # to signal the end of reading the data. data <- matrix(scan(),ncol=2,byrow=TRUE) 10455 2.58 9680 2.31 7300 2.47 9388 2.52 12496 3.22 11812 3.37 9224 2.43 11725 3.08 11320 2.78 12000 2.98 12500 3.55 13310 3.64 12105 3.72 6200 2.24 11522 2.7 8000 2.3 12548 2.83 7700 2.37 10028 2.52 13176 3.22 13255 3.55 13004 3.55 8000 2.47 8224 2.47 10750 2.78 11669 2.78 12322 2.98 11002 2.58 10666 2.58 10839 2.58 data CollegeData2 <- data.frame(data) colnames(CollegeData2) <- c("salary","cgpa") rm(data) # in the regression analysis below, we use the I() function so that we can directly # square cgpa as cgpa^2 College.Fit2 <- lm(CollegeData2$salary ~ CollegeData2$cgpa + I(CollegeData2$cgpa^2)) summary(College.Fit2) anova(College.Fit2) # this code creates a residual-by-predicted plot, and a normal plot of the residuals, # and other plots par(mfrow=c(2,2)) plot(fitted(College.Fit2),rstudent(College.Fit2),xlab="Predicted Values", ylab="Studentized residuals",main="Residual by Predicted plot") qqnorm(resid(College.Fit2)) qqline(resid(College.Fit2)) plot(College.Fit2$model[,1],fitted(College.Fit2),xlab="Salary Values", ylab="Predicted Values",main="Y by Predicted Y plot") plot(College.Fit2$model[,2],rstudent(College.Fit2),xlab="College GPA Values", ylab="Studentized residuals",main="Residual by College GPA plot") par(mfrow=c(1,1))