<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/instrumental-variables-in-r-exercises-part-2/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.r-exercises.com/2017/05/22/instrumental-variables-in-r-exercises-part-2/?utm_source=rss&utm_medium=rss&utm_campaign=instrumental-variables-in-r-exercises-part-2"> R-exercises</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a target="_blank" rel="nofollow" href="https://i0.wp.com/www.r-exercises.com/wp-content/uploads/2017/05/Rplot_set1.jpeg"><img sizes="(max-width: 150px) 100vw, 150px" alt="" class="wp-image-5754" src="https://i2.wp.com/www.r-exercises.com/wp-content/uploads/2017/05/Rplot_set1-150x150.jpeg?resize=150%2C150" data-recalc-dims="1"></a></p>
<p>This is the second part of the series on Instrumental Variables. For other parts of the series follow the tag <a target="_blank" rel="nofollow" href="http://www.r-exercises.com/tag/instrumental-variables/">instrumental variables</a>.</p>
<p>In this exercise set we will build on the example from <a target="_blank" rel="nofollow" href="http://www.r-exercises.com/2017/05/15/instrumental-variables-in-r-exercises-part-1/">part-1</a>.<br>
We will now consider an over-identified case i.e. we have multiple IVs for an endogenous variable. We will also look at tests for endogeneity and over-identifying restrictions.</p>
<p>Answers to the exercises are available <a target="_blank" rel="nofollow" href="http://r-exercises.com/2017/05/22/instrumental-variables-in-r-exercises-part-2-solutions/">here</a>.</p>
<p><strong>Exercise 1</strong><br>
Load the AER package (package description: <a target="_blank" rel="nofollow" href="https://cran.r-project.org/web/packages/AER/AER.pdf">here</a>). Next, load <code>PSID1976</code> dataset provided with the AER package. This has data regarding labor force participation of married women.<br>
Define a new data-frame that has data for all married women that were employed. This data-frame will be used for the following exercises.</p>
<p><strong>Exercise 2</strong><br>
We will use a more elaborate model as compared to the previous set.<br>
Regress <code>log(wage)</code> on <code>education</code>, <code>experience</code> and <code>experience^2</code>.</p>
<p><strong>Exercise 3</strong><br>
Previously, we identified <code>feducation</code> and <code>meducation</code> as possible IVs for <code>education</code>.<br>
Regress <code>education</code> on <code>experience</code>, <code>experience^2</code>, <code>feducation</code> and <code>meducation</code>. Comment on your results.</p>
<p><strong>Exercise 4</strong><br>
Test the hypothesis that <code>feducation</code> and <code>meducation</code> are jointly equal to zero.</p>
<p><strong>Exercise 5</strong><br>
Use 2SLS to estimate the IV based return to education.</p>
<p><strong>Exercise 6</strong><br>
Use the <code>ivreg</code> command to get the same results as in Exercise-5. Note that standard errors would be different.</p>
<p><strong>Exercise 7</strong><br>
There is a short form for the <code>ivreg</code> command which saves time when we are dealing with numerous variables.<br>
Try the short format and check that you get the same results as in Exercise-6.</p>
<p><strong>Exercise 8</strong><br>
Regress <code>log(wage)</code> on <code>education</code>, <code>experience</code>, <code>experience^2</code> and residuals from the model estimated in Exercise-3.<br>
Use your result to test for the endogeneity of <code>education</code>.</p>
<p><strong>Exercise 9</strong><br>
Regress the residuals from exercise-7 on <code>experience</code>, <code>experience^2</code>, <code>feducation</code> and <code>meducation</code>.<br>
Use your result to test for over-identifying restrictions.</p>
<p><strong>Exercise 10</strong><br>
The two tests we did in exercises 8 and 9 can be conveniently obtained using the <code>summary</code> command with diagnostics turned on. Verify that you get the same test results with the <code>summary</code> command.</p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a title="Instrumental Variables in R exercises (Part-1)" target="_blank" rel="nofollow" href="http://www.r-exercises.com/2017/05/15/instrumental-variables-in-r-exercises-part-1/">Instrumental Variables in R exercises (Part-1) </a></li>
<li><a title="Bioinformatics Tutorial with Exercises in R (part 1)" target="_blank" rel="nofollow" href="http://www.r-exercises.com/2017/01/22/bioinformatics-lessons-in-r-1-biostrings-exercises/">Bioinformatics Tutorial with Exercises in R (part 1) </a></li>
<li><a title="Let’s get started with dplyr" target="_blank" rel="nofollow" href="http://www.r-exercises.com/2017/01/12/lets-get-started-with-dplyr/">Let’s get started with dplyr </a></li>
<li><a target="_blank" rel="nofollow" href="http://www.r-exercises.com/start-here-to-learn-r/">Explore all our (>1000) R exercises</a></li>
<li><a target="_blank" rel="nofollow" href="http://www.r-exercises.com/r-courses/">Find an R course using our R Course Finder</a> directory</li>
</ol>
</div>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.r-exercises.com/2017/05/22/instrumental-variables-in-r-exercises-part-2/?utm_source=rss&utm_medium=rss&utm_campaign=instrumental-variables-in-r-exercises-part-2"> R-exercises</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/Vd3AjH8C7Oc"></a></div>