24.01.2013 Views

handout - Daina Chiba

handout - Daina Chiba

handout - Daina Chiba

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.2 Calculating Substantive Effects (a.k.a., CLARIFY “by hand”)<br />

Suppose you want to calculate substantive effects of some variable after running some fancy<br />

statistical model, but CLARIFY does not support the model. In this case, you have to<br />

implement the CLARIFY procedure “by hand.” I believe Randy has already covered how to<br />

do it with Stata, so I will show you how to do it with R.<br />

Assume further that the model you want to estimate is not readily available in R. For<br />

example, models such as Heckman’s probit, Sartori’s selection model, von Stein’s selection<br />

model, and censored duration model by Boehmke et al. can be easily estimated on Stata<br />

with ado file, but estimating these models in R requires a bit of programming. 2<br />

1. Estimate a model in Stata<br />

2. Save the estiamtes (coefficient vector and variance covariance matrix) and export them<br />

as a text file<br />

3. From R, import the estimates<br />

4. Simulate coefficients ( ˜ β)<br />

5. Set X of your interest at some value while holding the other variables at mean or<br />

median.<br />

6. Calculate E(Y) = F (X ˜ β), where F (·) is some link function (probit, logit, etc.)<br />

7. Repeat the steps 5 and 6<br />

As we have already completed the steps 1 & 2 in Section 2.3, we will begin with 3.<br />

A nice thing about using R is that we don’t really need to iterate the Steps 5 and 6<br />

using loop. Instead, we will use matrix to set X at many values and calculate E(Y) in one<br />

iteration.<br />

Step 3: Importing estimates from Stata<br />

Run the following chunk of R code (in 2_RPart.R).<br />

R code<br />

> beta vcov std.err z.score p.value reg.tbl colnames(reg.tbl) reg.tbl<br />

Compare the table shown in your R window and the one in your Stata window. They should<br />

be identical.<br />

2 In the future, you might want to learn how to program these models in R, but for now, let’s assume<br />

that we don’t have time to do it.<br />

13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!