[R] adding predictor to linear model without changingexistingcoefficients

Gerrit Eichner Gerrit.Eichner at math.uni-giessen.de
Wed May 17 10:12:13 CEST 2017

Hello, Urs,

you may have seen Wolfgang Viechtbauer's answer already which offers
an R-technical solution, but this may leave the mathematical grounds
of linear models. See inline below for my concern and a hint.

Am 17.05.2017 um 09:12 schrieb Urs Kleinholdermann:
> Dear list members,
> I want to add a predictor to a linear model without changing the
> coefficients of the existing model. How is that done with R?
> So if I have a response y and predictors x1, x2, x3 I want to make a model lm1 like
> lm1 = lm(y~x1+x2)
> After this model is computed I want to add x3 like
> lm2 = lm(y~x1+x2+x3)
> However, unlike it is done by the notation above or by update or add1
> (as far as I understand) I don't want a new model with all predictors
> estimated anew but I want a model lm2 where the coefficients for x1 and
> x2 stay exactly as in lm1 and the coefficent for x3 is estimated
> additionally. The reasons for this are theoretical.

And the reasons why this is usually impossible (for a valid linear
model as a projection of the response vector onto a linear subspace
spanned by the columns of the design matrix) are also theoretical:
It is not an R problem, but a mathematical fact that unless the vector
of values of a new model term is orthogonal to the vectors of all model
terms already included in the model (i.e., to all columns of its design
matrix) the estimated coefficients of the "old" model are correlated
with the estimated coefficient of the "new" one, and hence the already
existing ones change. So, if you manage to obtain orthogonality you can
achieve what you desire. (You may want to consult with a (theoretical)
book on linear models ... or a local statistician.)

Hth  --  Gerrit

> I guess what I want is similar to calculating a new regression on
> the residuals of lm1.
> lm2 = lm(residuals(lm1)~x3)
> however, I would prefer to to that in the common framework of the lm
> command in order to calculate statistics, perform anova on the models
> and so on.
> thanks for your help!
> Urs
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list