# Why do linear regression and ANOVA give different $p$-value in case of considering interaction between variable?

I was trying to fit one time-series data (without replicates) using regression model. The data looks like follows:

> xx.2
value time treat
1  8.788269    1     0
2  7.964719    6     0
3  8.204051   12     0
4  9.041368   24     0
5  8.181555   48     0
6  8.041419   96     0
7  7.992336  144     0
8  7.948658    1     1
9  8.090211    6     1
10 8.031459   12     1
11 8.118308   24     1
12 7.699051   48     1
13 7.537120   96     1
14 7.268570  144     1


Because of lack of replicates, I treat the time as continuous variable. Column "treat" shows the case and control data, respectively.

First, I fit the the model "value = time*treat" with "lm" in R:

summary(lm(value~time*treat,data=xx.2))

Call:
lm(formula = value ~ time * treat, data = xx.2)

Residuals:
Min       1Q   Median       3Q      Max
-0.50627 -0.12345  0.00296  0.04124  0.63785

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)  8.493476   0.156345  54.325 1.08e-13 ***
time        -0.003748   0.002277  -1.646   0.1307
treat       -0.411271   0.221106  -1.860   0.0925 .
time:treat  -0.001938   0.003220  -0.602   0.5606


The pvalue of time and treat is not significant.

While with anova, I got different results:

 summary(aov(value~time*treat,data=xx.2))
Df Sum Sq Mean Sq F value Pr(>F)
time         1 0.7726  0.7726   8.586 0.0150 *
treat        1 0.8852  0.8852   9.837 0.0106 *
time:treat   1 0.0326  0.0326   0.362 0.5606
Residuals   10 0.8998  0.0900


The pvalue for time and treat changed.

With linear regression, if I am right, it means the time and treat has no significant influence on value, but with ANOVA, it means time and treat has significant influence on value.

Could someone explain to me why there is difference in these two methods, and which one to use?

-
You may want to look up the different kinds of sums of squares. Specifically, I believe linear regression returns type III sum of squares, while anova returns a different kind. –  Max May 22 '12 at 15:50

-