# Linear regression scaling independent variables

I am trying to do a linear regression.

My $y$ variable is typical pretty small approx 0 to 0.3

I have some $x$ variables (regressing them individually on $y$ to start with) though that are very large. I have some $x$ variables that are 30,000. I have been told I should rebase these $x$ variables.

My question is will this make any difference? Also what is the best way to rebase these $x$ variables assuming a linear relationship?

Using logs of the inputs will make your model nonlinear but that may be what you want. With financial data, natural log usually makes models more predictable.

Typically if you what to have the coefficients have the same scale, you normalize the inputs by: x=(x-mean(x))/stdev(x)

That being said, it actually doesn't really matter if you don't rescale the inputs as long as the software displays all of the digits. However, you won't be able to see the influence of the particular input by the coefficient magnitude due to the differing scales.

• I'm using Matlab so assuming (could be wrong) that it should be able to handle the data? If I normalize the x variable do I also have to normalize the y variable? Apr 17, 2015 at 12:55

Values of independent variables $x$ are very high compare to dependent $y$, $\beta$-value would be very small, there will be many errors like.......sampling error, rounding error.

Yes! you really need to rebase $x$, The best way is to take logs

$$\ln{\hat y}=\beta\ln{\hat x}+\alpha$$

$$\ln{y}=\beta\ln{x}+\alpha+\epsilon~~........\epsilon~is~error$$ Note:- the linear form is linear in the regression parameters associated with the covariates.

Nonlinear regression

• thanks for the reply. Will taking logs of the x variable mean the regression is no longer linear? Apr 17, 2015 at 12:23
• The correct answer is no, $x$ does not have to be rescaled, because (1) you have no idea what the rounding and sampling errors are, and if you did you would evaluate them on the scale of $y$ regardless of the scale of $x$; and (2) using either exact arithmetic or IEEE floating point, there will be no precision problems. (Numbers would have to become larger than about $10^{300}$ or smaller than $10^{-300}$ before this becomes a concern.) There could be problems using software that employs numerically unstable solution algorithms, but that should not be an issue with Matlab.
– whuber
Apr 24, 2015 at 15:52