Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

R: st: R: Is there a better way of allocating individuals into different categories based on the probability of an event?


From   "Carlo Lazzaro" <carlo.lazzaro@tiscalinet.it>
To   <statalist@hsphsun2.harvard.edu>
Subject   R: st: R: Is there a better way of allocating individuals into different categories based on the probability of an event?
Date   Sat, 23 Mar 2013 16:14:01 +0100

Dear Gwinyai, 
thanks for pointing this out.
Sometimes, I have experienced, things do not go as expected due to trivial
details.
Happy with reading this was not your case, though.
Best regards,
Carlo

-----Messaggio originale-----
Da: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Gwinyai Masukume
Inviato: sabato 23 marzo 2013 09:52
A: statalist@hsphsun2.harvard.edu
Oggetto: Re: st: R: Is there a better way of allocating individuals into
different categories based on the probability of an event?

Thanks. I had set the obs and seed upstream of that code I quoted. I was
concerned that my method of categorising Smokers and Non-smokers looked
sloppy.
Thanks,
Gwinyai

On 3/23/13, Carlo Lazzaro <carlo.lazzaro@tiscalinet.it> wrote:
> Dear Gwinyai,
> the first trivial step to make your code running is setting the number 
> of
> observations:
> -----------------------------------------------------
> set obs  100 //or whatever you like or need gen 
> smoker1=int(1+(50000-1)*runiform())
> gen smoker=0 if smoker1 < 42000
> replace smoker=1 if smoker1 >= 42000
> label define smoker_label 0"Non-smoker" 1"Smoker"
> label values smoker smoker_label
> label variable smoker "Smoking status"
> drop smoker1
> -----------------------------------------------------
>
> Joseph has already commented on more substantive details.
>
> Kindest regards,
> Carlo
> -----Messaggio originale-----
> Da: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Gwinyai 
> Masukume
> Inviato: sabato 23 marzo 2013 04:16
> A: statalist@hsphsun2.harvard.edu
> Oggetto: st: Is there a better way of allocating individuals into 
> different categories based on the probability of an event?
>
> Dear Stata-listers,
>
> Is there a better way of executing the code below which assigns 
> individuals into the Non-smoker and Smoker categories based on the 
> probability of smoking in pregnancy?
>
> ****0=Non-smoker, 1=Smoker***
> **** Assuming 84% of women do not smoke during pregnancy
> **** Johnston V, Thomas DP, McDonnell J, Andrews RM. Maternal smoking 
> and smoking in the household during pregnancy and postpartum: findings 
> from an Indigenous cohort in the Northern Territory. Med J Aust. 2011 
> May 16;194(10):556-9.
> gen smoker1=int(1+(50000-1)*runiform())
> gen smoker=0 if smoker1 < 42000
> replace smoker=1 if smoker1 >= 42000
> label define smoker_label 0"Non-smoker" 1"Smoker"
> label values smoker smoker_label
> label variable smoker "Smoking status"
> drop smoker1
>
> Kind regards,
> Gwinyai
> *
> *   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/
>
> *
> *   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/
>
*
*   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/

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