Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: bootstrapping standard errors


From   "jean ries" <ries@ires.ucl.ac.be>
To   statalist@hsphsun2.harvard.edu
Subject   st: RE: bootstrapping standard errors
Date   Fri, 21 May 2004 22:37:09 +0200 (CEST)

Thomas,

In the -bootstrap- statements you require 1000 replications. However, when
looking at the output, in a lot of cases Stata reports less than 1000
replications for some variables. I think that in some replications you
simply had "bad luck". The bootstrap samples were such that in these
replications you had obtained explanatory variables that perfectly
predicted the dependant variable. Using Stata's -logit- command in such a
case will result in error messages of the following type:
"note: x2 != 0 predicts failure perfectly
       x2 dropped and 36 obs not used"
Thus if for instance the variable x2 is dropped, its coefficient cannot be
posted by the -bootstrap- procedure. I guess that a missing value is
posted in this case. Now, this does not yet explain the different results
in your case. However, looking at your .ado file (mcar_ordinal_6), it
becomes clear. If the coefficient on the x2 variable is missing, Stata
will return the coefficient of x3 in r(x2), x4 in r(x3) ... and finally a
missing value for the constant (the last scalar to be returned).

By the way, so as ensure identical results, you should set the random
number seed (-help seed-) to an identical value before each call to
-bootstrap-.

Hope this helps,

Jean



>Dear All,
>
>I wrote a small ado.file ("mcar_ordinal_6"), given below,  to get bootstrap
>std. err. estimates for the coefficients of a binary logit model with one
>categorical variable (given by the dummies x1 - x5) and one continuous
>variable Z4. I compare these estimates (obtained by typing: . bootstrap
>"mcar_ordinal_6" ....) with the usual bootstrapped logit std. err's
>(obtained by typing: . bootstrap "logit Y x1 x2 x3 x4 x5 Z4" _b, reps(1000)
>dots).  To my surprise, both ways result in totally different std. err.
>estimates (given below)!
>
>What is wrong with my ado.file? Any suggestions?
>
>Thank's a lot
>Thomas
>
>
>program define mcar_ordinal_6, rclass
>version 8.2
>
>logit Y x1 x2 x3 x4 x5 Z4
>mat beta=e(b)
>
>return scalar x1=beta[1,1]
>return scalar x2=beta[1,2]
>return scalar x3=beta[1,3]
>return scalar x4=beta[1,4]
>return scalar x5=beta[1,5]
>return scalar Z4=beta[1,6]
>return scalar const=beta[1,7]
>
>end
>
>
>. bootstrap "mcar_ordinal_6" const=r(const) Z4=r(Z4) x1=r(x1) x2=r(x2)
>x3=r(x3) x4=r(x4) x
>> 5=r(x5) , reps(1000) dots
>
>
>Bootstrap statistics                              Number of obs    =
>12451
>                                                  Replications     =
>1000
>
>----------------------------------------------------------------------------
>--
>Variable     |  Reps  Observed      Bias  Std. Err. [95% Conf. Interval]
>-------------+--------------------------------------------------------------
>--
>       const |   559    5.9239  .2659001  3.056453  -.0796589   11.92746
>(N)
>             |                                       .3723237   11.91934
>(P)
>             |                                        .167534   11.36338
>(BC)
>          Z4 |   973 -.1012986  2.435581  3.419307  -6.811373   6.608775
>(N)
>             |                                      -.1615792   10.09536
>(P)
>             |                                      -2.702652   6.346565
>(BC)
>          x1 |  1000 -3.159859  .0387406  .7028649   -4.53912  -1.780598
>(N)
>             |                                      -4.705648  -1.790577
>(P)
>             |                                      -4.807204  -1.910804
>(BC)
>          x2 |  1000 -3.567799   .221243   .762015  -5.063133  -2.072466
>(N)
>             |                                      -4.854494  -1.469348
>(P)
>             |                                      -5.062595  -2.441963
>(BC)
>          x3 |  1000 -3.020464   .755457  1.099255  -5.177578  -.8633499
>(N)
>             |                                      -4.334947  -.2468368
>(P)
>             |                                      -4.853861  -1.190173
>(BC)
>          x4 |  1000 -1.279128  .4245199   .660478  -2.575211   .0169558
>(N)
>             |                                      -1.876799   .2625169
>(P)
>             |                                      -2.165759  -.2838531
>(BC)
>          x5 |   999  -.365843  .2844974  1.212824   -2.74582   2.014134
>(N)
>             |                                      -.9417797   1.215659
>(P)
>             |                                      -1.233725  -.0630795
>(BC)
>----------------------------------------------------------------------------
>--
>
>
>
>. bootstrap "logit Y x1 x2 x3 x4 x5 Z4" _b, reps(1000) dots
>
>
>Bootstrap statistics                              Number of obs    =
>12451
>                                                  Replications     =
>1000
>
>----------------------------------------------------------------------------
>--
>Variable     |  Reps  Observed      Bias  Std. Err. [95% Conf. Interval]
>-------------+--------------------------------------------------------------
>--
>        b_x1 |   618 -3.159859  .4253625  .5268016    -4.1944  -2.125317
>(N)
>             |                                      -3.579062   -1.61639
>(P)
>             |                                       -3.82373  -2.401615
>(BC)
>        b_x2 |   939 -3.567799  -.040688  .6170578  -4.778773  -2.356826
>(N)
>             |                                      -4.897816  -2.479752
>(P)
>             |                                      -4.931322  -2.527777
>(BC)
>        b_x3 |   985 -3.020464 -.0677732  .6212142  -4.239521  -1.801407
>(N)
>             |                                      -4.528006  -1.958316
>(P)
>             |                                      -4.468464  -1.938175
>(BC)
>        b_x4 |  1000 -1.279128  .0311197  .3723199  -2.009746  -.5485089
>(N)
>             |                                      -1.958411  -.4930105
>(P)
>             |                                      -1.960265  -.4994082
>(BC)
>        b_x5 |  1000  -.365843  .0290434  .3521309  -1.056844   .3251582
>(N)
>             |                                      -.9971553   .4314241
>(P)
>             |                                      -1.042248   .3425232
>(BC)
>        b_Z4 |  1000 -.1012986 -.0010356  .0334018  -.1668444  -.0357529
>(N)
>             |                                      -.1695864  -.0428685
>(P)
>             |                                      -.1746111  -.0461127
>(BC)
>      b_cons |  1000    5.9239  .0343191  3.088323  -.1364438   11.98424
>(N)
>             |                                       .5156874   12.15566
>(P)
>             |                                        .706053   12.60186
>(BC)
>----------------------------------------------------------------------------
>--
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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