You may notice that r-squared is not the same in the original model as in the two subsequent versions. The solution simply must pass through (0,0) instead of (\overline{x},\overline{y}). Among other things, the reason r-squared is different is that the total sum of squares in y is not \sum (y_{i} - \overline{y})^2 but is \sum y^2 in the last two versions. This is not the same model.
The classic invariant solution to this problem is to center all the variables; notice these are identical in every way except for the y-intercept being zero to near computer precision [5.088e-16].
For cars:
> summary(lm(mpg~wt+disp, data=mtcars))
Call:
lm(formula = mpg ~ wt + disp, data = mtcars)
Residuals:
Min 1Q Median 3Q Max
-3.4087 -2.3243 -0.7683 1.7721 6.3484
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 34.96055 2.16454 16.151 4.91e-16 ***
wt -3.35082 1.16413 -2.878 0.00743 **
disp -0.01773 0.00919 -1.929 0.06362 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.917 on 29 degrees of freedom
Multiple R-squared: 0.7809, Adjusted R-squared: 0.7658
F-statistic: 51.69 on 2 and 29 DF, p-value: 2.744e-10
> summary(lm(scale(mpg, scale=FALSE)~scale(wt, scale=FALSE)+scale(disp, scale=FALSE), data=mtcars))
Call:
lm(formula = scale(mpg, scale = FALSE) ~ scale(wt, scale = FALSE) +
scale(disp, scale = FALSE), data = mtcars)
Residuals:
Min 1Q Median 3Q Max
-3.4087 -2.3243 -0.7683 1.7721 6.3484
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.088e-16 5.156e-01 0.000 1.00000
scale(wt, scale = FALSE) -3.351e+00 1.164e+00 -2.878 0.00743 **
scale(disp, scale = FALSE) -1.772e-02 9.190e-03 -1.929 0.06362 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.917 on 29 degrees of freedom
Multiple R-squared: 0.7809, Adjusted R-squared: 0.7658
F-statistic: 51.69 on 2 and 29 DF, p-value: 2.744e-10