# Why do I get a different RSE when I call the summary of two identical linear models?

I am trying to find the best transformations for my data to use in a linear model. I call summary(lm(log10(Y)~X3^2) and get a RSE of 0.1787.

Then I saved my data and call a summary of the same data just by the object names summary(lm(log10_Y~X3squared) and get a RSE of 0.1735.

I have checked my saved data and they are correct, i.e., identical to the original columns. How can the RSE be different for identical data?

## 1 Answer

Your intuition is right - if you use the same variables and fit the same model. The results has to be identical.

Given that the results are different something must have changed.

In fact, you are getting two different results because of how you specify the model.

mod1 = lm(log(Girth)~Volume^2, trees)
summary(mod1)


Vs.

trees$nY = log(trees$Girth)
trees$nX = trees$Volume^2
mod2 = lm(nY~nX, trees)
summary(mod2)


If we dig a little deeper and compare the data used to fit both models, we will see that they are in fact different

> head(mod1$model) log(Girth) Volume 1 2.116256 10.3 2 2.151762 10.3 3 2.174752 10.2 4 2.351375 16.4 5 2.370244 18.8 6 2.379546 19.7  Vs. > head(mod2$model)
nY     nX
1 2.116256 106.09
2 2.151762 106.09
3 2.174752 104.04
4 2.351375 268.96
5 2.370244 353.44
6 2.379546 388.09


In mod1 we see that Volume has not been squared!, hence this is the reason why you are seeing different RSEs. The ^ actually has a special meaning when specifying a model formula, you can read more about it here.

If you are trying to fit Volume^2, you can use the following command: lm(log(Girth)~I(Volume^2), trees).

• That is so helpful, thank you. – D.man Apr 27 '20 at 3:52
• No problem. Great question! – nwaldo Apr 27 '20 at 4:53