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 means of several variables in one command


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: bootstrap means of several variables in one command
Date   Wed, 26 Mar 2014 18:43:00 +0000

You need to write your own program therefore, say as here:

sysuse auto, clear

program myprog, rclass
      version 9
      syntax varlist(min=2 max=2 numeric) [if] [in]
      tokenize "`varlist'"
      args v1 v2

     su `v1'  `if' `in', meanonly
     return scalar mean1 = r(mean)

     su `v2'  `if' `in', meanonly
     return scalar mean2 = r(mean)
end

bootstrap  mean1=r(mean1) mean2 = r(mean2) : myprog turn trunk

Nick
[email protected]


On 26 March 2014 18:28, Mitchell F. Berman <[email protected]> wrote:

> bootstrap mean1=r(mean):sum var1, meanonly        works fine
>
> but I don't see a way to do this for 2 or more variables, since
> r(mean) after running
> sum var1 var2
> has only the mean for var2.
>
> mean var1 var2
> produces a matrix e(b) with the two means
> but I can't get bootstrap to accept this ("matrices not allowed").
>
> I'm sure there's a simple way to do this.
*
*   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