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

From |
"Carlo Lazzaro" <carlo.lazzaro@tiscalinet.it> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
R: st: constrained sum of random values |

Date |
Thu, 26 Mar 2009 07:52:12 +0100 |

Dear Eva and Nick, thanks a lot for your helpful hints. Kind Regards, Carlo -----Messaggio originale----- Da: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Nick Cox Inviato: mercoledì 25 marzo 2009 20.16 A: statalist@hsphsun2.harvard.edu Oggetto: RE: st: constrained sum of random values Carlo specified Stata 9.2; so he would need to use 125 + 25 * invnormal(uniform()) Not rnormal(125,25). Otherwise Eva's reply shows that Carlo's question is open to various interpretations Nick n.j.cox@durham.ac.uk Eva Poen If you put such a constraint on your random values, it means that at most 76 of them can be random; you need one value to bring the sum up to 9900. This is very simple to do: clear set obs 77 set seed 123 gen n = rnormal(125,25) in 1/76 qui sum n replace n = 9900-r(sum) in 77 You didn't mention what kind of random values you want, i.e. which distribution. I assumed normal distribution with mean 125 and sd of 25. 2009/3/25 Carlo Lazzaro <carlo.lazzaro@tiscalinet.it>: > is there any way for imposing Stata 9.2/SE to create a variable composed of > 77 random values so that the sum of these random values is 9900? * * 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/

**References**:**RE: st: constrained sum of random values***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st:how to connect a variable's value with another variable's name** - Next by Date:
**st: psmatch2 by(var)** - Previous by thread:
**RE: st: constrained sum of random values** - Next by thread:
**Re: st: constrained sum of random values** - Index(es):

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