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

From |
Antoine Terracol <terracol@univ-paris1.fr> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: random draw of single variable, not whole data |

Date |
Thu, 26 Feb 2009 20:31:29 +0100 |

You're correct. building on Jeph's solution: clear set obs 10 g x=rnormal() g y=x[int(_N*uniform())+1] li Antoine Austin Nichols wrote:

Antoine Terracol <terracol@univ-paris1.fr>: Except the poster wanted resampling with replacement, so you need to generate a random obs to draw from (for each obs) from the integers 1 to N (not simply randomize the order of obs). Look in bsample.ado for a "fast method for resample of size _N" On Thu, Feb 26, 2009 at 2:12 PM, Antoine Terracol <terracol@univ-paris1.fr> wrote:In addition to -bsample- and -merge-, another solution is: clear set obs 10 g x=rnormal() g rnd=uniform() egen rank=rank(rnd) g y=x[rank] li drop rank Antoine Florian Wakolbinger wrote:Dear all, is it possible to randomly draw numbers out of a variable x and write it into another variable y i.e. if x 1 2 3 4 5 then y could be, for instance y 3 5 3 2 4 all numbers in y are randomly drawn from x. how is it possible to construct such a variable y in stata? thanks, and kind regards florian* * 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/

**Follow-Ups**:**Re: st: random draw of single variable, not whole data***From:*Austin Nichols <austinnichols@gmail.com>

**References**:**st: random draw of single variable, not whole data***From:*Florian Wakolbinger <wakolbinger@drei-e.at>

**Re: st: random draw of single variable, not whole data***From:*Antoine Terracol <terracol@univ-paris1.fr>

**Re: st: random draw of single variable, not whole data***From:*Austin Nichols <austinnichols@gmail.com>

- Prev by Date:
**Re: st: random draw of single variable, not whole data** - Next by Date:
**Re: st: random draw of single variable, not whole data** - Previous by thread:
**Re: st: random draw of single variable, not whole data** - Next by thread:
**Re: st: random draw of single variable, not whole data** - Index(es):

© Copyright 1996–2023 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |