Fitting models in R where coefficients are subject to linear restriction(s)?

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.

81.7k 32 32 gold badges 199 199 silver badges 654 654 bronze badges asked Jan 13, 2011 at 12:07 6,564 4 4 gold badges 40 40 silver badges 50 50 bronze badges

3 Answers 3

$\begingroup$

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 = ) lm(formula = Y ~ I(2*X1 + X2) + X3, data = )