搜索
人大经济论坛 附件下载

附件下载

所在主题:
文件名:  R软件 Farnsworth-EconometricsIn R.pdf
资料下载链接地址: https://bbs.pinggu.org/a-483656.html
附件大小:
296.47 KB   举报本内容
Econometrics in R
Grant V. Farnsworth
October 26, 2008
This paper was originally written as part of a teaching assistantship and has subsequently become a personal reference.
I learned most of this stu by trial and error, so it may contain ineciencies, inaccuracies, or incomplete explanations. If
you nd something here suboptimal or have suggestions, please let me know. Until at least 2009 I can be contacted at
g-farnsworth@kellogg.northwestern.edu.
Contents
1 Introductory Comments 3
1.1 What is R? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 How is R Better Than Other Packages? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Obtaining R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Using R Interactively and Writing Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Working with Data 6
2.1 Basic Data Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Caveat: Math Operations and the Recycling Rule . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Important Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.1 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.2 Arrays, Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.3 Dataframes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.4 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.5 S3 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3.6 S4 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Working with Dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 Merging Dataframes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.6 Opening a Data File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.7 Working With Very Large Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.7.1 Reading elds of data using scan() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.7.2 Utilizing Unix Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.7.3 Using Disk instead of RAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.7.4 Using RSQLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.8 Issuing System Commands|Directory Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.9 Reading Data From the Clipboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.10 Editing Data Directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3 Cross Sectional Regression 14
3.1 Ordinary Least Squares . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 Extracting Statistics from the Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3 Heteroskedasticity and Friends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.3.1 Breusch-Pagan Test for Heteroskedasticity . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.3.2 Heteroskedasticity (Autocorrelation) Robust Covariance Matrix . . . . . . . . . . . . . 16
3.4 Linear Hypothesis Testing (Wald and F) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.5 Weighted and Generalized Least Squares . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.6 Models With Factors/Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4 Special Regressions 18
4.1 Fixed/Random E ects Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.1.1 Fixed E ects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.1.2 Random E ects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2 Qualitative Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.1 Logit/Probit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.2 Multinomial Logit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.3 Ordered Logit/Probit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.3 Tobit and Censored Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.4 Quantile Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.5 Robust Regression - M Estimators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.6 Nonlinear Least Squares . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.7 Two Stage Least Squares on a Single Structural Equation . . . . . . . . . . . . . . . . . . . . 21
4.8 Systems of Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2
4.8.1 Seemingly Unrelated Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.8.2 Two Stage Least Squares on a System . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5 Time Series Regression 22
5.1 Di erences and Lags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.2 Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23


    熟悉论坛请点击新手指南
下载说明
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。
2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。
3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。
(如有侵权,欢迎举报)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

GMT+8, 2025-12-24 22:42