楼主: tmdxyz
29197 38

[作图问题求助] 如何画分位数回归后的这种图 [推广有奖]

11
hqu_sun 在职认证  发表于 2011-6-16 09:56:16
那个图是R的吧

12
pingzhu1990 发表于 2011-8-12 21:48:15
sungmoo 发表于 2010-4-22 12:53
*手工操作(0.05~0.95,19个分位点,x的估计系数的图像)
preserve
loc s=0
版主您好~
我的编程能力极其有限,程序没太理解,就直接套用的,就是把程序中y和x换成了我的变量名称,结果显示如下:红色是出问题的地方,绿色是我加载的自己的变量。
不知道出了什么问题,能麻烦您给我看看吗?感激不尽!

. preserve

.
. loc s=0

.
. mat b=J(19,4,.)

.
. forv i=0.05(0.05)1{
  2.
. loc s=`s'+1
  3.
. qreg  lw m workage edu han, q(`i')
  4.
. predictnl b=_b[edu], ci(lo up)
  5.
. mat b[`s',1]=`i'
  6.
. mat b[`s',2]=b[1]
  7.
. mat b[`s',3]=lo[1]
  8.
. mat b[`s',4]=up[1]
  9.
. drop b l u
10.
. }
Iteration  1:  WLS sum of weighted deviations =  267.12611

Iteration  1: sum of abs. weighted deviations =  270.16683
Iteration  2: sum of abs. weighted deviations =  197.77124
Iteration  3: sum of abs. weighted deviations =  143.57681
Iteration  4: sum of abs. weighted deviations =  119.73458
Iteration  5: sum of abs. weighted deviations =  105.14784
Iteration  6: sum of abs. weighted deviations =  104.50444
Iteration  7: sum of abs. weighted deviations =  93.163863
Iteration  8: sum of abs. weighted deviations =  85.482668
Iteration  9: sum of abs. weighted deviations =  84.774639
Iteration 10: sum of abs. weighted deviations =  84.508331
Iteration 11: sum of abs. weighted deviations =  84.484432
Iteration 12: sum of abs. weighted deviations =  83.288993
Iteration 13: sum of abs. weighted deviations =  82.929077
Iteration 14: sum of abs. weighted deviations =  82.633191
Iteration 15: sum of abs. weighted deviations =  82.602378
Iteration 16: sum of abs. weighted deviations =  82.602378
Iteration 17: sum of abs. weighted deviations =  82.596511
Iteration 18: sum of abs. weighted deviations =  82.596511
Iteration 19: sum of abs. weighted deviations =  82.592156

.05 Quantile regression                              Number of obs =       649
  Raw sum of deviations 95.82249 (about 5.7037826)
  Min sum of deviations 82.59216                     Pseudo R2     =    0.1381

------------------------------------------------------------------------------
          lw |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
           m |   .2646556    .125722     2.11   0.036     .0177811    .5115302
     workage |  -.0119254   .0071892    -1.66   0.098    -.0260426    .0021917
         edu |   .1337953   .0142054     9.42   0.000     .1059008    .1616899
         han |   .0442619   .1429128     0.31   0.757    -.2363694    .3248932
       _cons |   4.246894   .2706284    15.69   0.000     3.715474    4.778315
------------------------------------------------------------------------------
Warning: prediction constant over observations; perhaps you meant to run nlcom.
note: Confidence intervals calculated using t(644) critical values.
l ambiguous abbreviation
r(111)
;

.
. clear

.
. svmat b
number of observations will be reset to 19
Press any key to continue, or Break to abort
obs was 0, now 19

.
. tw rarea b3 b4 b1||scatter b2 b1,c(l)

.
. restore

.

13
h3327156 发表于 2011-8-13 00:18:54
这一题测好久…
我的感觉啦!
sungmoo版主用法都很精简。
问题出在drop b l u
其实您的红色不也暗示问题的所在?

以下测试,【第一个会出现与您一样的状况,调一下就不会有问题了】
******************
sysuse auto
preserve
loc s=0
mat b=J(19,4,.)
forv i=0.05(0.05)1{
loc s=`s'+1
qreg price weight length foreign , q(`i')
predictnl b=_b[weight], ci(lo up)
mat b[`s',1]=`i'
mat b[`s',2]=b[1]
mat b[`s',3]=lo[1]
mat b[`s',4]=up[1]
drop b l u
}

clear
svmat b
tw rarea b3 b4 b1||scatter b2 b1,c(l)
restore

*******************
sysuse auto
preserve
loc s=0
mat b=J(19,4,.)
forv i=0.05(0.05)1{
loc s=`s'+1
qreg price weight length foreign , q(`i')
predictnl b=_b[weight], ci(lo up)
mat b[`s',1]=`i'
mat b[`s',2]=b[1]
mat b[`s',3]=lo[1]
mat b[`s',4]=up[1]
drop b lo u
}

clear
svmat b
tw rarea b3 b4 b1||scatter b2 b1,c(l)
restore

*********************

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
h894510055 + 1 + 1 + 1 热心帮助其他会员

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

受到警告 14
xge2000 发表于 2011-8-13 08:58:58
提示: 受到警告  蓝色 灌水 2011-8-13 09:13
rightttttttttttttttttttttttttttttt

15
aizhihui2009 发表于 2011-8-13 11:26:30
grqreg命令足够了,而且还可以通过boostrap得到置信区间图。

16
jiangbogz 发表于 2011-11-15 13:58:11
已阅!                           
看庭前花开花落;
望天上云卷云舒。

17
iloveyou21 发表于 2011-11-15 15:16:04
好东西,收藏了,真是有启发

18
zhangzhendaxue 发表于 2011-11-24 11:14:15
这个图形该怎么解释呢?

19
whywjwzx 发表于 2011-11-30 17:27:08
程序不懂,还是找命令吧!
淡淡如斯

20
whywjwzx 发表于 2011-11-30 17:42:47
很喜欢人大经济论坛,查了一下午stata的书也没搞明白分位数回归怎么作图,论坛上一查就搞定,感谢一下各位大虾!顶
淡淡如斯

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-29 15:14