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

Re: st: Generating random variable with predefined characteristics

 From Nick Cox <[email protected]> To "[email protected]" <[email protected]> Subject Re: st: Generating random variable with predefined characteristics Date Mon, 3 Jun 2013 17:08:20 +0100

```I can't see scope for negative skewness in a negative binomial. See
the skewness definition at

http://en.wikipedia.org/wiki/Negative_binomial_distribution
Nick
[email protected]

On 3 June 2013 16:45, Konrad Zdeb <[email protected]> wrote:
> 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,
>
>
> ----- Original Message -----
> Sent: 06/02/13 11:50 AM
> To: [email protected]
> Subject: Re: st: Generating random variable with predefined characteristics
>  Maarten,
>
>
> --
> Regards
>
> 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
>> 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,
> *
> *   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/
```