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: error message about bootstrp


From   Wu Zhang <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: error message about bootstrp
Date   Tue, 5 Mar 2013 23:19:17 -0800 (PST)

Hi Nick,

  That's very smart way to do it; by the way, can you change the program for arbitrary many variables, not just for 2?

Thanks a lot!

Wu 



________________________________
From: Nick Cox <[email protected]>
To: [email protected] 
Sent: Monday, March 4, 2013 2:02 PM
Subject: Re: st: error message about bootstrp

Yes; you can use e(b) in a r-class program.

The best way to check is by doing, i.e. by writing a dopey little
program, such as

program myprog, rclass
       version 8
       syntax varlist(numeric min=2 max=2)
       regress `varlist'
       tempname b
       mat `b' = e(b)
       return scalar b1 = `b'[1,1]
       return scalar b2 = `b'[1,2]
end


Nick

On Mon, Mar 4, 2013 at 7:54 PM, Wu Zhang <[email protected]> wrote:
> Hi Nick,
>
>   It works fine that way.I am just wondering whether we can use e(b) in the rclass program?
>
> Thanks,
>
> Wu
>
>
>
>
> ----- Original Message -----
> From: Nick Cox <[email protected]>
> To: [email protected]
> Cc:
> Sent: Monday, March 4, 2013 7:27 AM
> Subject: Re: st: error message about bootstrp
>
> You should run your program -apese- once by itself on the data to see
> what it leaves behind.
>
> Nick
>
> On Mon, Mar 4, 2013 at 7:54 AM, Wu Zhang <[email protected]> wrote:
>
>> After I adopt your suggestion and modify the code a little bit, I get this error message :
>>
>> insufficient observations to compute bootstrap standard errors
>> no results will be saved
>> r(2000);
>>
>> The Boostrap code is as follows:
>>
>>
>>
>> cap program drop apese
>> program apese, rclass
>> version 12.1
>> capture drop   xalphat ehat sdhat meanvaluen meanvalue21
>> reg odds  x1 x2 x3
>> mat paraest=e(b)
>> return scalar alphaj =_b[x2]
>> predict ehat, residual
>> mean x1 x2 x3 const
>> mat xmean=e(b)
>> mat meanvalue=xmean*paraest'
>> svmat meanvalue, names(meanvalue2)
>> sum meanvalue21
>> gen meanvaluen=r(mean)
>> gen sdhat=alphaj*exp(meanvaluen+ehat)/(1+exp(meanvaluen+ehat))^2
>>
>> sum sdhat
>> return scalar apej=r(mean)
>>
>> end
>>
>>
>>
>> The running code is:  bootstrap apej=r(apej): apese
>>
> *
> *   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?searchhttp://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