Created
May 1, 2011 20:29
-
-
Save tony91782/950836 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ------------------------ ## | |
## An Easy IV regression ## | |
## regression command for R ## | |
## ## | |
## Author: Tony Cookson ## | |
## Commands: ivregress() ## | |
## sum.iv() ## | |
## ------------------------ ## | |
## Read Data ## | |
library(foreign) | |
mkt.df = read.dta("C://R//mktshare.dta") | |
## Run IV Regression ## | |
library(car) ## Uses linearHypothesis() from car() | |
## Define the IV object | |
mkt.iv = ivregress(Y~x1+x2+p, p~z1+z2, mkt.df) | |
## Options to summarize the IV object | |
sum.iv(mkt.iv) ## Basic Output | |
sum.iv(mkt.iv, first=T) ## Show first stage | |
##-- like Stata's ", first" | |
sum.iv(mkt.iv, ftest=T) ## F-test for relevance | |
##-- same as Stata's "estat first" | |
sum.iv(mkt.iv, overid=T) ## Test for overidentifying restrictions | |
##-- same as Stata's "estat overid" | |
sum.iv(mkt.iv, overid=T, first=T, ftest=T) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment