约束最小二乘法 [英] Constrained least squares
本文介绍了约束最小二乘法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对人均燃气使用量的R进行了简单回归.回归公式如下:
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) +
log(pd) + log(ps) + log(years),
data=gas)
summary(gas_b)
我想包含一个线性约束,即log(pn)+log(pd)+log(ps)=1
的beta系数(总和为1).是否有一种简单的方法可以在R中实现此功能(可能在lm
函数中)而无需使用constrOptim()
函数?
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?
推荐答案
按如下所示修改回归:
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)
如果为b=coef(gas_b)
,则相关系数为
log(pn): b[4]
log(pd): b[5]
log(ps): 1 - b[4] - b[5]
这篇关于约束最小二乘法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文