Key to assignment 1 1.(a) >treat<-factor(treat) >summary(aov(imp~treat)) # At least 2 treatment means are different. (b) part 1: >D1<-ifelse(treat=="A", 1,0) >D2<-ifelse(treat=="B", 1,0) >summary(lm(imp~D1+D2)) # Comment on A vs C (A-mean is significantly smaller than C-mean) # Comment on B vs C (B-mean is NOT significantly smaller than C-mean) # C and B are better than A part 2: >treat<-factor(treat) >summary(lm(imp~treat)) # Comment on A vs B (B-mean is significantly larger than A-mean) # Comment on A vs C (C-mean is significantly larger than A-mean) 2.(a) >plot(x1, y) >plot(x2, y) (b) >cor(x1, y) >cor(x2, y) x1 more correlated with y. Select x1. >reg1<-lm(y~x1) >summary(reg1) >qqnorm(reg1$residuals) >qqline(reg1$residuals) # normality holds >plot(reg1$fitted, reg1$residuals) # constant variance Regression coefficient 3.49 (from summary). p-value 5.26e-08 (almost 0). Significant. (c) >reg2<-lm(y~x2) >summary(reg2) Regression coefficient 1.83 (from summary). p-value 0.0374. Significant. (d) >reg12<-lm(y~x1+x2) >summary(reg12) R^2 is 0.9372. 93.72% of variability in y is explained by x1 and x2 together. R^2(d) < R^2(b)+R^2(c)= 1.0337 (more than 100% !!!) Indicates some correlation between x1 and x2.