Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Instrumental Variables example library(sem) #If gets error, add code < install.packages(Hmisc,dependecies=T)> or download a new version R studio wages
# Instrumental Variables example library(sem) #If gets error, add code< install.packages("Hmisc",dependecies=T)> or download a new version R studio wages<-read.csv('http://inta.gatech.s3.amazonaws.com/wage2.csv') iv.results<-tsls(lwage ~ educ + age + married + black + exper, ~ feduc + age + married + black + exper, data=wages) ols.results<-lm(lwage ~ educ + age + married + black + exper, data=wages) print(summary(ols.results)) print(summary(iv.results)) library(MASS) start.model<-lm(wage ~ hours + IQ + KWW + educ + exper + tenure + age + married + black + south + urban + sibs, data=wages) summary(start.model) stepwise.model<- step(start.model) summary(stepwise.model) stepwise.model.interactions <- step(start.model, scope=wage~.^2) summary(stepwise.model.interactions)
below is a screenshot for the code: