Simultaneous Equations Models (Chapter 16)

Comments will follow…

setwd('...')

library('foreign')
library('AER') # install.packages('AER') # Package for estimating IV models

rm(list=ls())

# Data that we will use
download.file('http://fmwww.bc.edu/ec-p/data/wooldridge/mroz.dta','mroz.dta',mode="wb")
download.file('http://fmwww.bc.edu/ec-p/data/wooldridge/openness.dta','openness.dta',mode="wb")
download.file('http://fmwww.bc.edu/ec-p/data/wooldridge/consump.dta','consump.dta',mode="wb")
download.file('http://fmwww.bc.edu/ec-p/data/wooldridge/prison.dta','prison.dta',mode="wb")


# 16.5
mroz<-read.dta('mroz.dta')

s.iv.1<-summary(iv.1<-ivreg(hours ~ lwage + educ + age + kidslt6 + nwifeinc |
                              educ + age + kidslt6 + nwifeinc + exper + expersq,
                            data=mroz))
s.iv.1


lm.1<-lm(lwage ~ educ + age + kidslt6 + nwifeinc + exper + expersq,
   data=mroz[mroz$inlf==1,])
lm.2<-lm(hours ~ lwage + educ + age + kidslt6 + nwifeinc + lm.1$residuals,
         data=mroz[mroz$inlf==1,])
summary(lm.2)

# 16.6
openness<-read.dta('openness.dta')

s.lm.1<-summary(lm.1<-lm(open ~ lpcinc + lland, data=openness))
s.lm.1

s.iv.1<-summary(iv.1<-ivreg(inf ~ open +lpcinc |
                              lpcinc + lland,
                            data=openness))
s.iv.1

# 16.7
consump<-read.dta('consump.dta')

s.iv.1<-summary(iv.1<-ivreg(gc ~ gy + r3 |
                              gc_1 + gy_1 +r3_1,
                            data=consump))
s.iv.1

# 16.8
prison<-read.dta('prison.dta')

s.lm.1<-summary(lm.1<-lm(gcriv ~ y81 + y82 + y83 + y84 + y85 + y86 + y87 + y88 +
                           y89 + y90 + y91 + y92 + y93 + gpris + gpolpc + gincpc +
                           cunem + cblack + cmetro + cag0_14 + cag15_17 + cag18_24 +
                           cag25_34,
                         data=prison))
s.lm.1

s.iv.1<-summary(iv.1<-ivreg(gcriv ~ y81 + y82 + y83 + y84 + y85 + y86 + y87 + y88 +
                              y89 + y90 + y91 + y92 + y93 + gpris + gpolpc + gincpc +
                              cunem + cblack + cmetro + cag0_14 + cag15_17 + cag18_24 +
                              cag25_34 |
                              y81 + y82 + y83 + y84 + y85 + y86 + y87 + y88 +
                              y89 + y90 + y91 + y92 + y93 + gpolpc + gincpc +
                              cunem + cblack + cmetro + cag0_14 + cag15_17 + cag18_24 +
                              cag25_34 + final1 + final2,
                            data=prison))
s.iv.1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s