Statalist


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

Re: Fwd: st: RE: [clustered] random draws


From   "Susan Olivia" <olivia@primal.ucdavis.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: Fwd: st: RE: [clustered] random draws
Date   Thu, 28 May 2009 18:34:19 -0700

Thanks heaps Kieran for the programming tips. The code is
doing what I after.  

Cheers,

Susan



> ---------- Forwarded message ----------
> From: Kieran McCaul <Kieran.McCaul@uwa.edu.au>
> Date: Thu, May 28, 2009 at 4:26 PM
> Subject: st: RE: [clustered] random draws
> To: statalist@hsphsun2.harvard.edu
> 
> 
> .
> 
> 
> How about something like this. It creates 10 clusters.
> I've left the sd's set at 5, but you could change these to
> affect the degree of clustering.
> 
> 
> 
> set seed 1234
> 
> forvalues i = 1/10  {
> clear
> local m1 = uniform()*100
> local m2 = uniform()*100
> 
> matrix m = (`m1',`m2')
> matrix sd = (5,5)
> drawnorm x y, n(10) means(m) sds(sd)
> 
> tempfile ttt`i'
> save ttt`i', replace
> 
> }
> 
> 
> use ttt1, clear
> forvalues i = 2/5  {
> append using ttt`i'
> }
> drop if x<0 | x>100
> drop if y<0 | y>100
> 
> scatter y x
> 
> 
> 
> ______________________________________________
> Kieran McCaul MPH PhD
> WA Centre for Health & Ageing (M573)
> University of Western Australia
> Level 6, Ainslie House
> 48 Murray St
> Perth 6000
> Phone: (08) 9224-2701
> Fax: (08) 9224 8009
> email: Kieran.McCaul@uwa.edu.au
> http://myprofile.cos.com/mccaul
> http://www.researcherid.com/rid/B-8751-2008
> ______________________________________________
> Man is a credulous animal, and must believe something; in
> the absence of good grounds for belief,
> he will be satisfied with bad ones. Bertrand Russell
> 
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of
> Susan Olivia Sent: Friday, 29 May 2009 6:17 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: [clustered] random draws
> 
> Dear Stata lister,
> 
> I am generating x and y coordinates based on random draws
> from a uniform distribution with a minimum value of 0 and
> maximum value of 100 - which has the effect of randomly
> locating the data in a 100 by 100 square.
> 
> The question that I want to ask:  I would like generate
> clustered pattern from the generated x and y coordinates
> [say 10 observations that close to each other forming a
> cluster]. Is this something possible that I can do in
> Stata?
> 
> Thanks in advance,
> 
> Susan
> 
> *
> *   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/



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