# Should you standardize your variables before or after removing outliers?

Barring the question of how to operationalize outliers, or the utility of doing so, and assuming dependent variables and independent variables are all scaled in the main regression specification (centered and divided by their standard deviations), should the scaling happen before or after outlier removal?

Specifically, I'm wondering if the p-values from coefficients will be affected at all by this decision?

Here is a simulation of what I'm talking about:

meeting_count <- c(.01, .02, .01, .05, .03, .025)

revenue_pre_scaled = scale(revenue)
summary(lm(revenue_scaled[0:4] ~ meeting_count[0:4]))

revenue_post_scaled = scale(revenue[0:4])
summary(lm(revenue_post_scaled ~ meeting_count[0:4]))


Perhaps this is just dumb luck, but here are the summary outputs

> summary(lm(revenue_post_scaled ~ meeting_count[0:4]))
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)          -1.025      0.526   -1.95     0.19
meeting_count[0:4]   45.572     18.893    2.41     0.14

> summary(lm(revenue_scaled[0:4] ~ meeting_count[0:4]))
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)        -0.42611    0.00536  -79.57  0.00016 ***
meeting_count[0:4]  0.46401    0.19237    2.41  0.13734

• It depends on the specifics of the model. In standard applications, where the model is linear in all the variables, scaling doesn't do anything to the solutions or the p-values, so it doesn't matter how you do it (or even whether you do it at all), except insofar as it might affect numerical precision. Could you therefore make your question more specific?
– whuber
Jul 2 '19 at 16:04
• @whuber, the actual model is a standard lm() regression that looks like this: lm(y ~ x + x^2)` where all variables have been standardized. The question is whether to standardize y and x before or after the removal of outliers. It appears as if the p-values are unaffected. Are the beta estimates also supposed to be equivalent, but the decimal point just shifted over twice? Jul 3 '19 at 14:50
• No, but the beta estimates have a predictable relationship to each other. I believe this is answered at stats.stackexchange.com/questions/68202. The p-value of the intercept, BTW, changes because the two tests are not the same: the original test compares the intercept to $0$ while the test based on transformed values of the regressors and response is tantamount to comparing the original intercept to some other number, usually nonzero. Again, that other number can be predicted and is easily computed in terms of the transformations that were applied.
– whuber
Jul 3 '19 at 14:54
• Other relevant posts include stats.stackexchange.com/questions/47178 (addressing the quadratic term) and stats.stackexchange.com/questions/110171.
– whuber
Jul 3 '19 at 14:58