cgpa <- c(2.70, 2.66, 2.61, 2.23, 2.04, 3.19, 3.35, 2.80, 2.33, 3.61, 2.60, 2.44, 2.44, 2.83, 2.64, 2.40, 3.12, 2.73, 2.66, 2.22, 2.31, 2.33, 2.68, 3.30, 2.54, 3.27, 3.48, 2.43, 2.81, 2.90) salary <- c(29.29, 28.79, 28.98, 24.07, 22.57, 31.37, 31.73, 27.67, 26.88, 29.34, 28.46, 26.44, 26.75, 30.05, 28.58, 27.16, 30.16, 29.80, 27.83, 26.63, 25.97, 26.58, 29.82, 31.99, 29.24, 31.45, 30.66, 27.61, 31.85, 29.73) CollegeData <- data.frame(cgpa,salary) rm(cgpa,salary) College.Fit <- lm(salary ~ cgpa, data = CollegeData) summary(College.Fit) anova(College.Fit) # a plot with the raw data, the fitted regression line, and a lowess line plot(CollegeData$cgpa,CollegeData$salary,xlab="College GPA",ylab="Salary",main="Regression with College data") abline(College.Fit) lines(lowess(CollegeData$cgpa,CollegeData$salary)) windows() # on a Windows computer, opens a new window for plotting # this code creates a residual-by-predicted plot and a normal plot of the residuals par(mfrow=c(2,1)) # makes all future plots appear two # per page, vertically plot(fitted(College.Fit),resid(College.Fit),xlab="Predicted Values", ylab="Residuals",main="Residual by Predicted plot") qqnorm(resid(College.Fit)) qqline(resid(College.Fit)) par(mfrow=c(1,1)) # restores one plot per page