60 likes | 208 Views
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.
E N D
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. • 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.
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.
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.
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?
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.