Example: bankruptcy

Econometrics in R

Econometrics in RGrant V. Farnsworth October 26, 2008 This paper was originally written as part of a teaching assistantship and has subsequently become a personal learned most of this stuff by trial and error, so it may contain inefficiencies, inaccuracies, or incomplete explanations. Ifyou find something here suboptimal or have suggestions, please let me know. Until at least 2009 I can be contacted Introductory What is R? .. How is R Better Than Other Packages? .. Obtaining R .. Using R Interactively and Writing Scripts.

nnet Multinomial logit/probit quantreg Quantile Regressions R.matlab Read matlab data les RSQLite Interact with SQL databases sandwich (and zoo) Heteroskedasticity and autocorrelation robust covariance sem Two stage least squares survival* Tobit and censored regression

Tags:

  Econometrics, Logit, Multinomial, Multinomial logit

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Econometrics in R

1 Econometrics in RGrant V. Farnsworth October 26, 2008 This paper was originally written as part of a teaching assistantship and has subsequently become a personal learned most of this stuff by trial and error, so it may contain inefficiencies, inaccuracies, or incomplete explanations. Ifyou find something here suboptimal or have suggestions, please let me know. Until at least 2009 I can be contacted Introductory What is R? .. How is R Better Than Other Packages? .. Obtaining R .. Using R Interactively and Writing Scripts.

2 Getting Help ..52 Working with Basic Data Manipulation .. Caveat: Math Operations and the Recycling Rule .. Important Data Types .. , Matrices .. Classes .. Classes .. Working with Dates .. Merging Dataframes .. Opening a Data File .. Working With Very Large Data Files .. fields of data using scan() .. Unix Tools .. Disk instead of RAM .. RSQLite .. Issuing System Commands Directory Listing .. Reading Data From the Clipboard .. Editing Data Directly ..143 Cross Sectional Ordinary Least Squares.

3 Extracting Statistics from the Regression .. Heteroskedasticity and Friends .. Test for Heteroskedasticity .. (Autocorrelation) Robust Covariance Matrix .. Linear Hypothesis Testing (Wald and F) .. Weighted and Generalized Least Squares .. Models With Factors/Groups ..174 Special Fixed/Random Effects Models .. Effects .. Effects .. Qualitative Response .. logit .. logit /Probit .. Tobit and Censored Regression .. Quantile Regression .. Robust Regression - M Estimators .. Nonlinear Least Squares.

4 Two Stage Least Squares on a Single Structural Equation .. Systems of Equations .. Unrelated Regression .. Stage Least Squares on a System ..215 Time Series Differences and Lags .. Filters .. AR and MA filters .. Filtration .. Prescott Filter .. Filter .. ARIMA/ARFIMA .. ARCH/GARCH .. GARCH garch() .. GARCH garchFit() .. GARCH Ox G@RCH .. Correlograms .. Predicted Values .. Time Series Tests .. Test for Autocorrelation .. and Breusch-Godfrey Tests for Autocorrelation .. Test for Unit Root.

5 Vector Autoregressions (VAR) ..286 Plotting Empirical Distributions .. Contour Plots .. Adding Legends and Stuff .. Adding Arrows, Text, and Markers .. Multiple Plots .. Saving Plots png, jpg, eps, pdf, xfig .. Adding Greek Letters and Math Symbols to Plots .. Other Graphics Packages ..327 Working with Common Statistical Distributions .. P-Values .. Sampling from Data ..348 Math in Matrix Operations .. Algebra and Inversion .. Numerical Optimization .. Minimization .. with Linear Constraints.

6 Numerical Integration ..369 Writing Functions .. Looping .. Avoiding Loops .. a Function to an Array (or a Cross Section of it) .. Conditionals .. Operators .. : Conditionals and NA .. The Ternary Operator .. Outputting Text .. Pausing/Getting Input .. Timing Blocks of Code .. Calling C functions from R .. to Write the C Code .. to Use the Compiled Functions .. Calling R Functions from C ..4210 Changing Default Options .. Significant Digits .. What to do with NAs .. How to Handle Errors.

7 Suppressing Warnings ..4411 Saving Your Saving the Data .. Saving the Session Output .. Saving as LATEX ..4512 Final Comments4513 Appendix: Code Monte Carlo Simulation .. The Haar Wavelet .. Maximum Likelihood Estimation .. Extracting Info From a Large File .. Contour Plot ..481 Introductory What is R?R is an implementation of the object-oriented mathematical programming language S. It is developed bystatisticians around the world and is free software, released under the GNU General Public License. Syn-tactically and functionally it is very similar (if not identical) to S+, the popular statistics How is R Better Than Other Packages?

8 R is much more more flexible than most software used by econometricians because it is a modern mathe-matical programming language, not just a program that does regressions and tests. This means our analysisneed not be restricted to the functions included in the default package. There is an extensive and constantlyexpanding collection of libraries online for use in many disciplines. As researchers develop new algorithmsand processes, the corresponding libraries get posted on the R website. In this sense R is always at theforefront of statistical knowledge.

9 Because of the ease and flexibility of programming in R it is easy S language is thede factostandard for statistical science. Reading the statistical literature, we findthat examples and even pseudo-code are written in R-compatible syntax. Since most users have a statisticalbackground, the jargon used by R experts sometimes differs from what an econometrician (especially abeginning econometrician) may expect. A primary purpose of this document is to eliminate this languagebarrier and allow the econometrician to tap into the work of these innovative written for R can be run on many computational platforms with or without a graphical userinterface, and R comes standard with some of the most flexible and powerful graphics routines of course, R is completely free for any Obtaining RThe R installation program can be downloaded free of charge BecauseR is a programming language and not just an Econometrics program.

10 Most of the functions we will beinterested in are available through libraries (sometimes called packages) obtained from the R website. Toobtain a library that does not come with the standard installation follow theCRAN link on the abovewebsite. Undercontribyou will find is a list of compressed libraries ready for download. Click on the oneyou need and save it somewhere you can find it later. If you are using a gui, start R and clickinstall packagefrom local directoryunder thepackagemenu. Then select the file that you downloaded. Now the packagewill be available for use in the future.


Related search queries