打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
qrprocess:高效好用的分位数回归命令

🍎 连享会主页:lianxh.cn

「十年口碑,桃李三千」
🎦 2021 Stata 暑期班
📅 2021 年 7 月 20-30 日
🔑 连玉君(中山大学);江艇 (中国人民大学)
🍓 课程主页https://gitee.com/lianxh/PX

New! lianxh 命令发布了:   GIF 动图介绍
随时搜索 Stata 推文、教程、手册、论坛,安装命令如下:
. ssc install lianxh

作者:赵玉 (山东大学)
邮箱:zhaoyu_yep@163.com


目录

  • 1. 背景介绍

  • 2. qrprocess 命令介绍

    • 2.1 理论介绍

    • 2.2 安装与语法结构

  • 3. Stata 实例

  • 4. 结语

  • 5. 参考资料

  • 6. 相关推文


温馨提示: 文中链接在微信中无法生效。请点击底部「阅读原文」。或直接长按/扫描如下二维码,直达原文:

1. 背景介绍

在连享会以往的推文中,我们介绍了分位数回归的基本方法(具体链接链接见「6. 相关推文」),包括总体分位数,样本分位数以及面板分位数回归模型。

分位数方法之所以被广泛使用,关键取决于快速算法的存在。尽管在算法上目前已有很多改进,但计算时间仍然是不可忽略的。本文主要向大家介绍一种分位数回归命令 qrprocess,这一命令与 Stata 官方命令 qreg 的估计结果相近,但运算速度约为前者的 30 倍。

引述一段 Chernozhukov, V., I. Fernández-Val, and B. Melly. 2020a. Fast algorithms for the quantile regression process. Working paper. -PDF- 在结论部分的观点:

Instead of bootstrapping the quantile regression estimates, it is possible to bootstrap the score (or estimating equation) of the estimator. This approach amounts in fact to using the one-step estimator to compute the bootstrap estimate when we take the sample estimate as a preliminary guess. This inference procedure, which has been suggested for quantile regression by Chernozhukov and Hansen (2006) and Belloni et al. (2017), is extremely fast and can also be used to perform uniform inference. Its drawback is the necessity to choose a smoothing parameter to estimate the conditional density of the response variable given the covariates.

The simulations we report in Section 6 show that the preprocessing algorithm is 30 times faster than Stata’s built-in algorithm when we have 50, 000 observations, 20 regressors and we estimate 99 quantile regressions. The onestep estimator further divides the computing time by almost 4. The preprocessing step applied to the bootstrap of a single quantile regression divides the computing time by about 10. The score multiplier bootstrap further divides the computing time by 10 compared to the preprocessing algorithm. Thus, these new algorithms open new possibilities for quantile regression methods. For instance, in the application reported in Section 7, we could estimate 91 different quantile regressions in a sample of 2, 194, 021 observations, with 14 regressors and bootstrap 100 times the estimates in about 30 minutes on a laptop. The same estimation with the built-in commands of Stata would take over two months. The codes in Stata and some rudimentary codes in R are available from the authors.

2. qrprocess 命令介绍

2.1 理论介绍

的随机样本,Bassett and Koenker (1978) 的分位数回归估计量为:

其中, 为系数向量, 为线性损失函数,对 ,。此公式为最基础的公式,当然还存在一系列的改进模型,如 Chernozhukov, Fernández-Val and Melly (2020a) 提供了新的算法,有关 Stata 命令的更多详细信息请参照 Fernández-Val and Melly (2020b)。

2.2 安装与语法结构

qrprocess 命令是 Chernozhukov, Fernández-Val and Melly (2020) 编写的 Stata 新命令,安装命令如下:

. ssc install qrprocess, replace

该命令依赖于 moremata,需预先安装:

. ssc install moremata, replace

如果无法直接安装,可以使用如下推文中介绍的手动安装方法:

  • moremata 程序包手动安装方法

亦可直接执行如下命令:

. net install moremata, from(https://file.lianxh.cn/StataCMD/moremata) replace force

qrprocess 命令语法结构如下:

. help qrprocess
. qrprocess depvar [indepvars] [if] [in] [weight] [, options]

. depvar:被解释变量;
. indepvars:解释变量;
. Options:
. quantile(numlist):指定要估计的分位数;默认值为0.5(中位数)
. method([mtype], [mopts]):指定用于计算分位数回归估计的算法方法以及控制算法结束的参数
. vce([vtype], [vopts]):指定用于估计标准误差
. functional:提供置信区间、假设检验
. level(#):设置置信水平;默认值为水平为0.95
. noprint:禁止显示结果

3. Stata 实例

我们使用 qrprocess 命令来实现分位数回归模型,这里我们使用 Stata 自带的数据 auto.dta。

首先进行中位数回归:

. sysuse auto, clear

. qrprocess price mpg weight length foreign // 中位数回归

Quantile regression
No. of obs. 74
Algorithm: qreg.
Variance: kernel estimate of the sandwich as proposed by Powell(1990).

--------------------------------------------------------------------------
priceCoef. Std. Err.tP>t [95% Conf.Interval]
--------------------------------------------------------------------------
Quant. 0.5
mpg6.297878134.95090.050.963-262.9217275.5175
weight3.9335882.4871041.580.118-1.0267858.893961
length -41.2519172.577 -0.570.572-186.0022103.4984
foreign3377.7711411.45 2.390.019 562.72226192.82
_cons344.64897452.5840.050.963-14519.0615208.36
--------------------------------------------------------------------------

有上述结果可知,mpg 每增加一单位,会使价格中位数增加 6.30 个单位,即当汽车每加仑能行走的公里数提高一个单位,中档价位的汽车便会增加 6.30 个单位,但统计结果上并不显著。

进一步地,用 bootstrap 标准误差估计 0.25、0.5、0.75 分位点上的回归结果:

. qrprocess price mpg weight length foreign, vce(boot) quantile(0.25 0.5 0.75)
(bootstrapping .......................)

Quantile regression
No. of obs. 74
Algorithm: qreg.
Variance: empirical bootstrap.



-------------------------------------------------------------------------
priceCoef. Std. Err.tP>t [95% Conf.Interval]
-------------------------------------------------------------------------
Quant. 0.25
mpg 6.8590554.473290.130.900-101.8122115.5303
weight1.9037341.3984221.360.178-.88604224.69351
length2.03783427.913240.070.942-53.6475657.72323
foreign2253.604935.75262.410.019386.82914120.38
_cons-2097.6583569.829-0.590.559-9219.2715023.956
-------------------------------------------------------------------------
Quant. 0.5
mpg6.297878134.95090.050.963-262.9217275.5175
weight3.9335882.4871041.580.118-1.0267858.893961
length -41.2519172.577 -0.570.572-186.0022103.4984
foreign3377.7711411.45 2.390.019 562.72226192.82
_cons344.64897452.5840.050.963-14519.0615208.36
-------------------------------------------------------------------------
Quant. 0.75
mpg-47.17156166.7631-0.280.778-379.8547285.5116
weight9.1394582.5307523.610.0014.09074614.18817
length-226.854585.49465-2.650.010-397.4116-56.2973
foreign3343.1271130.8742.960.0041087.0965599.159
_cons22606.3812346.161.830.071-2023.52647236.29
-------------------------------------------------------------------------

估计 0.1,0.2,…,0.9 分位数的离散分位数回归过程,并绘制所有系数:

. qrprocess price mpg weight length foreign, quantile(0.1(0.01)0.9) noprint
. plotprocess

4. 结语

关于 qrprocess 的基本介绍在这里就结束了,想要深入了解的学者可以阅读下方的参考资料,或者 help qrprocess 查看相关命令的应用与介绍。

5. 参考资料

  • Angrist J, Chernozhukov V, Fern´andez-Val I (2006) Quantile regression under misspecification, with an application to the us wage structure. Econometrica 74: 539–563. -PDF-
  • Bassett, Gilbert, and Roger Koenker. 1978. “Asymptotic Theory of Least Absolute Error Regression.” Journal of the American Statistical Association 73 (363): 618–22. -PDF-
  • Chernozhukov, V., I. Fernández-Val, and B. Melly. 2020a. Fast algorithms for the quantile regression process. Working paper. -PDF-
  • Chernozhukov, V., I. Fernández-Val, and B. Melly. 2020b. Quantile and distribution regression in Stata: algorithms, pointwise and functional inference. Working paper.
  • Chernozhukov V, Hansen C (2006) Instrumental quantile regression inference for structural and treatment effect models. Journal of Econometrics 132:491–
  1. -PDF-
  • Koenker R (2005) Quantile Regression. Cambridge University Press. -Link-PDF-, 有权限的用户可以在线阅读

6. 相关推文

Note:产生如下推文列表的 Stata 命令为:
lianxh 分位数
安装最新版 lianxh 命令:
ssc install lianxh, replace

  • 专题:专题课程
    • 连享会直播:分位数回归
  • 专题:回归分析
    • Stata+R:分位数回归一文读懂
    • Stata:分位数回归简介
  • 专题:内生性-因果推断
    • Stata:分位数回归中的样本自选择问题
  • 专题:分位数回归
    • qregplot:分位数回归图示-T359
    • Stata:面板分位数模型估计及内生性初探

🍎 🍏 🍎 🍏
🎧 暑期 空间计量专题
📅 2021 年 8 月 21-24 日
🔑 范巧 (兰州大学);杨海生 (中山大学)
🍓 课程主页https://gitee.com/lianxh/SP

关于我们

  • 🍎 连享会 ( 主页:lianxh.cn ) 由中山大学连玉君老师团队创办,定期分享实证分析经验。
  • 👉 直达连享会:百度一下:连享会】即可直达连享会主页。亦可进一步添加 主页,知乎,面板数据,研究设计 等关键词细化搜索。
连享会主页  lianxh.cn

New! lianxh 命令发布了:    GIF 动图介绍
随时搜索连享会推文、Stata 资源,安装命令如下:
. ssc install lianxh
使用详情参见帮助文件 (有惊喜):
. help lianxh

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
qregplot:分位数回归图示
分位数回归stata实现
用R语言进行分位数回归(Quantile Regression)
带你读论文 | 值分布强化学习
med4way:中介效应和交互效应分析
推荐一篇《中国工业经济》上门槛回归方法论文
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服