Using R, build a regression model for data that interests you. Conduct residual analysis. Was the linear model appropriate? Why or why not?
I pick a data related to exp and salary,I personally hope this is a linear regression.
And I want to use plot to visualize the result.
From the scatter plot we can see it has a linear regression since it has a line relationship between salary and exp.
salary <- read.csv("/Users/jaylee/Downloads/Experience-Salary.csv", check.names = FALSE)
plot(salary$`salary(in thousands)`,salary$`exp(in months)`)
lmsalary = lm(`salary(in thousands)`~`exp(in months)`, data = salary)
The histogram show the same story.
expandsalary <- resid(lmsalary)
hist(expandsalary)
From all the plot below shows the date is normal distribution.
plot(salary, pch = 16, col = "blue")
abline(lmsalary)
plot(lmsalary)