我是斯塔塔的初学者。我试图运行以下回归:
regress logy logI logh logL
但是我想把logh
的斜率限制为一个。有人能告诉我这个命令吗?
发布于 2014-04-03 23:36:16
在斯塔塔,至少有三种方法可以做到这一点。
1)使用约束线性回归:
. sysuse auto
(1978 Automobile Data)
. constraint 1 mpg = 1
. cnsreg price mpg weight, constraints(1)
Constrained linear regression Number of obs = 74
Root MSE = 2502.5449
( 1) mpg = 1
------------------------------------------------------------------------------
price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
mpg | 1 (constrained)
weight | 2.050071 .3768697 5.44 0.000 1.298795 2.801347
_cons | -46.14764 1174.541 -0.04 0.969 -2387.551 2295.256
------------------------------------------------------------------------------
2)变量转换(由whuber在上面的评论中建议):
. gen price2 = price - mpg
. reg price2 weight
Source | SS df MS Number of obs = 74
-------------+------------------------------ F( 1, 72) = 29.59
Model | 185318670 1 185318670 Prob > F = 0.0000
Residual | 450916627 72 6262730.93 R-squared = 0.2913
-------------+------------------------------ Adj R-squared = 0.2814
Total | 636235297 73 8715552.01 Root MSE = 2502.5
------------------------------------------------------------------------------
price2 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | 2.050071 .3768697 5.44 0.000 1.298795 2.801347
_cons | -46.14764 1174.541 -0.04 0.969 -2387.551 2295.256
------------------------------------------------------------------------------
3)使用具有偏移量的GLM模型:
. glm price weight , family(gaussian) link(identity) offset(mpg)
Iteration 0: log likelihood = -683.04238
Iteration 1: log likelihood = -683.04238
Generalized linear models No. of obs = 74
Optimization : ML Residual df = 72
Scale parameter = 6262731
Deviance = 450916626.9 (1/df) Deviance = 6262731
Pearson = 450916626.9 (1/df) Pearson = 6262731
Variance function: V(u) = 1 [Gaussian]
Link function : g(u) = u [Identity]
AIC = 18.51466
Log likelihood = -683.0423847 BIC = 4.51e+08
------------------------------------------------------------------------------
| OIM
price | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | 2.050071 .3768697 5.44 0.000 1.31142 2.788722
_cons | -46.14764 1174.541 -0.04 0.969 -2348.205 2255.909
mpg | 1 (offset)
------------------------------------------------------------------------------
如果适当地更改链接和家庭选项,glm路由还可以为您处理结果的日志转换。
https://stackoverflow.com/questions/22861496
复制相似问题