[R] instrumental variables regression using ivreg (AER) or tsls (sem)

Ranjan Maitra maitra.mbox.ignored at inbox.com
Thu Nov 29 23:27:46 CET 2012


Dear friends,

I am trying to understand and implement instrumental variables
regression using R.

I found a small (simple) example here which purportedly illustrates the
mechanics (using 2-stage least-squares):

http://www.r-bloggers.com/a-simple-instrumental-variables-problem/

Basically, here are the R commands (reproducible example) from that
site:

# ------ begin R 

library(AER)

library(lmtest)

data("CollegeDistance")

cd.d<-CollegeDistance

simple.ed.1s<- lm(education ~ distance,data=cd.d)

cd.d$ed.pred<- predict(simple.ed.1s)

simple.ed.2s<- lm(wage ~ urban + gender + ethnicity + unemp + ed.pred ,
data=cd.d) 

# ------ end R


This yields the following summary:

summary(simple.ed.2s)

Call:
lm(formula = wage ~ urban + gender + ethnicity + unemp + ed.pred, 
    data = cd.d)

Residuals:
    Min      1Q  Median      3Q     Max 
-3.1692 -0.8294  0.1502  0.8482  3.9537 

Coefficients:
                   Estimate Std. Error t value Pr(>|t|)    
(Intercept)       -2.053604   1.675314  -1.226   0.2203    
urbanyes          -0.013588   0.046403  -0.293   0.7697    
genderfemale      -0.086700   0.036909  -2.349   0.0189 *  
ethnicityafam     -0.566524   0.051686 -10.961  < 2e-16 ***
ethnicityhispanic -0.529088   0.048429 -10.925  < 2e-16 ***
unemp              0.145806   0.006969  20.922  < 2e-16 ***
ed.pred            0.774340   0.120372   6.433 1.38e-10 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 1.263 on 4732 degrees of freedom
Multiple R-squared: 0.1175,	Adjusted R-squared: 0.1163 
F-statistic:   105 on 6 and 4732 DF,  p-value: < 2.2e-16 



Question: Assuming that the above illustration is correct, I was
wondering how I could mimic these calculations using the ivreg () in
AER or tsls () in sem?

Any suggestions? 

Many thanks in advance, and best wishes,
Ranjan

-- 
Important Notice: This mailbox is ignored: e-mails are set to be
deleted on receipt. For those needing to send personal or professional
e-mail, please use appropriate addresses.

____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!



More information about the R-help mailing list