Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Speed problems using Stata 8.2


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Speed problems using Stata 8.2
Date   Fri, 23 Jul 2004 13:59:38 +0100

One very small comment here. If this is run, the time 
will include the time to -drop _all-, which -- the 
very first time this is done -- could be all sorts
of different datasets in memory before the -simulate-. 

As several people may be interested in 
this or other benchmarking programs, then 
the number of sources of variability can 
be reduced by ensuring that -simulate- is 
run after -clear-. 

Nick 
[email protected] 

Daniel Feenberg
> 
> program define lnsim, rclass
>          syntax [, obs(integer 1) mu(real 0) sigma(real 1)]
>          drop _all
>          set obs `obs'
>          tempvar z
>          gen `z' = exp(`mu' + `sigma'*invnorm(uniform()))
>          summarize `z'
>          return scalar mean = r(mean)
>          return scalar Var  = r(Var)
>     end
> 
> simulate "lnsim, obs(100)" mean=r(mean) var=r(Var), reps(10000)

*
*   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/



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