# hw_S - second way y_hat = predict(lm.1 plot(y_hat...

This preview shows pages 1–2. Sign up to view the full content.

Sheet1 Page 1 # I made a ascii text file (hw_S_dat.txt) and cut/paste the data into it, # including a line of header. Then, dat = read.table("hw_S_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) Two ways of getting residual plots, that you learned in lab. # first way: plot(lm.1) # hit return after this. The first fig is the residual plot.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: # second way: y_hat = predict(lm.1) plot(y_hat, lm.1\$residuals) # The residualplot is a random scatter of dots about the y=0 line, # and so, suggets that the fit is good. # d) lm.2 = lm(y ~ x1 + x2 ) lm.2 # (Intercept) x1 x2 # 38.3508 -0.2588 -0.3015 # e) summary(lm.2) Sheet1 Page 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() . # f) # 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....
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

hw_S - second way y_hat = predict(lm.1 plot(y_hat...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online