1 / 6

Running Tobit on Simulated Data in Stata /Mata

Joseph Guse Econ 398 Fall 2012. Running Tobit on Simulated Data in Stata /Mata. Why Generate Artificial Data?. A basic question that one might ask about an estimation procedure is how it would perform under various data generating mechanisms.

abe
Download Presentation

Running Tobit on Simulated Data in Stata /Mata

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Joseph Guse Econ 398 Fall 2012 Running Tobit on Simulated Data in Stata/Mata

  2. Why Generate Artificial Data? • A basic question that one might ask about an estimation procedure is how it would perform under various data generating mechanisms. • t-stats and other inferences tools can lend a false sense of statistical confidence even when your model is mis-specified. • Using Mata, one can simulate data from just about any model. • Test whether your identification strategy would work under any hypothesis about how the data was generated.

  3. The “true” (made-up) Data generating process. • We will work with a very simple model of charitable giving amenable to estimation with a tobit regression. • The “true” model has a “latent” variable, Giving*: Giving* = -10000 + 0.1*Income + e • In the data, however, we only observed “censored” giving. That is, whenever the latent giving is negative, we see zero: Giving = max{0,Giving*} • Use the code “makeTobitData.do” to generate this data.

  4. Instructions for Using “makeTobitData.do”Part 1: Downloading and Compiling. • Create/Designate PERSONAL. Designate a directory as your PERSONAL Stata directory; let’s call it persDir (For me, persDir = h:\stata\bin). This is where Stata will saved compiled Mata programs and also where it will look for such programs when you call them from a Stata command line. • Set your PERSONAL Direcotry. Open Stata and type: • sysdir set PERSONAL persDir so I would type: • sysdir set PERSONAL h:\stata\bin • Download do file. Go to: http://home.wlu.edu/~gusej/econ398/lectures/tobit/makeTobitData.do and save to a directory of your choice (it doesn’t have to be the same directory you designated as PERSONAL, but it could be; I keep my stata source code in h:\stata\source whereas the compiled programs get stored in h:\stata\bin, my PERSONAL Stata directory.) 4. Open do file Editor. In Stata, open a new do file editor (Window -> DoFile Editor -> new do File Editor) • Open do file. From the do file editor open makeTobitData.do by navigating the file chooser to where ever you saved it in step (3). • Exectute do File. In the do-file editor, choose “Tools -> Execute” . If you check your PERSONAL directory, you should now see a file call makeTobitData.mo. This is the compiled program that can be called from Stata.

  5. Instruction for Using “makeTobitData.do”Part II: Calling mata program from Stata • Clear Stata. From your Stata command line (not the do-file Editor), type “clear all”. This will erase any data currently stored in Stata, so be sure that you have saved anything you care about. • Create artificial data. Type: matamakeTobitData(4000) “4000” (or whatever integer you put in there) will be the number of observations created by the program. • Run Regressions. Try the following regress giving income tobit giving income, ll(0) • Explain. What is the difference in the estimated coefficients produced by OLS and tobit regressions. Why?

  6. Explore the Mata Code Try modifying the true model in the mata code. For example… • Change the intercept from -10000 to something else. • Change the coefficient on income • Add another variable to the model • Change the standard deviation on the error term. Don’t forget to re-compile your code after making modifications. Use the “scatter” command in Stata to get a picture of the data. Report the output from running a Tobit regression on the data generated by your modified code to me for extra credit.

More Related