Problem 8.11

bailsofhay — Nov 25, 2013, 5:57 PM

data=read.table("http://www.stat.lsu.edu/exstweb/statlab/datasets/KNNLData/CH06PR05.txt")
names(data)=c("y","x1","x2")

### Part a ###

fit=lm(y~x1+x2+I(x1*x2), data=data)
fit

Call:
lm(formula = y ~ x1 + x2 + I(x1 * x2), data = data)

Coefficients:
(Intercept)           x1           x2   I(x1 * x2)  
      27.15         5.92         7.87        -0.50  

### Part b ###
# Alternatives: Ho: B3 = 0,  Ha: B3 is not equal to 0.
# Decision Rule: If F* < or equal to F critical, conclude Ho, if F* > F critical, Conclude Ha.

fitred=lm(y~x1+x2, data=data)
fitred

Call:
lm(formula = y ~ x1 + x2, data = data)

Coefficients:
(Intercept)           x1           x2  
      37.65         4.42         4.37  
anova.fit=anova(fitred,fit)
anova.fit
Analysis of Variance Table

Model 1: y ~ x1 + x2
Model 2: y ~ x1 + x2 + I(x1 * x2)
  Res.Df  RSS Df Sum of Sq    F Pr(>F)  
1     13 94.3                           
2     12 74.3  1        20 3.23  0.097 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
top=anova.fit[2,4]
SSEf=anova.fit[2,2]
dft=anova.fit[2,3]
dff=anova.fit[2,1]
# F* is:
Fs=(top/dft)/(SSEf/dff)
Fs
[1] 3.23
# F critical is:
Fc=qf(.95,1,12)
Fc
[1] 4.747

# Conclude Ho since F* << F Critical.