开发者

Constrained least squares

I am fitting a simple regression in R on gas usage per capita. The regression formulas looks like:

gas_b <- lm(log(gasq_pop) ~ log(gasp) + log(pcincome) + log(pn) +
       开发者_Go百科     log(pd) + log(ps) + log(years), 
            data=gas)
summary(gas_b)

I want to include a linear constraint that the beta coefficients of log(pn)+log(pd)+log(ps)=1 (sum to one). Is there a simple way of implementing this (possibly in the lm function) in R without having to use constrOptim() function?


Modify your regression as follows:

gas_b <- lm(log(gasq_pop) - log(ps) ~ log(gasp) + log(pcincome) +
  I(log(pn)-log(ps)) + I(log(pd)-log(ps)) + log(years), data=gas) 
summary(gas_b)

If b=coef(gas_b), then the relevant coefficients are

log(pn): b[4]
log(pd): b[5]
log(ps): 1 - b[4] - b[5]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜