<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/instrumental-variables-in-r-exercises-part-3/"></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/29/instrumental-variables-in-r-exercises-part-3/?utm_source=rss&utm_medium=rss&utm_campaign=instrumental-variables-in-r-exercises-part-3"> R-exercises</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="https://i1.wp.com/www.r-exercises.com/wp-content/uploads/2017/05/Rplot_ex3.jpeg" target="_blank"><img alt="" src="https://i0.wp.com/www.r-exercises.com/wp-content/uploads/2017/05/Rplot_ex3-150x150.jpeg?resize=150%2C150" class="wp-image-5754" data-recalc-dims="1"></a></p>
<p>This is the third part of the series on Instrumental Variables. For other parts of the series follow the tag <a rel="nofollow" href="http://www.r-exercises.com/tag/instrumental-variables/" target="_blank">instrumental variables</a>.</p>
<p>In this exercise set we will use Generalized Method of Moments (GMM) estimation technique using the examples from <a rel="nofollow" href="http://www.r-exercises.com/2017/05/15/instrumental-variables-in-r-exercises-part-1/" target="_blank">part-1</a> and <a rel="nofollow" href="http://www.r-exercises.com/2017/05/22/instrumental-variables-in-r-exercises-part-2/" target="_blank">part-2</a>.<br>
Recall that GMM estimation relies on the relevant moment conditions. For OLS we assume that predictors are uncorrelated with the error term. Similarly, IV estimation implies that the instrument(s) is uncorrelated with the error term.</p>
<p>Answers to the exercises are available <a rel="nofollow" href="http://www.r-exercises.com/2017/05/29/instrumental-variables-in-r-exercises-part-3-solutions/" target="_blank">here</a>.</p>
<p><strong>Exercise 1</strong><br>
Load the AER package (package description: <a rel="nofollow" href="https://cran.r-project.org/web/packages/AER/AER.pdf" target="_blank">here</a>) and the <code>PSID1976</code> dataset. 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. As we did in part-2, this data-frame will be used for the remaining exercises.<br>
Next, load the ‘gmm’ package (package description: <a rel="nofollow" href="https://cran.r-project.org/web/packages/gmm/gmm.pdf" target="_blank">here</a>).</p>
<p><strong>Exercise 2</strong><br>
We will start with a simple example. Regress <code>log(wage)</code> on <code>education</code> using the usual OLS technique.<br>
Next, use the <code>gmm</code> function to estimate the same model using OLS’s moment conditions. Match your result and comment on the standard errors.</p>
<p><strong>Exercise 3</strong><br>
Estimate the return to education for the model from Exercise-2 using <code>feducation</code> as the IV. Use both <code>ivreg</code> and <code>gmm</code> functions and compare results.</p>
<p><strong>Exercise 4</strong><br>
Regress <code>log(wage)</code> on <code>education</code>, <code>experience</code> and <code>experience^2</code> using the usual OLS technique.<br>
Next, use the <code>gmm</code> function to estimate the same model using OLS’s moment conditions. Match your result.</p>
<p><strong>Exercise 5</strong><br>
Estimate the return to education for the model from Exercise-4 using <code>feducation</code> as the IV. Use both <code>ivreg</code> and <code>gmm</code> functions and compare results.</p>
<p><strong>Exercise 6</strong><br>
We will now use the over-identified case. Estimate the return to education for the model from Exercise-2 using <code>feducation</code> and <code>meducation</code> as IVs. Use both <code>ivreg</code> and <code>gmm</code> functions and compare results.</p>
<p><strong>Exercise 7</strong><br>
Estimate the return to education for the model from Exercise-4 using <code>feducation</code> and <code>meducation</code> as IVs. Use both <code>ivreg</code> and <code>gmm</code> functions and compare results.</p>
<p><strong>Exercise 8</strong><br>
The test of over-identifying restrictions can be obtained by the J-test (Sargan test). It is displayed with the <code>summary</code> and <code>specTest</code> functions. Do the over-identified moment conditions match the data well?</p>
<p><strong>Exercise 9</strong><br>
Iterated estimation might offer some advantages over the default two-step method in some cases. Estimate the model in Exercise-7 using the iterative estimation technique.</p>
<p><strong>Exercise 10</strong><br>
Use the <code>plot</code> function to get the graph of <code>log(wage)</code> and fitted values for the model in Exercise-7.</p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/05/15/instrumental-variables-in-r-exercises-part-1/" title="Instrumental Variables in R exercises (Part-1)" target="_blank">Instrumental Variables in R exercises (Part-1) </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/05/22/instrumental-variables-in-r-exercises-part-2/" title="Instrumental Variables in R exercises (Part-2)" target="_blank">Instrumental Variables in R exercises (Part-2) </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/05/05/forecasting-arimax-model-exercises-part-5/" title="Forecasting: ARIMAX Model Exercises (Part-5)" target="_blank">Forecasting: ARIMAX Model Exercises (Part-5) </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/start-here-to-learn-r/" target="_blank">Explore all our (>1000) R exercises</a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/r-courses/" target="_blank">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/29/instrumental-variables-in-r-exercises-part-3/?utm_source=rss&utm_medium=rss&utm_campaign=instrumental-variables-in-r-exercises-part-3"> 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 rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/I3MqiaRN_DE" height="1"></a></div>