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: Generating random variable with predefined characteristics


From   "Konrad Zdeb" <[email protected]>
To   [email protected]
Subject   Re: st: Generating random variable with predefined characteristics
Date   Mon, 03 Jun 2013 17:45:20 +0200

Dear Colleagues,

I find the rnbinomial function extremely useful and I'm trying to educate myself on generating pseudorandom variates. Out of curiosity, how easily I could manipulate the skew? Let's say that I would like to obtain distribution that would be negatively skewed or platykurtic?

Kind regards,
Konrad


----- Original Message -----
From: Konrad Zdeb
Sent: 06/02/13 11:50 AM
To: [email protected]
Subject: Re: st: Generating random variable with predefined characteristics
 Maarten,

Thank you very much for your reply. It did work.

--
Regards
Konrad

On 31 May 2013, at 16:19, Maarten Buis wrote:

> On Fri, May 31, 2013 at 4:55 PM, Konrad Zdeb wrote:
>> I would like to generate a random variable that would have the following characteristics:
>> - would take values from 1 to 34
>> - would display a strong correlation with another variable that is currently present in the data set
>> - ideally, I would like to obtain distribution that would be positively skewed, but correlation with another variable is a priority
> 
> I interpret your question such that you want your values to be
> integers. In that case you can look at the binomial distribution:
> 
> *------------------ begin example ------------------
> sysuse nlsw88, clear
> gen p = invlogit(-3+ .1*grade)
> gen var = rbinomial(33,p) + 1
> corr grade var
> spikeplot var
> *------------------- end example -------------------
> (For more on examples I sent to the Statalist see:
> http://www.maartenbuis.nl/example_faq )
> 
> Hope this helps,
> Maarten
> 
> ---------------------------------
> Maarten L. Buis
> WZB
> Reichpietschufer 50
> 10785 Berlin
> Germany
> 
> http://www.maartenbuis.nl
> ---------------------------------
> *
> * 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/ 



--
Kind regards,
Konrad
*
*   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