How should I define a model formula in R, when one (or more) exact linear restrictions binding the coefficients is available. As an example, say that you know that b1 = 2*b0 in a simple linear regression model.


Suppose your model is

$ Y(t) = \beta_0 + \beta_1 \cdot X_1(t) + \beta_2 \cdot X_2(t) + \varepsilon(t)$

and you are planning to restrict the coefficients, for instance like:

$ \beta_1 = 2 \beta_2$

inserting the restriction, rewriting the original regression model you will get

$ Y(t) = \beta_0 + 2 \beta_2 \cdot X_1(t) + \beta_2 \cdot X_2(t) + \varepsilon(t) $

$ Y(t) = \beta_0 + \beta_2 (2 \cdot X_1(t) + X_2(t)) + \varepsilon(t)$

introduce a new variable $Z(t) = 2 \cdot X_1(t) + X_2(t)$ and your model with restriction will be

$ Y(t) = \beta_0 + \beta_2 Z(t) + \varepsilon(t)$

In this way you can handle any exact restrictions, because the number of equal signs reduces the number of unknown parameters by the same number.

Playing with R formulas you can do directly by I() function

lm(formula = Y ~ I(1 + 2*X1) + X2 + X3 - 1, data = <your data>) 
lm(formula = Y ~ I(2*X1 + X2) + X3, data = <your data>)
  • $\begingroup$ This is pretty clear, but the question was suggesting a restriction between b0 and b1. Should I also create a new variable Z = 2X + 1 and fit a model without intercept? $\endgroup$ – George Dontas Jan 13 '11 at 13:04
  • 2
    $\begingroup$ I think usualy I is used instead of eval in formulas, i.e. Y~I(1+2*X1)+X2+X3-1 $\endgroup$ – mpiktas Jan 13 '11 at 13:21
  • $\begingroup$ @gd047: I have updated with a code pieces, yes it is as you say. @mpiktas: will change this, yes it is shorter ;) $\endgroup$ – Dmitrij Celov Jan 13 '11 at 13:21
  • 4
    $\begingroup$ This is a good answer for the general theoretical approach, but for an easier way to actually implement these hypotheses in R, which also has the advantage of not requiring one to estimate multiple models, see linearHypothesis() in the car package. $\endgroup$ – Jake Westfall May 23 '13 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.