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
Sun, 2 Jun 2013 11:50:34 +0100
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/