Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: How to do Pseudo-class draws in STATA?


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: How to do Pseudo-class draws in STATA?
Date   Thu, 18 Apr 2013 09:38:12 +0100

For a start on your problem, check out

(1) -rdiscrete()- in Mata.

and

(2)

SJ-7-3  pr0032  . . . . . . . . . .  Stata tip 48: Discrete uses for uniform()
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M. L. Buis
        Q3/07   SJ 7(3):434--435                                 (no commands)
        tip on using uniform() to create random draws from a
        discrete distribution where each possible value has a
        known probability

http://www.stata-journal.com/sjpdf.html?articlenum=pr0032

and

(3)

http://www.stata.com/support/faqs/resources/statalist-faq/#spell

All that said, two lines of code may help

gen rndm = runiform()
gen which = cond(rndm < 0.5, 1, cond(rndm < 0.8, 2, 3))

I didn't get how you want lots of fake datasets, etc. and so may well
be missing the major part of your problem.

Nick
[email protected]

Cheenghee M. Koh, MSW, MS(c), PhD(c) and/or ChengShi Shiu wrote

> I would like to do Pseudo-Class draws in STATA. I have some ideas about how to do it, but not sure how to implement it in STATA.
>
> When I say "Pseudo-Class draws", I refer to the papers by Bandee-Roche, K. et al., (1997). Latent variable regression for multiple discrete outcomes, JASA, 92(440): 1375-1386 & Wang, C.-P. et al., (2005). Residual diagnostics for growth mixture models, JASA, 100(471): 1054 - 1075. A more concrete example could be seen in Petras, H. & Masyn, K. (2010). General growth mixture analysis with antecedents and consequences of change, Handbook of Quantitative Criminology, pp 69-100. But in short, if now a person has 0.5, 0.3, and 0.2 probability to be categorized in the 1st, 2nd, and the 3rd classes respectively, then, if I make independent 100 random draws, there should be approximately 50 "class 1", 30 "class 2", and 20 "class 3". But as it is random drawing, the exact numbers may or may not perfect match with their probabilities. Also, the order to these numbers will be at random too.
>
> So I would like to do this in STATA.
>
> Now, say, I would love to make 20 draws (as recommended by Wang et al.'s paper) for each person in the dataset, and thus create 20 datasets containing these draws (each draw will be stored in a dataset). This is sort of parallel to multiple imputation. But I am not sure how to do it in STATA.
>
> The following is how I think I may do, but I am not sure how to implement it:
>
> 1. I will create a variable for each person. In this variable, I would create 100 observations, among which, there are, using the example above, 50 "1", 30 "2", and 20 "3" (as the probabilities for class 1, 2, and 3 are 0.5, 0.3, and 0.2 respectively). So, if there are 500 people in my dataset, I will need to create 500 new variables.
>
> 2.  I will sort randomly these new variables.
>
> 3. Then I will select the first 20 observations.
>
> 4. I would transpose the data I select in my step 3, so that now the row represents the original people/observations, and the column represents the 20 new draws for each individuals.
>
> This is what I think I would like to do, but I can't figure out the first step: how to create this new variable containing replicated numbers according to other variables that have information about the class probabilities? (in this case, I may have other three variables containing the probabilities for each of the three class)

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index