########## 3.1 ##########
#The commented out stuff wasn't part of the solution

wagedata = read.table("wagedata.csv")
#constvar = rep(1, length(wagedata$wage))

#a)
#const = lm(wage ~ constvar +1, data = wagedata)
edu = lm(wage ~ educ, data = wagedata)

#summary(const)
summary(edu)


#b)
#log_const = lm(log(wage) ~ constvar +1, data = wagedata)
log_edu = lm(log(wage) ~ educ, data = wagedata)

#summary(log_const)
summary(log_edu)

########## 3.2 ##########

#a)
par(mfrow=c(2,1))
plot(wage ~ educ, data = wagedata, col="blue")
abline(edu, col="blue")

plot(log(wage) ~ educ, data = wagedata, col="blue")
abline(log_edu, col="blue")
par(mfrow=c(1,1))

#sum(edu$residuals^2)
#sum(log_edu$residuals^2)


#b)
b2 = edu[["coefficients"]][["educ"]]
log_b2 = log_edu[["coefficients"]][["educ"]]
