# Mutliple linear regression and variable collinearity

I think I need an explanation about the nature of the summary when making a lm on R. Does someone could explain to me that:

When you make an analysis of variance on a lm model (ex: aov(lm(Y~X1+X2)), it is actually observed that when there is a collinearity between the explanatory variables, the order of entry of the variables in the regression model analysis is important because SCEs are calculated sequentially, so the first input variable will capture all the variance and the others less, so if you make the same model but whith this variables order: aov(lm(Y~X2+X1)), the p.value will change.

But I do not understand why, when you permut the order of entry of the variables on a lm model as : Y~X1+X2, the summary of the multiple regression model returns the slope coefficient estimates but why there is not the same kind of problem as the aov? I mean why the slope coefficient are still the same when you permut the order of the variables: Y~X1+X2 and Y~X2+X1?

The difference in behavior between aov() and lm() has to do with the types of comparisons that are being made by the two functions.
With your two-predictor formula, aov() with its Type I significance tests is comparing different models: a model without predictors against a model with only the first predictor, then the model with the first predictor against a model that adds the second predictor. With unbalanced designs and multicollinearity of predictors the order of entry will matter, as the first-entered predictor will pick up some of the variance that might actually be due to a correlated but later-entered predictor. Note that there are other types of ANOVA test that avoid this problem but potentially introduce others; this page is a superb introduction to differences in ANOVA test types.
With lm() the standard comparisons are of each individual estimated regression coefficient against a value of 0. All predictors are effectively evaluated in parallel in the full model. Unlike aov(), there's no comparison of different models, just whether the value of each coefficient is sufficiently far from 0 given the standard error of the coefficient.
What lm() doesn't do, however, is provide an estimate of the overall significance of a multi-level categorical predictor, a continuous predictor modeled with polynomials or splines; in general, any predictors that show up in multiple terms in the regression model. For that you need some type of ANOVA test and make appropriate choices among the types of tests explained in the page linked above.