Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Errors arise when dataset is modified in Bootstrapping


From   Zhi Su <[email protected]>
To   statalist <[email protected]>
Subject   st: Errors arise when dataset is modified in Bootstrapping
Date   Tue, 12 Jul 2011 15:58:36 -0400

Dear Statalists,
I bootstrap standard error from a written estimation command and get
the following warning:

"Because NHreg is not an estimation command or does not set e(sample),
bootstrap has no way to determine which observations are used in
calculating the statistics and so assumes that all observations are
used.  This means that no observations will be excluded from the
resampling because of missing values or other reasons."

Here are parts of the program NHreg

capture program drop NHreg
program define NHreg, eclass
  syntax varlist(max=1 numeric)
  tempname b V
  local T "T1 T2 T3 T4"
  local basic "AGE FEMALE BLACK HISPANIC MARRIED H3TOTD KID6 HS EVERFT
EMP NUMFTMOS PASTERN2 RECASS CAR ARRE HEALPRO"
  local  u "u1 u2 u3 u4"
  gsort -TR
  quietly:mvprobit (T1=`basic') (T2=`basic') (T3=`basic') (T4=`basic')
if TR==1,robust
  .
  *(notes: u1 u2 u3 u4 in the original dataset are all 0. I conduct a
process to calculate values of u1 u2 u3 u4 when TR==1)
  .
  mata: g_u()

  quietly: regress `varlist' `basic' `T' `u', robust
  matrix `b'=e(b)
  matrix `V'=e(V)
  ereturn post `b' `V'
end

clear mata
mata:
void g_u()
{
real scalar O, N
real vector Y, XBM, D
real matrix V, U, Y_si, Y_in, U_s
.
.
.
end

bootstrap _b _se, reps(50) seed(1234):NHreg e1

The command –NHreg- changes the values stored in variables “u1 u2 u3
u4” and use new value in OLS regression. And the modified dataset is
where I used -ereturn post- to specify my -e(sample)-.  When the
-restore- of -bootstrap- is performed, that -e(sample)- cannot be
assumed to be valid. I think that is why bootstrapping fails.

  How can I modify –NHreg- to let Stata understand that the –NHreg-
has changed the dataset, let –restore- of -bootstrap- to restore to
the original dataset that all u1 u2 u3 u4 are all 0, and start to
–bsample-, modified values of u1 u2 u3 u4, and run the iteration from
the very beginning?

  Thank you!

-- 
Zhi Su
348 Holmes Hall
Northeastern University
360 Huntington Avenue
Boston, MA 02115
Office:1-617-373-2316
email:[email protected]

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index