The simplest way to remove urban70 would be to create
a new model which does not include it. However, retyping the
formulae can get tiresome, especially when a lot of terms are involved.
A fancier way to change the model is with the update function.
> education.lm <- update(education.lm, . ~ . - Urban70)This assigns a new value to
education.lm. The new value
is education.lm, updated to have the same response
(the . before the ~ means the same thing is
being predicted) and using the same predictors, except without
Urban70. The new model looks like this:
> summary(education.lm)
Call: lm(formula = SE70 ~ PI68 + Y69)
Residuals:
Min 1Q Median 3Q Max
-51.42 -18.17 -1.768 15.32 53.16
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) -301.0892 70.2713 -4.2847 0.0001
PI68 0.0612 0.0074 8.2532 0.0000
Y69 0.8361 0.1733 4.8253 0.0000
Residual standard error: 28.97 on 48 degrees of freedom
Multiple R-Squared: 0.6267
F-statistic: 40.3 on 2 and 48 degrees of freedom, the p-value is 5.354e-11
Correlation of Coefficients:
(Intercept) PI68
PI68 -0.4839
Y69 -0.9402 0.1624
Let's check for an interaction between the two significant terms.
Note that when you enter an interaction, the main effects are included
as well.
> education.lm <- update(education.lm, . ~ PI68*Y69)
> summary(education.lm)
Call: lm(formula = SE70 ~ PI68 + Y69 + PI68:Y69)
Residuals:
Min 1Q Median 3Q Max
-44.55 -17.02 -1.733 13.56 52.48
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 245.8215 328.7258 0.7478 0.4583
PI68 -0.1017 0.0960 -1.0592 0.2949
Y69 -0.6669 0.8995 -0.7414 0.4621
PI68:Y69 0.0004 0.0003 1.7016 0.0954
Residual standard error: 28.41 on 47 degrees of freedom
Multiple R-Squared: 0.6484
F-statistic: 28.89 on 3 and 47 degrees of freedom, the p-value is 9.728e-11
Correlation of Coefficients:
(Intercept) PI68 Y69
PI68 -0.9826
Y69 -0.9974 0.9815
PI68:Y69 0.9778 -0.9971 -0.9820
The interaction term really messed up the model, so we should
go back to the previous model by removing it.
> education.lm <- update(education.lm, . ~ . - PI68:Y69)The
PI68:Y69 term means ``the PI68 and Y69 interaction'',
so if we subtract PI68:Y69 we are left with the main effects only.