house1=read.table("house1.txt") names(house1)=c("price","assess","old","months") pairs(house1) attach(house1) house1.lm=lm(price ~ assess + months) summary(house1.lm) anova(house1.lm) anova(lm(price ~ months + assess)) # order matters in the ANOVA table summary(lm(price~months)) anova(lm(price~months)) plot(assess,price) lines(assess,fitted(house1.lm)) # this doesn't work very well plot(assess,price) lines(assess[order(assess)],fitted(house1.lm)[order(assess)]) # still weird plot(fitted(house1.lm),resid(house1.lm)) plot(assess,resid(house1.lm)) plot(months,resid(house1.lm)) qqnorm(resid(house1.lm)) predict(house1.lm,data.frame(assess=80,months=6),interval="predict") detach() pairs(printlog) attach(printlog) print.lm2=lm(week3 ~ week1 + week2) summary(print.lm2) # interpret coefficients and p-values anova(print.lm2) plot(fitted(print.lm2),resid(print.lm2)) # not good plot(week1,resid(print.lm2)) plot(week2,resid(print.lm2)) qqnorm(resid(print.lm2)) # how can we fix this? print.lm3=lm(log(week3+1) ~ log(week1+1) + log(week2+1)) summary(print.lm3) anova(print.lm3) plot(fitted(print.lm3),resid(print.lm3)) # about as good as it will get here qqnorm(resid(print.lm3)) print.lm4=lm(sqrt(week3) ~ sqrt(week1) + sqrt(week2)) summary(print.lm4) # not as good as log plot(fitted(print.lm4),resid(print.lm4)) qqnorm(resid(print.lm4)) # not as good as log