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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

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

Subject |
st: AW: R: RE: odd results after insample |

Date |
Sat, 26 Sep 2009 19:23:44 +0200 |

<> Also note the help file for -simulate- which contains an example covering the lognormal distribution... HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Carlo Lazzaro Gesendet: Samstag, 26. September 2009 16:20 An: statalist@hsphsun2.harvard.edu Cc: 'Martin Weiss' Betreff: st: R: RE: odd results after insample Dear Martin, thanks a lot for your kind reply. The approach sketched in my previous message follows the one suggested by: Briggs, A. and Nixon, R. and Dixon, S. and Thompson, S. (2005) Parametric modelling of cost data: some simulation evidence. Health Economics 14(4):pp. 421-428. So far, I have been quite successful with other Stata procedures for drawing random samples from a given distribution (for instance, -simulate-), including the approach you kindly advice me about. Unfortunately, I cannot figure out what went wrong with this last do_file. Thanks a lot again and enjoy your W_E. Kind Regards, Carlo -----Messaggio originale----- Da: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Martin Weiss Inviato: sabato 26 settembre 2009 15.21 A: statalist@hsphsun2.harvard.edu Oggetto: st: RE: odd results after insample <> Just out of curiosity: If you want 20 obs per sample, and 2,000 samples, should that not lead to 40,000 observations overall? HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Carlo Lazzaro Sent: Samstag, 26. September 2009 15:00 To: statalist@hsphsun2.harvard.edu Subject: st: odd results after insample Dear Statalisters, as an alternative to - simulate - , I have written the following do file (for Stata 9.2/SE) to draw 2000 random samples, 20 observations each, from a normal distribution: drop _all set more off set obs 2000 obs was 0, now 2000 g double ln_g_20=. g double ln_sd_g_20=. set seed 999 qui gen A=5.37 + 1.19*invnorm(uniform()) in 1/972 qui forvalues i = 1(1)2000 { qui gen ln_20`i'=A qui generate random`i' = uniform() qui sort random`i' qui generate insample`i' = _n <= 20 qui sum ln_20`i' if insample`i' == 1 replace ln_g_20=r(mean) in `i' replace ln_sd_g_20=r(sd) in `i' drop ln_20`i' drop random`i' drop insample`i' } drop A However, as a result I have obtained 1721 observations instead of the expected 2000. sum ln_g_20 ln_sd_g_20 Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- ln_g_20 | 1271 5.314033 .3800687 3.79247 6.587941 ln_sd_g_20 | 1271 1.101084 .2835007 .0260279 2.161299 Besides, results are even more puzzling when I increase the number of samples (again 20 observations each), in that I get a different number of observation for ln_g and ln_sd_g. Comments are gratefully acknowledged. Thanks a lot for your kindness and for your time. Kind Regards, Carlo * * 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/ * * 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: RE: odd results after insample***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**st: R: RE: odd results after insample***From:*"Carlo Lazzaro" <carlo.lazzaro@tin.it>

- Prev by Date:
**Re: st: Survival analysis: repeated spells** - Next by Date:
**st: AW: R: RE: odd results after insample** - Previous by thread:
**st: R: RE: odd results after insample** - Next by thread:
**st: AW: R: RE: odd results after insample** - Index(es):

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