**R-exercises**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This is the third part of the series on Instrumental Variables. For other parts of the series follow the tag instrumental variables.

In this exercise set we will use Generalized Method of Moments (GMM) estimation technique using the examples from part-1 and part-2.

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.

Answers to the exercises are available here.

**Exercise 1**

Load the AER package (package description: here) and the `PSID1976`

dataset. This has data regarding labor force participation of married women.

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.

Next, load the ‘gmm’ package (package description: here).

**Exercise 2**

We will start with a simple example. Regress `log(wage)`

on `education`

using the usual OLS technique.

Next, use the `gmm`

function to estimate the same model using OLS’s moment conditions. Match your result and comment on the standard errors.

**Exercise 3**

Estimate the return to education for the model from Exercise-2 using `feducation`

as the IV. Use both `ivreg`

and `gmm`

functions and compare results.

**Exercise 4**

Regress `log(wage)`

on `education`

, `experience`

and `experience^2`

using the usual OLS technique.

Next, use the `gmm`

function to estimate the same model using OLS’s moment conditions. Match your result.

**Exercise 5**

Estimate the return to education for the model from Exercise-4 using `feducation`

as the IV. Use both `ivreg`

and `gmm`

functions and compare results.

**Exercise 6**

We will now use the over-identified case. Estimate the return to education for the model from Exercise-2 using `feducation`

and `meducation`

as IVs. Use both `ivreg`

and `gmm`

functions and compare results.

**Exercise 7**

Estimate the return to education for the model from Exercise-4 using `feducation`

and `meducation`

as IVs. Use both `ivreg`

and `gmm`

functions and compare results.

**Exercise 8**

The test of over-identifying restrictions can be obtained by the J-test (Sargan test). It is displayed with the `summary`

and `specTest`

functions. Do the over-identified moment conditions match the data well?

**Exercise 9**

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.

**Exercise 10**

Use the `plot`

function to get the graph of `log(wage)`

and fitted values for the model in Exercise-7.

**leave a comment**for the author, please follow the link and comment on their blog:

**R-exercises**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.