> data<-read.table("/afs/umich.edu/user/k/u/kutsyy/Public/html/classes/ALSM/CH06FI05.DAT")
> data
V1 V2
V3
1 68.5 16.7 174.4
2 45.2 16.8 164.4
3 91.3 18.2 244.2
4 47.8 16.3 154.6
5 46.9 17.3 181.6
6 66.1 18.2 207.5
7 49.5 15.9 152.8
8 52.0 17.2 163.2
9 48.9 16.6 145.4
10 38.4 16.0 137.2
11 87.9 18.3 241.9
12 72.8 17.1 191.1
13 88.4 17.4 232.0
14 42.9 15.8 145.3
15 52.5 17.8 161.1
16 85.7 18.4 209.7
17 41.3 16.5 146.4
18 51.7 16.3 144.0
19 89.6 18.1 232.6
20 82.7 19.1 224.1
21 52.3 16.0 166.5
> X1<-data[,1]
> X2<-data[,2]
> Y<-data[,3]
> fit.full<-lm(Y~X1+X2+X1^2+X2^2+I(X1*X2))
> summary(fit.full,cor=F)
Call: lm(formula = Y ~ X1 + X2 + X1^2 + X2^2
+ I(X1 * X2))
Residuals:
Min
1Q Median 3Q Max
-16.87 -6.058 -1.286 5.392 15.69
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 1255.1962 1788.3504
0.7019 0.4935
X1 9.8284 9.8467
0.9981 0.3340
X2 -175.3420 239.2591 -0.7329
0.4749
I(X1^2)
0.0433 0.0255 1.6967
0.1104
I(X2^2)
6.8404 8.1482 0.8395
0.4144
I(X1 * X2) -0.8120
0.7313 -1.1103 0.2844
Residual standard error: 10.79 on 15 degrees
of freedom
Multiple R-Squared: 0.9333
F-statistic: 42.01 on 5 and 15 degrees of
freedom, the p-value is 2.679e-08
> fit<-update(fit.full,~.-I(X1*X2))
> anova(fit,fit.full)
Analysis of Variance Table
Response: Y
Terms Resid. Df RSS
Test Df
1
X1 + X2 + I(X1^2) + I(X2^2) 16
1889.513
2 X1 + X2 + X1^2 + X2^2 + I(X1 * X2)
15 1746.017 +I(X1 * X2) 1
Sum of Sq F Value
Pr(F)
1
2 143.4953 1.232765 0.2843522
> summary(fit,cor=F)
Call: lm(formula = Y ~ X1 + X2 + I(X1^2) +
I(X2^2))
Residuals:
Min
1Q Median 3Q Max
-18.74 -5.967 -1.726 5.691 17.82
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) -487.9151 862.6323
-0.5656 0.5795
X1 -0.9642 1.5830 -0.6091
0.5510
X2 65.9985 100.7109 0.6553
0.5216
I(X1^2)
0.0181 0.0117 1.5417
0.1427
I(X2^2) -1.6193
2.9085 -0.5567 0.5854
Residual standard error: 10.87 on 16 degrees
of freedom
Multiple R-Squared: 0.9279
F-statistic: 51.46 on 4 and 16 degrees of
freedom, the p-value is 6.171e-09
> fit<-update(fit,~.-I(X2^2))
> anova(fit,fit.full)
Analysis of Variance Table
Response: Y
Terms Resid. Df RSS
Test Df
1
X1 + X2 + I(X1^2) 17 1926.117
2 X1 + X2 + X1^2 + X2^2 + I(X1 * X2)
15 1746.017 +I(X2^2)+I(X1 * X2) 2
Sum of Sq F Value
Pr(F)
1
2 180.0996 0.7736161 0.4788993
> summary(fit,cor=F)
Call: lm(formula = Y ~ X1 + X2 + I(X1^2))
Residuals:
Min
1Q Median 3Q Max
-19.2 -6.549 -0.6448 7.298 19.35
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) -9.3204 70.3166
-0.1325 0.8961
X1 -0.8176 1.5289 -0.5348
0.5997
X2 9.9739 3.9508 2.5245
0.0218
I(X1^2) 0.0170
0.0113 1.4997 0.1520
Residual standard error: 10.64 on 17 degrees
of freedom
Multiple R-Squared: 0.9265
F-statistic: 71.4 on 3 and 17 degrees of
freedom, the p-value is 7.684e-10
> fit<-update(fit,~.-I(X1^2))
> anova(fit,fit.full)
Analysis of Variance Table
Response: Y
Terms Resid. Df RSS
1
X1 + X2 18 2180.927
2 X1 + X2 + X1^2 + X2^2 + I(X1 * X2)
15 1746.017
Test Df Sum of Sq F Value Pr(F)
1
2 +I(X1^2)+I(X2^2)+I(X1 * X2) 3
434.9101 1.245435 0.3283157
> summary(fit,cor=F)
Call: lm(formula = Y ~ X1 + X2)
Residuals:
Min
1Q Median 3Q Max
-18.42 -6.216 0.7449 9.436 20.22
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) -68.8571 60.0170
-1.1473 0.2663
X1 1.4546 0.2118 6.8682
0.0000
X2 9.3655 4.0640 2.3045
0.0333
Residual standard error: 11.01 on 18 degrees
of freedom
Multiple R-Squared: 0.9167
F-statistic: 99.1 on 2 and 18 degrees of
freedom, the p-value is 1.921e-10
> LF.test(fit)
Analysis of Variance Table
Response: Y
Terms Resid. Df
RSS Test Df Sum of Sq F Value Pr(F)
1 X - 1
18 2180.927
2 x
0 0.000 1 vs. 2 18 2180.927