Hello,
Using Stata 13.1, I am running a Heckman two-step regression. I am bootstrapping the difference of two fitted values. (The original data has synthetic set to 1. I then collapse the data by sex and set synthetic equal to 3. I am finding the difference between the fitted values with an associated synthetic value of 3). When I run the bootstrap command I receive the following error message: "insufficient observations to compute bootstrap standard errors." The program works when I run just the OLS (or second stage regression) and crashes once I add the probit. Additionally, the program itself works and can be run multiple times without generating errors.
Because I wanted to make the code more accessible, I made a version using auto.dta. Surprisingly, I am able to bootstrap the program; yet I am not able to distinguish the differences in the code that may be driving the errors in my initial program.
Thank you!
Using Stata 13.1, I am running a Heckman two-step regression. I am bootstrapping the difference of two fitted values. (The original data has synthetic set to 1. I then collapse the data by sex and set synthetic equal to 3. I am finding the difference between the fitted values with an associated synthetic value of 3). When I run the bootstrap command I receive the following error message: "insufficient observations to compute bootstrap standard errors." The program works when I run just the OLS (or second stage regression) and crashes once I add the probit. Additionally, the program itself works and can be run multiple times without generating errors.
Because I wanted to make the code more accessible, I made a version using auto.dta. Surprisingly, I am able to bootstrap the program; yet I am not able to distinguish the differences in the code that may be driving the errors in my initial program.
Code:
use MR_work/mr_datasets/temp_all.dta, clear * regressors* global regs1 "widowed divorced separated never_married midwest south west hsd08 hsd911 hsg cg ad pot_exp1 pot_exp2 pot_exp3 pot_exp4 hsd08_pot_exp1 hsd08_pot_exp2 hsd08_pot_exp3 hsd08_pot_exp4 hsd911_pot_exp1 hsd911_pot_exp2 hsd911_pot_exp3 hsd911_pot_exp4 hsg_pot_exp1 hsg_pot_exp2 hsg_pot_exp3 hsg_pot_exp4 cg_pot_exp1 cg_pot_exp2 cg_pot_exp3 cg_pot_exp4 ad_pot_exp1 ad_pot_exp2 ad_pot_exp3 ad_pot_exp4" global probit_regs " __child06 child06_widowed child06_divorced child06_separated child06_never_married" global regs2 "sex*" ************************** *Define bootstrap program* ************************** capture prog drop bias70s90s prog define bias70s90s, rclass set more off append using MR_work/mr_datasets/tempV2.dta //add 2 observations with synthetic==3 probit ftfy $regs1 $probit_regs if sex==1 & timepd==0 & synthetic==1 [pweight=wgt] tempvar lambda_input lambda_female predict `lambda_input' if sex==1, xb gen `lambda_female' = normalden(-`lambda_input') / (1 - normal(-`lambda_input')) if timepd==0 replace `lambda_female'=0 if sex==0 replace `lambda_female'=0 if synthetic>1 reg log_hourly_wage $regs1 $regs2 `lambda_female' if timepd==0 & wagesmpl==1 [pw=wgt], robust tempvar xb predict `xb' sum `xb' if sex==1 & synthetic==3 local m1=r(mean) sum `xb' if sex==0 & synthetic==3 local m2=r(mean) return scalar ols0_fix=`m1'-`m2' drop if synthetic>1 end ** end bootstrap loop *Run bootstrap command* bootstrap r(ols0_fix), reps(10) seed(123) strata(timepd): bias70s90s
Code:
sysuse auto, clear gen synthetic=1 global regs1 "mpg" global regs2 "weight" capture prog drop bias70s90s ************************** *Define bootstrap program* ************************** prog define bias70s90s, rclass set more off append using "C:\Users\Briana\Desktop\Temporary\auto_temp.dta" //created by collapse, by(foreign) probit foreign $regs2 if synthetic==1 tempvar lambda_input lambda_female predict `lambda_input', xb gen `lambda_female' = normalden(-`lambda_input') / (1 - normal(-`lambda_input')) replace `lambda_female'=0 if synthetic==2 reg displacement $regs1 `lambda_female' if synthetic==1, robust tempvar xb predict `xb' sum `xb' if foreign==1 & synthetic==2 local m1=r(mean) sum `xb' if foreign==0 & synthetic==2 local m2=r(mean) return scalar ols0_fix=`m1'-`m2' drop if synthetic>1 end ** end bootstrap loop *Run bootstrap command* bootstrap r(ols0_fix), reps(10) seed(123): bias70s90s
Comment