Hai all,
so I am performing bootstrap manually with a for loop. Basically what I am dong is to compute residuals from a first stage regression:
and put them in a poisson fixed effects regression:
Now sometimes poisson fixed effects does not converge and an error like the following appears:
which is my case at iteration 168. The code is:
What I would like to do is to ignore the error and keep looping. I wished I could do it with capture but it actually does not work. Is there a way to ignore iteration number 168 and carry on looping? Let's say I have 300 repetitions: the goal is to perform 299 repetitions ignoring the 168 (the one raising the error message)
Thank in advance,
Federico
so I am performing bootstrap manually with a for loop. Basically what I am dong is to compute residuals from a first stage regression:
Code:
capture quietly xtreg y L.major_recalls_norm average_age_prodbyatc3 avg_prd_sq mean_agefirm_byatc mean_agefirm_squared hhi share_expired share_patented i.Year, fe vce(cluster newid)
capture predict residuals, e
Code:
capture noisily quietly xtpoisson trials y residuals average_age_prodbyatc3 avg_prd_sq mean_agefirm_byatc mean_agefirm_squared hhi share_expired share_patented i.Year, fe vce(robust)
Code:
cannot compute an improvement -- discontinuous region encountered
Code:
set seed 1234
set matsize 11000
global filedata "DB_atc3.dta"
global varx "y residuals average_age_prodbyatc3 avg_prd_sq mean_agefirm_byatc mean_agefirm_squared hhi share_expired share_patented"
global resid "residuals"
global filename "bootexcel.xlsx"
global nrepl 300
local nx=0
set more off
foreach var in $varx {
local nx=`nx'+1
}
global ncol= `nx' +2
mat coeff = J($nrepl ,$ncol,.)
set more off
forval i=1/$nrepl {
use "$filedata", clear
rename tot_count trials
*bysort idatc3 (Year): gen byte panelsize = _N
bsample, cluster(idatc3) idcluster(newid)
***
capture xtset newid Year
capture quietly xtreg y L.major_recalls_norm average_age_prodbyatc3 avg_prd_sq mean_agefirm_byatc mean_agefirm_squared hhi share_expired share_patented i.Year, fe vce(cluster newid)
capture predict residuals, e
capture noisily quietly xtpoisson trials y residuals average_age_prodbyatc3 avg_prd_sq mean_agefirm_byatc mean_agefirm_squared hhi share_expired share_patented i.Year, fe vce(robust)
***
local conta=0
set more off
foreach var in $varx {
local conta=`conta'+1
mat coeff[`i',`conta']=_b[`var']
}
mat coeff[`i',`conta'+1]=_b[$resid]
di as text " Replication # `i'"
mat coeff[`i',$ncol]=`i'
}
Thank in advance,
Federico

Comment