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.

Answer

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>)

Attribution
Source : Link , Question Author : George Dontas , Answer Author : Dmitrij Celov

Leave a Comment