Solved – Adding a quadratic term: should I use the squared original (and not the squared standardized?)

logisticquadratic formstandardization

In a multiple logistic regression I need to standardize one of the variables because I need to add a quadratic term. Whether I add the quadratic term as the squared original or the squared standardized, I get very similar models, same AIC. Why? The estimates of the linear term change.
When I square a standardized variable, I get positive numbers after squaring half of the data (which are negative) and that should completely mess up my data. Why does it not? Can someone please explain the mathematical reason behind it and tell me if I definitely should use the squared original and if I can use the squared standardized, why does it work?
I notice this is a mathematics question rather than anything but I searched and could not find anything related to this.

Best Answer

Let the variable be $x$, its mean be $\mu$, and its standard deviation $\sigma$, so that the standardized variable is $z = (x-\mu)/\sigma$. By expanding $z^2$ and collecting like powers of $x$ you can rewrite your model as

$$\eqalign{ y &= \beta_0 + \beta_1 x + \beta_2 z^2 + \varepsilon \\ &= \beta_0 + \beta_1 x + \beta_2 \left(\frac{x-\mu}{\sigma}\right)^2 + \varepsilon\\ &= \left(\beta_0 + \beta_2\frac{\mu^2}{\sigma^2}\right) + \left(\beta_1 + \beta_2\left(-2\frac{\mu}{\sigma}\right)\right)x + \left(\frac{\beta_2}{\sigma^2}\right)x^2 + \varepsilon \\ &= \alpha_0 + \alpha_1 x + \alpha_2 x^2 + \varepsilon }$$

where the $\alpha_i$ are functions of the parameters $\beta_i$ depending on the constants $\mu$ and $\sigma$ and the error terms $\varepsilon$ are the same as before. (Other multivariate regression terms would be unchanged and are not shown.) This means that one model will fit the data exactly as well as the other: any differences can be attributable to floating point rounding errors. (If they are not really tiny, you likely have huge collinearity problems.) Moreover, the parameter estimates obtained with one model can be converted to corresponding estimates with the other model, provided the estimation procedure is invariant under linear changes of parameters (which is the case with Maximum Likelihood, which is what is being used when an AIC is reported).

In short, you don't have to standardize the variable when squaring it: you get an equivalent model even when it is not standardized. Because the software will automatically standardize all variables when solving, you are free to write the model in whatever form you find most interpretable.

Related Question