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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

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

Subject |
st: RE: Re:Is there any way ? |

Date |
Sat, 11 Sep 2004 15:10:58 +0100 |

I am a bit lost on what you are trying to do here. You seem to be generating samples from a normal, but only wanting to keep them if they appear really close to the target population in the sense that sample mean and sample sd are really close to the corresponding population parameters. If that's right and memory is the issue, then you should test each sample just after generation and drop it immediately if it is not up to your standards. Or equivalently you could do something like this: gen prov = . local j = 1 qui while `j' < 100 { replace prov = 50 + 10 * invnorm(uniform()) su prov if inrange(r(mean),49.9,50.1)) & inrange(r(sd),9.9,10.1) { gen OK`j++' = prov } } That way, what you have in memory is just the last sample generated and all previous samples generated deemed OK By the way, standard advice in the Statalist FAQ is The current version of Stata is 8.2. Please specify if you are using an earlier version; otherwise, the answer to your question is likely to refer to commands or features unavailable to you. Nick n.j.cox@durham.ac.uk P.S. Stata is telling you why your code didn't work. First time round it thinks that the [1] in use ai[1].dta, clear is a reference to weights. This also is puzzling. Presumably you wouldn't try to -use- that dataset if you hadn't previously saved it, but is that a legal filename with your (unstated) operating system? -------------------------------------------------------------- victor michael zammit > the following dataset lists the 16 variables , out of 1000 normally > distributed variable with mean 50 and standard deviation 10 > , and then < > keep if mean>49.9 & mean < 50.1 & sd > 9.9 & sd< 10.1 > . I > would like to > do this for different < set obs # > ,and 10,000 instead of > 1000 , but > memory becomes an issue .What I thought I could do , is to > save variable i > ' s under a different name, and then go to the next <set > obs #> and < > save,replace> over the previous 1000 or whatever variables . > > +---------------------------+ > mean sd i > --------------------------- > 1. 49.96996 9.978514 76 > 2. 49.92636 10.07861 118 > 3. 49.97271 10.07149 122 > 4. 50.07562 10.07239 218 > 5. 49.94316 9.913686 220 > --------------------------- > 6. 50.02873 10.05811 346 > 7. 50.01596 10.04384 442 > 8. 50.00026 9.943673 513 > 9. 49.91186 9.95947 533 > 10. 50.00311 10.00525 629 > --------------------------- > 11. 50.09705 9.929688 653 > 12. 49.98079 10.04592 678 > 13. 49.93727 9.962771 686 > 14. 49.98563 10.07247 694 > 15. 50.08827 9.936735 833 > --------------------------- > 16. 49.97584 10.05994 854 > > > I experimented with a loop : > > > . local i = 1 > > . while `i'<= _N { > 2. use ai[`i'].dta,clear > 3. save b`i',replace > 4. local i = `i'+1 > 5. } > weights not allowed > r(101); > > but it did not work > Is there a way I could do this ? * * 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: RE: Re:Is there any way ?***From:*"victor michael zammit" <vmz@vol.net.mt>

- Prev by Date:
**st: Correlation coefficients and the CORTESTi program - again** - Next by Date:
**st: RE: Tabulate and date format display** - Previous by thread:
**st: RE: RE: RE: Storage datatype in assert test** - Next by thread:
**st: Re: RE: Re:Is there any way ?** - Index(es):

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