[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Miller.DavidJ@epamail.epa.gov |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Stata's "Simulate" command and Stata v.8.1 |

Date |
Tue, 19 Aug 2003 15:09:08 -0400 |

I am fairly new to Stata programming but would like to perform a simulation whereby I create a dataset containing means and variances of 1000-observation samples from a log-normal distribution with a given mean and standard deviation. I would like to output the 1000 generated mean and standard deviations pairs (or doublets) and plot these as (x,y) coordinates . Eventually, I would also like the output to contain the skewness and kurtosis and understand that, to do this, I would need to use the "summarize, detail" command and I could do this using incorporating r(skewness) and r(kurtosis) as output requests into the program. As a first step in this process, I thought I would try out an example in Stata's on-line help function and see if it worked. I typed "help simulate" into Stata and copied a sample program from there into Stata. When I did this, however, Stata told me that there was an "error when command executed on original dataset under version 8.1 control r(199);" As this was a sample command taken directly from the Stata on-line help files, I was puzzled. I thought that it might help to add in "version 8.0" into the program as line 1 (so that it would understand that it was supposed to work under the the 8.0 version of Stata), but this didn't work either and Stata came back with the same error. Does anyone know what needs to be done to modify programs if the 8.1 version of Stata will now longer accept them? Or if I am doing something wrong? I am using Stata 8.1 born 01 July 2003. I have excerpted below my sample program which was copied directly from a sample program provided under Stata's on-line help function as well as Stata's response about v.8.1 control. . about Intercooled Stata 8.1 for Windows Born 01 Jul 2003 Copyright (C) 1985-2003 Total physical memory: 259992 KB Available physical memory: 4224 KB program define lnsim, rclass 1. syntax [, obs(integer 1) mu(real 0) sigma(real 1)] 2. drop _all 3. set obs `obs' 4. temvar z 5. gen `z'=exp(`mu' + `sigma' * invnorm(uniform())) 6. summarize `z' 7. return scalar mean=r(mean) 8. return scalar Var = r(Var) 9. end . simulate "lnsim, obs(100)" mean=r(mean) var=r(Var), reps(10000) command -> lnsim , obs(100) error when command executed on original dataset under version 8.1 control r(199); . simulate "lnsim, obs(50) mu(-3) sigma(7)" mean=r(mean) var=r(Var), reps(10000) command -> lnsim , obs(50) mu(-3) sigma(7) error when command executed on original dataset under version 8.1 control r(199); * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**st: RE: Stata's "Simulate" command and Stata v.8.1***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: -graph bar, over()- question and bug report** - Next by Date:
**st: Location of the knots when estimating a spline model** - Previous by thread:
**st: New user...trying to use ADO file with SVR** - Next by thread:
**st: RE: Stata's "Simulate" command and Stata v.8.1** - Index(es):

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