Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Lance Wiggains <lance.wiggains@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: using loop to generate distributions with different means and standard deviations |

Date |
Wed, 18 May 2011 13:36:13 -0400 |

I've tried that but the problem is that I'm pre-calculating the means and sd's for the variable because I'm only using the last 3-4 observations for each variable to calculate those values. I'm doing this because I want it to reflect the changes that happen recently. My mean function uses tssmooth, with weights (1 1<2>), to average the last 3 weeks of sales. So if sales were 70,80,90, and 100 I get a value of 92.5 for my mean. It also calculates a SD for the last 3-4 observations. Then I want to plug those numbers into the drawnorm function using a loop. Any idea about how that would work? Lance On Wed, May 18, 2011 at 1:16 PM, Sarah Edgington <sedging@ucla.edu> wrote: > Lance, > Try something like this: > > forv i=1/3 { > drawnorm name`i', m(mean_var`i') sd(sd_var`i') > } > > You'll run into problems, though, if your data actually includes the > variable names you list since there isn't a sd_var1. > > -Sarah > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Lance Wiggains > Sent: Wednesday, May 18, 2011 10:09 AM > To: statalist@hsphsun2.harvard.edu > Subject: st: using loop to generate distributions with different means and > standard deviations > > Statalist members, > > I'm trying to get Stata to generate a distribution of data from variables in > my data set. > > My appended data looks like this > mean_var1=90 > standard_deviation_var1=5 > mean_var2=100 > sd_var2=10 > mean var3=110 > sd_var3=15 > and so on > > I'm need a loop that will take my variables and create the distributions for > me. > I've been using the drawnorm command > drawnorm name1, m(mean_var1) sd(sd_var1) but I can't get it to > recognize more than 1 variable at a time > > I want it to perform the distribution command for each pair of my variables. > I.e. (m_var1, sd_var1), (m_var2, sd_var2) , (m_var3, sd_var3) > > Thanks for your consideration, > > Lance > * > * 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/ > * * 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: RE: using loop to generate distributions with different means and standard deviations***From:*"Sarah Edgington" <sedging@ucla.edu>

**References**:**st: using loop to generate distributions with different means and standard deviations***From:*Lance Wiggains <lance.wiggains@gmail.com>

**st: RE: using loop to generate distributions with different means and standard deviations***From:*"Sarah Edgington" <sedging@ucla.edu>

- Prev by Date:
**RE: st: creating variable summarizing for each individual properties of other members of a group at t-1** - Next by Date:
**st: RE: correct egen command to calculate means - please help** - Previous by thread:
**st: RE: using loop to generate distributions with different means and standard deviations** - Next by thread:
**RE: st: RE: using loop to generate distributions with different means and standard deviations** - Index(es):