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

From |
Linn Renée Naper <linn.naper@ecgroup.no> |

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

Subject |
st: RE: RE: using drawnorm and by()?? |

Date |
Tue, 11 Nov 2008 19:50:12 +0100 |

Thanks Nick, it makes sense. -----Opprinnelig melding----- Fra: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] På vegne av Nick Cox Sendt: 11. november 2008 19:30 Til: statalist@hsphsun2.harvard.edu Emne: st: RE: using drawnorm and by()?? I haven't been following this thread closely, partly because I could not easily read earlier postings, but it is not obvious to me that you need to use -drawnorm- at all. . gen rndnorm = invnormal(uniform()) gives you a variable with random normal (Gaussian) deviates. Add means and multiply by standard deviations as desired. As the means and sds could differ by group, that is where the -by- element comes in. Nick n.j.cox@durham.ac.uk Linn Renée Naper I typed the following commands in Stata 9. set seed 123456 capture drop group_var egen group_var=group(year) sum group_var forvalues i = 1(1) `r(max)' { drawnorm x`i', m(0) sd(5) } summarize exit Well, what this actually does is to produce seven variables with the given distribution (it is 7 years in my dataset). What I would like to do is to produce one random variable where the draw is done individually for each year, potentially also from a different distribution in different years(different m and sd for different years). (the dataset has hourly price variables and a year indicator following the prices). I want to generate alternative group variables (not only by year, but also by seasons etc) in order to produce a random variable with different distribution for different parts of the dataset. So my question I guess is whether drawnorm in some way can be combined with by(), or if anyone has an alternative solution to this. Or do I have to do this manually for different parts of the data set, and then putting it all together in the end? * * 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**:**st: using drawnorm and by()??***From:*Linn Renée Naper <linn.naper@ecgroup.no>

**st: RE: using drawnorm and by()??***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: Sort on time** - Next by Date:
**RE: st: Re: area between reference lines** - Previous by thread:
**st: RE: using drawnorm and by()??** - Next by thread:
**st: Table command** - Index(es):

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