Data from here: https://canvas.uoregon.edu/courses/175081/files/fo...
Now, please download the dataset hw1_2018.csv onto your computer.
Make sure in R Studio you install two packages: tidyverse, and broom. I'll walk you through your R script. Unless there is a double space, things go on the same line.
In your script file at the top type:
To read in your dataset, next type (after updating the directory for where you put the data)
gross_test <- read_csv "C:/Users/benja/Dropbox/HealthvUndergrad/R examples/HW1.csv")
Now run a linear regression of days_poor_health on age, and educ.
ols1 <- lm (days_poor_health ~ coll+age, data=gross_test)
What is the estimated effect of education on days in poor health?
What is the estimated effect of age on days in poor health?
Next you need to estimate the first stage for an IV regression.
###College Height as instrument
first <- lm (coll ~ act+age, data=gross_test)
#### storing predicted values
coll_hat <- fitted(first)
What is the estimated effect of ACT test score on college completion?
Now you need to estimate the second stage of two stage least squares.
### SEcond Stage
second <- lm (days_poor_health ~ coll_hat+age, data=gross_test)
What is the estimated effect of college attainment on health now?