Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Bootstrap in two-stage models

From   "Brian P. Poi" <>
Subject   Re: st: Bootstrap in two-stage models
Date   Fri, 18 Feb 2005 10:28:11 -0600 (CST)

On Fri, 18 Feb 2005, nolwenn roudaut wrote:

Dear All,

I want to estimate a treatment effect model, a two-stage model with a probit
model in the first and an OLS in the second.

I cannot use the 'treatreg' stata program as some of my hypothesis are different
from the classical ones.
So I need to compute the two-step corrected variance-covariance matrix "by

One way to do this is to use the Murphy-Topel correction procedure. (I thank a
statalister that provided me his program last month).

Another way (and this is the one I am interested in) is to use bootstrap
Does anyone knows how to implement this method?


One alternative may be to use the -bootstrap- command along with
-treatreg, twostep-.  That would provide bootstrap standard errors
for the classic two-step treatment effects model.

In the program below I do just that, using the dataset described in
[R] treatreg.  Then I write my own program that illustrates how to
replicate the results from -bootstrap- and -treatreg, twostep-.
The only thing of note is that even though we are bootstrapping,
to use -ereturn post- we must provide a variance matrix; the
identity matrix is fine as long as the row and column names
match the column names of our parameter vector.

webuse labor, clear
gen wc = cond(we>12, 1, 0)

set seed 1
bootstrap "treatreg ww wa cit, treat(wc=wmed wfed) twostep" _b, reps(50)

program mytreat, eclass

        // Stage 1 probit
        probit wc wmed wfed
        tempname b
        mat `b' = e(b)

        // Get the hazard ratio
        tempvar xb hazard
        predict double `xb', xb
        generate double `hazard' = .
        replace `hazard' = normden(`xb') / norm(`xb') if wc==1
        replace `hazard' = -1*normden(`xb') / (1-norm(`xb')) if wc==0

        // Now do the second step
        regress ww wa cit wc `hazard'
        tempvar used
        gen byte `used' = e(sample)

        mat `b' = `b', e(b)	// `b' has [<probit coefs> <reg coefs>]
        mat colnames `b' = pr_wmed pr_wfed pr_cons wa cit wc hazard _cons

        // Need a variance matrix for -ereturn post-
        // The identity matrix is fine, since we don't
        // really care what is in it.
        tempname V
        mat `V' = I(colsof(`b'))
        mat rownames `V' = pr_wmed pr_wfed pr_cons wa cit wc hazard _cons
        mat colnames `V' = pr_wmed pr_wfed pr_cons wa cit wc hazard _cons

        ereturn post `b' `V', esample(`used')


set seed 1
bootstrap "mytreat" _b, reps(50)

Hope this helps

   -- Brian Poi
*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index