Stata, Fast and Slow: Why Running Many Small Regressions in a Large Dataset Takes So Long; and What to Do About It

P. Geertsema
{"title":"Stata, Fast and Slow: Why Running Many Small Regressions in a Large Dataset Takes So Long; and What to Do About It","authors":"P. Geertsema","doi":"10.2139/ssrn.2423171","DOIUrl":null,"url":null,"abstract":"Stata is fast, often very fast. However, when performing regressions on small sub-samples within a large host dataset (more than 1 million observations) performance can deteriorate by many orders of magnitude. For example, an OLS regression on a sub-sample of 100 consecutive observations takes 3.6 seconds in a host dataset with 1 billion observations, but only 3.8 milliseconds in a host dataset with 1000 observations. The difference in performance is due to the mechanism regress uses to mark estimation samples. This performance deterioration has practical implications in finance research, where many variables of interest are themselves estimated via millions of individual OLS regressions within large panel datasets. I suggest an approach that circumvents this issue by using a simple Mata implementation of regress which I call fastreg. As a test, I estimate daily Fama and French 3-factor betas for individual stocks in the CRSP database from 1923 to 2013 using a 250-day rolling window. In this setting fastreg is approximately 367 times faster than regress. The code for fastreg ado is included in the Appendix and is open-source licensed under the GNU GPL.","PeriodicalId":320844,"journal":{"name":"PSN: Econometrics","volume":"5 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2014-04-11","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"PSN: Econometrics","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.2139/ssrn.2423171","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

Stata is fast, often very fast. However, when performing regressions on small sub-samples within a large host dataset (more than 1 million observations) performance can deteriorate by many orders of magnitude. For example, an OLS regression on a sub-sample of 100 consecutive observations takes 3.6 seconds in a host dataset with 1 billion observations, but only 3.8 milliseconds in a host dataset with 1000 observations. The difference in performance is due to the mechanism regress uses to mark estimation samples. This performance deterioration has practical implications in finance research, where many variables of interest are themselves estimated via millions of individual OLS regressions within large panel datasets. I suggest an approach that circumvents this issue by using a simple Mata implementation of regress which I call fastreg. As a test, I estimate daily Fama and French 3-factor betas for individual stocks in the CRSP database from 1923 to 2013 using a 250-day rolling window. In this setting fastreg is approximately 367 times faster than regress. The code for fastreg ado is included in the Appendix and is open-source licensed under the GNU GPL.
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
Stata,快与慢:为什么在大数据集中运行许多小回归需要这么长时间以及如何应对
Stata速度很快,通常非常快。然而,当对大型主机数据集(超过100万个观测值)中的小子样本执行回归时,性能可能会下降许多数量级。例如,在具有10亿个观测值的主机数据集中,对100个连续观测值的子样本进行OLS回归需要3.6秒,但在具有1000个观测值的主机数据集中只需要3.8毫秒。性能上的差异是由于回归用来标记估计样本的机制。这种性能恶化在金融研究中具有实际意义,在金融研究中,许多感兴趣的变量本身是通过大型面板数据集中数百万个单独的OLS回归来估计的。我建议一种绕过这个问题的方法,即使用一个简单的Mata回归实现,我称之为fastreg。作为测试,我使用250天滚动窗口,估计了1923年至2013年CRSP数据库中个股的每日Fama和French三因子贝塔系数。在这个设置中,fastreg比回归快大约367倍。fastreg ado的代码包含在附录中,并且是基于GNU GPL的开源许可。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Robust Inference for Moment Condition Models without Rational Expectations Augmented cointegrating linear models with possibly strongly correlated stationary and nonstationary regressors regressors Structured Additive Regression and Tree Boosting Large-Scale Precision Matrix Estimation With SQUIC Error Correction Models and Regressions for Non-Cointegrated Variables
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1