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]

Re: st: bootstrap problem on a user written program: insufficient observations to compute bootstrap standard errors


From   Marco Savegnago <[email protected]>
To   [email protected]
Subject   Re: st: bootstrap problem on a user written program: insufficient observations to compute bootstrap standard errors
Date   Sat, 1 Mar 2014 17:29:06 +0100

Dear Federico,
thanks for your help,
it was very useful!!

Marco

2014-03-01 15:40 GMT+01:00 Federico Belotti <[email protected]>:
> Dear Marco,
>
> I usually wrote a program exploiting the eclass. Obviusly you can make your
> program more flexible, but this solves your issue, at least from the
> programming point of view.
>
> =============== code begins ====================
>
> cap prog drop myprog
>            prog def myprog, eclass
>            syntax varlist(min=3 max=3 numeric) [if] [in]
>            tokenize `varlist'
>            marksample touse
>            qui reg `1' `2' if `3' == 0
>            scalar beta_0 = _b[`2']
>            qui reg `1' `2' if `3' == 1
>            scalar beta_1 = _b[`2']
>            matrix diffbeta = beta_1 - beta_0
>            mat colnames diffbeta = "diffbeta"
>            matrix vdiffbeta = 1
>            mat colnames vdiffbeta = "diffbeta"
>            mat rownames vdiffbeta = "diffbeta"
>            eret post diffbeta vdiffbeta, e(`touse')
>            eret local cmd myprog
>            eret di
>
> end
>
>
> sysuse auto, clear
> myprog price mpg foreign
> eret li
> bootstrap _b[diffbeta]: myprog price mpg foreign
>
> =============== code ends====================
>
> HTH
>
> Federico
>
> Federico
>
>> Il giorno 01/mar/2014, alle ore 12:22, Marco Savegnago <[email protected]> ha scritto:
>>
>> Dear Statalisters,
>>
>> I have a trouble using the bootstrap prefix.
>>
>> Before resorting to Statalist, I've looked online and on textbooks for
>> a solution, without finding it.
>>
>> Assume we want to bootstrap the difference between 2 OLS estimations
>> (for 2 subpopulations identified by a dummy variable) and that we
>> write our rclass program.
>>
>> cap prog drop myprog
>>
>>            prog def myprog, rclass
>>
>>            syntax varlist(min=3 max=3 numeric)
>>
>>            tokenize `varlist'
>>
>>
>>            qui reg `1' `2' if `3' == 0
>>
>>            scalar beta_0 = _b[`2']
>>
>>
>>            qui reg `1' `2' if `3' == 1
>>
>>            scalar beta_1 = _b[`2']
>>
>>
>>            scalar diffbeta = beta_1 - beta_0
>>
>>            disp in ye "Diff in beta between  (" "`3'" " = 1)  and  ("
>> "`3'" " = 0) is "   as result diffbeta
>>
>>            return scalar diffbeta=diffbeta
>>
>> end
>>
>> Let's test it and check it works:
>>
>> sysuse auto, clear
>>
>> myprog price mpg foreign
>>
>> ret list
>>
>>
>>
>> However, when I try to use it in bootstrap, I encounter this problem:
>>
>>
>> . bootstrap dbet = r(diffbeta): myprog price mpg foreign
>>
>> (running myprog on estimation sample)
>>
>>
>>
>> Bootstrap replications (50)
>>
>> ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
>>
>> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    50
>>
>> insufficient observations to compute bootstrap standard errors
>>
>> no results will be saved
>>
>> r(2000);
>>
>>
>>
>> Is there any suggestion to solve the problem?
>>
>> I hope someone can help,
>>
>>
>> Thank you very much,
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index