Hi guys,
I am trying to replicate a two step procedure with bootstrap. It is basically a 2SLS where in the second stage we put residuals instead of fitted values.
My panel database looks as follows:
Now I would like to replicate the sample estimates obtained by:
with a bootstrap procedure as follows:
The problem is that I do not get the expected results (i.e. sample coefficients are different from bootstrapped coefficients). I read about issues in using lag variables with bootstrap. Can someone please help me?
Thanks,
Federico
I am trying to replicate a two step procedure with bootstrap. It is basically a 2SLS where in the second stage we put residuals instead of fitted values.
My panel database looks as follows:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(idatc3 Year y_firststage y_second 1 2004 16.353962 0 1 2005 16.340631 1 1 2006 16.286907 0 1 2007 16.273083 0 1 2008 16.255836 0 1 2009 15.925304 0 1 2010 15.859792 0 2 2004 18.146786 0 2 2005 18.185635 1 2 2006 18.199041 0 2 2007 18.194345 0 2 2008 18.213171 0 2 2009 18.345274 0 2 2010 18.226433 0 3 2004 13.705626 3 3 2005 15.13613 7 3 2006 16.208109 1 3 2007 16.591629 3 3 2008 16.917368 0 3 2009 17.030642 2 3 2010 17.209492 5 4 2004 16.50014 25 4 2005 16.745003 8 4 2006 16.75969 6 4 2007 17.048187 14 4 2008 17.244335 2 4 2009 17.343176 0 4 2010 17.933966 2 5 2004 17.868816 0 5 2005 17.693306 0 5 2006 17.696056 2 5 2007 17.748852 4 5 2008 17.76949 0 5 2009 17.838858 0 5 2010 17.91857 0 6 2004 19.07523 0 6 2005 18.995157 0 6 2006 18.959908 0 6 2007 18.898798 1 6 2008 18.66919 0 6 2009 18.642822 0 6 2010 18.255278 0 7 2004 22.090456 1 7 2005 22.101965 0 7 2006 22.116083 2 7 2007 22.14667 0 7 2008 22.0739 2 7 2009 22.06895 0 7 2010 21.95814 0 8 2004 17.097506 2 8 2005 16.42637 2 8 2006 16.32611 0 8 2007 16.537579 0 8 2008 16.272715 0 8 2009 16.364277 0 8 2010 15.86466 0 9 2004 18.293467 2 9 2005 18.54712 0 9 2006 18.760092 0 9 2007 17.585657 0 9 2008 15.65171 1 9 2009 15.918745 0 9 2010 18.139769 0 10 2004 20.34576 0 10 2005 20.38664 2 10 2006 20.52285 1 10 2007 20.07849 0 10 2008 19.609467 0 10 2009 19.61134 1 10 2010 19.63593 0 11 2004 15.633678 0 11 2005 16.186264 0 11 2006 16.36874 2 11 2007 16.868628 0 11 2008 16.864525 0 11 2009 16.66895 0 11 2010 16.688057 0 12 2004 18.850607 2 12 2005 18.661394 0 12 2006 18.685404 0 12 2007 18.935335 0 12 2008 19.289694 0 12 2009 19.490005 0 12 2010 18.965286 0 13 2004 15.167782 1 13 2005 15.652504 0 13 2006 16.465668 0 13 2007 16.760597 0 13 2008 16.878334 0 13 2009 17.17612 0 13 2010 18.00114 0 14 2004 19.100143 2 14 2005 18.629805 0 14 2006 18.49677 0 14 2007 18.35715 0 14 2008 18.183216 0 14 2009 18.108658 0 14 2010 18.07056 0 15 2004 17.956966 0 15 2005 18.202034 0 end
Code:
use "/Users/federiconutarelli/Desktop/DB_atc3.dta", clear rename tot_count trials 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 idatc3) predict residuals, e 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:
use "/Users/federiconutarelli/Desktop/DB_atc3.dta", clear rename tot_count trials 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 idatc3) predict residuals, e 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) keep if e(sample) capture program drop onebootrep program define onebootrep preserve //data will be restored after program termination (quindi ogni volta che il programma finisce i dati sono restored) 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) cap drop residuals predict residuals, e 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) end tsset, clear gen newid = idatc3 xtset newid Year capture bootstrap _b _se, cluster(idatc3) idcluster(newid) seed(1234) reps(200) saving(coeffse, replace) nodots nowarn: onebootrep
Thanks,
Federico
Comment