# I made a ascii text file (hw_Q_dat.txt) and cut/paste the data into it, # including a line of header. Then, dat = read.table("hw_Q_dat.txt", header=T) x1 = dat[,1] x2 = dat[,2] y = dat[,3] # a) lm.1 = lm(y ~ x1 + x2 + I(x1^2) + I(x2^2) + I(x1*x2)) lm.1 # (Intercept) x1 x2 I(x1^2) I(x2^2) I(x1 * x2) # 51.19338 -2.14571 -1.87120 0.06305 0.02733 0.13171 # b) summary(lm.1) # Multiple R-squared: 0.4078, # This means that about 41% of the variance in Strength can be attributed # to (or explained by) Depth and Water Content through the expression # given above in lm(). # c) lm.2 = lm(y ~ x1 + x2 ) lm.2 # (Intercept) x1 x2 # 38.3508 -0.2588 -0.3015 # d) summary(lm.2) # Multiple R-squared: 0.3648. # About 36% of the variance in Strength can be attributed to (or explained by) # Depth and and Water Content through the linear expression in lm() . # e) # Given that the R2 increases from 36% to 41%, it's reasonable to conclude # that at least one of the higher-order terms provides useful information # about Strength.