Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Bootstrap not reporting observed coefficient as the mean of expression


From   Charles Koss <hqtiger@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Bootstrap not reporting observed coefficient as the mean of expression
Date   Tue, 19 Apr 2011 09:42:25 -0500

I have run your code. Seems to me that your program myderivative is
bootstrapping the standard error of the expression whereas the first
procedure is boostrapping both the expression and corresponding
standard error.

Charles

-- 
Charles Koss
http://charlesonnet.blogspot.com

On Tue, Apr 19, 2011 at 8:52 AM, Jaime Ruiz-Tagle
<jaimeruiztagle@gmail.com> wrote:
> Hi all,
>
> I found a problem in bootstrap, which is not reporting the "mean" of
> an expression as the "observed coefficient".
>
> Here comes an example where bootstrap gives the correct "observed
> coefficient" only when invoked through a user defined program.
>
> Hopefully somebody can help me since I'm very puzzled.
>
> Thanks,
>
> Jaime.
>
>
> // //////////////////////////////////////////
> use http://www.stata-press.com/data/r11/auto, clear
>
> gen weight2=weight^2
>
> regress mpg weight weight2 gear foreign
>
> gen derivative1 = (_b[weight] + 2*weight*_b[weight])
> sum derivative1, detail
>
> // Using bootstrap with expression:
> bootstrap derivative = (_b[weight] + 2*weight*_b[weight]), reps(100)
> seed(1): regress mpg weight weight2 gear foreign
>
> // The "observed coefficient" is reported as -96.14374, but the mean
> is -99.07872
>
> // Now using a user defined program that does the same as expression above
>
> capture pr drop myderivative
> program define myderivative, rclass
>        version 11
>        tempname derivative2
>        quietly regress mpg weight weight2 gear foreign
>        capture drop derivative2
>        gen derivative2 =_b[weight] + 2*weight*_b[weight]
>        quietly summarize derivative2, meanonly
>        scalar `derivative2' = r(mean)
>        return scalar derivative2 = `derivative2'
> end
>
> bootstrap r(derivative2), reps(100) seed(1): myderivative
>
> // The "observed coefficient" is now reported as equal to the mean = -99.07872
>
> // //////////////////////////////////////////
>
>
>
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Jaime Ruiz-Tagle V.
> Profesor
> Centro de Microdatos, Departamento de Economía, Universidad de Chile
> Diagonal Paraguay 257, Torre 26, Oficina 1603 A
> Santiago - CHILE
>
> Tel: (56 2) 978 3586 / 978 3421
> Fax: (56 2) 634 7342
> jaimert@econ.uchile.cl
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> *
> *   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/
>

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