Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Bootstrap ordered heckman with 2SLS in secondstage


From   <htakesh2@illinois.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Bootstrap ordered heckman with 2SLS in secondstage
Date   Thu, 17 Jul 2008 22:25:56 -0500 (CDT)

Dear all, 

I am running ordered heckman with 2SLS in the second stage and trying to use bootstrap to obtain standard errors for the second stage regression which uses "ivreg2" (I am not sure if I can use "oheckman" in this case). 

I keep getting the error message 
"estimation command error: e(k_eq) is larger than the number of equations" and 
"captured error running (cps_ols), posting missing values" 
so STATA end the compilation after just 1 run of bootstrap. 

I appreciate if I can get any suggestions for this problem. Thank you. 

Below is the code I wrote. 

**** 
program cps_ols, eclass 

oprobit regime2 hhdsize gender age_h 
tempvar pick_opro    
predict `pick_opro' if e(sample), xb 
tempvar x_opro a2 
scalar `a2' = _b[/cut2] 
gen `x_opro' = `pick_opro'-1 
tempvar lambda_opro 
gen `lambda_opro' = normalden(`x_opro')/normal(`x_opro') 
  
ivreg2 lnh `lambda_opro' hhdsize (lnp = gender age_h) if regime == 2 

tempvar used 
gen byte `used' = e(sample) 
tempname b 
mat `b' = e(b) 
local eqnames: coleq e(b), quoted 
local col_names: colnames e(b) 
tokenize `col_names' 
local first `1' 
mac shift 
local rest1 `*' 
mat coleq `b' = `eqnames' 
mat colnames `b' = pick_opro `rest1' 
tempname V 
mat `V' = I(colsof(`b')) 
mat coleq `V' = `eqnames' 
mat roweq `V' = `eqnames' 
mat rownames `V' = pick_opro `rest1' 
mat colnames `V' = pick_opro `rest1'   
ereturn post `b' `V', esample(`used') 

end 

bootstrap "cps_ols" _b, rep(100) 
*** 
Hiroyuki Takeshima 
Graduate Research Assistant 
Department of Agricultural and Consumer Economics 
University of Illinois at Urbana-Champaign 
326 Mumford Hall 
1301 W. Gregory 
Urbana , IL 61801 
htakesh2@illinois.edu 
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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