Update 2: [15 May 2011] The function I wrote here does not work with factors due to the way in which I constructed fitted values for the standard error correction in the second stage.
I recorded a new video tutorial on how to conduct an IV regression. This time I used my new ivregress() command, which has much better syntax than my old one. There are several reasons I needed to do this:
- Relative to my previous post on IV regression, I have added the ability to conduct overidentifying tests. Now, my ivregress() command has all of the basic functionality of Stata's 2sls option to ivregress.
- Relative to my previous video tutorial on IV regression, this video uses my newer command, which as much better syntax. As such, I will use this video tutorial to replace the old one.
To get ivregress() and sum.iv() to work, (1) copy the text in the above text box into an R script, (2) run all (or just download and run the R script) and (3) save into your default workspace if you want to use the commands into the future. Then, you're good to go. See my video demonstrating how to use the command here:
Here is the code I used to produce the output in the video.
Finally, here is a link to the synthetic "market share" data I used in the video.
I hope you find this command helpful.
Hey Tony,
ReplyDeleteCan you tell me if this package is geared for your specific data set or have you tried multiple data sets?
Douglas from Michigan
Douglas,
ReplyDeleteI have tested it on my own data set (to make sure it matches Stata's calculations exactly), but I wrote the function to work for any data set where you have one endogenous variable (and possibly many instruments). If you have more than one endogenous variable, my function won't do that (yet... I may add that functionality in my next update).
Tony,
ReplyDeleteGreat video and code. Thanks!
Would it be possible to share the code used to generate the dataset mktshare.dta ?
Also the link to the data (mktshare.dta) seems to have too many redirects. Can you make it available as a CSV file (mktshare.dta.SCV.txt)?
Thanks,
James