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

Re: st: RE: how to create a HLM dataset


From   Joseph Coveney <jcoveney@bigplanet.com>
To   Statalist <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: how to create a HLM dataset
Date   Thu, 15 Sep 2005 16:12:04 +0900

Min Zhang wrote:

Nick, as for the first solution, can you give me more hint?
I do not know how to set up the structure identifiers.

> You can use -egen, seq()- to set up a
> structure of identifiers. Recall that this
> was an answer to one of your previous questions.
>
> Alternatively, if you want to mimic the structure
> of the USA, just borrow a real dataset with
> existing identifiers and then create your
> "random counts" according to whatever precise
> recipe you have in mind.
>
> Nick
>
> > I want to create a dataset which has a hierarchical linear structure.
> > for example, a structure of states, counties:
> >
> > 50 states in total. For each state, create counties with
> > random county counts.
> > Then for each county, create school districts with random counts.

--------------------------------------------------------------------------------

I'm not sure how to set up random counts of counties-within-states and
districts-within-counties using -egen , seq()-, but perhaps the following
might create the data structure that your'e looking for.

(I'm not sure whether school districts are always nested within counties.
In any event, I believe that you can get the actual rosters of counties and
of school districts--Nick's second suggestion--from the U.S. Bureau of the
Census.  Check the bureau's website in the SAIPE area:  "Small Area Income &
Poverty Estimates--Model-based Estimates for States, Counties & School
Districts.")

Joseph Coveney

set obs 50
generate byte state_id = _n
generate byte county_id = ceil(50 * uniform()) // 50 is arbitrary
expand county_id
bysort state_id: replace county_id = _n
generate byte school_district_id = ceil(5 * uniform()) // 5 ditto
expand school_district_id
bysort state_id county_id: replace school_district_id = _n

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index