Solved – Comparing two linear regression models

model comparisonregression

I would like to compare two linear regression models which represent degradation rates of a mRNA over time under two different conditions. The data for each model collected independently.

Here is the dataset.

Time (hours)    log(Treatment A)     log(treatment B)
0   2.02    1.97
0   2.04    2.06
0   1.93    1.96
2   2.02    1.91
2   2.00    1.95
2   2.07    1.82
4   1.96    1.97
4   2.02    1.99
4   2.02    1.99
6   1.94    1.90
6   1.94    1.97
6   1.86    1.88
8   1.93    1.97
8   2.12    1.99
8   2.06    1.93
12  1.71    1.70
12  1.96    1.73
12  1.71    1.76
24  1.70    1.46
24  1.83    1.41
24  1.62    1.42

These are my models:

Exp1.A.lm<-lm(Exp1$Time~Exp1$(Treatment A))
Exp1.B.lm<-lm(Exp1$Time~Exp1$(Treatment B))
Call:
lm(formula = Exp1$Time ~ Exp1$(Treatment A))

Residuals:
    Min      1Q  Median      3Q     Max 
-6.8950 -1.2322  0.2862  1.2494  5.2494 

Coefficients:
                   Estimate Std. Error t value Pr(>|t|)    
(Intercept)           74.68       6.27   11.91 2.94e-10 ***
Exp1$(Treatment A)   -36.14       3.38  -10.69 1.77e-09 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 2.97 on 19 degrees of freedom
Multiple R-squared: 0.8575, Adjusted R-squared:  0.85 
F-statistic: 114.3 on 1 and 19 DF,  p-value: 1.772e-09

Call:
lm(formula = Exp1$Time ~ Exp1$(Treatment B))

Residuals:
   Min     1Q Median     3Q    Max 
-7.861 -3.278 -1.444  3.222 11.972 

Coefficients:
                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)             88.281     16.114   5.478 2.76e-05 ***
Exp1$(Treatment B)  -41.668      8.343  -4.994 8.05e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 5.173 on 19 degrees of freedom
Multiple R-squared: 0.5676, Adjusted R-squared: 0.5449 
F-statistic: 24.94 on 1 and 19 DF,  p-value: 8.052e-05

To compare these two models, I used this following code.

anova(Exp1.A.lm,Exp1.B.lm)
Analysis of Variance Table

Model 1: Exp1$Time ~ Exp1$Exp1$(Treatment A)
Model 2: Exp1$Time ~ Exp1$Exp1$(Treatment B)
  Res.Df    RSS Df Sum of Sq F Pr(>F)
1     19 167.60                      
2     19 508.48  0   -340.88

My question is why the ANOVA analysis doesn't show an F statistics and a p.val. My apologies if this is a naive question.

Based on different slopes, the rate of degradation is different in these two models, but I would like to know how statistically significant this difference is. I hope that this makes sense.

Best Answer

If you set up the data in one long column with A and B as a new column, you then can run your regression model as a GLM with a continuous time variable and a nominal "experiment" variable (A, B). The output of the ANOVA will give you the significance of the difference between the parameters. "intercept' is the common intercept and the "experiment" factor will reflect differences between the intercepts (actually overall means) between the experiments. the "Time" factor will be the common slope, and the interaction is the difference between the experiments with respect to the slope.

I have to admit I cheat (?) and run the models separately first to get the two sets of parameters and their errors and then run the combined model to acquire the differences between the treatments (in your case A and B)...

Related Question