Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Generate three correlated variables

Subject: Generate three correlated variables

From: Gabriela Sicilia

Date: 12 Mar, 2012 15:30:11

Message: 1 of 8

Hello, I need to generate three random correlated variables: corr (x1,x2 )= -0,9; corr (x1,x3)= 0.9 and corr (x2, x3) =0. In addition, x1 and x1 are uniform (a,b) distributed and x2 is a normal (mu, sigma) distributed variable.

Thanks in advance,

Gabriela.

Subject: Generate three correlated variables

From: Roger Stafford

Date: 12 Mar, 2012 18:26:12

Message: 2 of 8

"Gabriela Sicilia" wrote in message <jjl4q3$pab$1@newscl01ah.mathworks.com>...
> Hello, I need to generate three random correlated variables: corr (x1,x2 )= -0,9; corr (x1,x3)= 0.9 and corr (x2, x3) =0. In addition, x1 and x1 are uniform (a,b) distributed and x2 is a normal (mu, sigma) distributed variable.
> ......
- - - - - - -
  Knowing the separate distributions of two random variables and their correlation does not uniquely determine their joint distribution. For example, if two dice are thrown and each die separately has 1/6 probability for each face, but together they have a non-zero correlation (due, say, to hidden magnets,) there are 36 unknowns in their joint distribution which are constrained to satisfy only 12 independent equations. There remain 24 degrees of freedom in choosing their joint distribution. Or, if both random variables are normal with given mean and variance, their correlation only determines their joint distribution if they are known to be jointly normal, which is a very powerful constraint.

  In other words you haven't given enough information to uniquely determine the joint distribution of your three random variables, and that would be needed to generate them properly.

Roger Stafford

Subject: Generate three correlated variables

From: Peter Perkins

Date: 12 Mar, 2012 19:06:55

Message: 3 of 8

As Roger said, you haven't provided specific enough information to have
a unique solution to your question, but you might find this

<http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/copulademo.html>

useful.


On 3/12/2012 2:26 PM, Roger Stafford wrote:
> "Gabriela Sicilia" wrote in message
> <jjl4q3$pab$1@newscl01ah.mathworks.com>...
>> Hello, I need to generate three random correlated variables: corr
>> (x1,x2 )= -0,9; corr (x1,x3)= 0.9 and corr (x2, x3) =0. In addition,
>> x1 and x1 are uniform (a,b) distributed and x2 is a normal (mu, sigma)
>> distributed variable. ......
> - - - - - - -
> Knowing the separate distributions of two random variables and their
> correlation does not uniquely determine their joint distribution. For
> example, if two dice are thrown and each die separately has 1/6
> probability for each face, but together they have a non-zero correlation
> (due, say, to hidden magnets,) there are 36 unknowns in their joint
> distribution which are constrained to satisfy only 12 independent
> equations. There remain 24 degrees of freedom in choosing their joint
> distribution. Or, if both random variables are normal with given mean
> and variance, their correlation only determines their joint distribution
> if they are known to be jointly normal, which is a very powerful
> constraint.
>
> In other words you haven't given enough information to uniquely
> determine the joint distribution of your three random variables, and
> that would be needed to generate them properly.
>
> Roger Stafford

Subject: Generate three correlated variables

From: ImageAnalyst

Date: 12 Mar, 2012 22:37:32

Message: 4 of 8

Maybe not uniquely, but maybe all she requires is "A" solution - any
solution at all that satisfies the requirements.

Subject: Generate three correlated variables

From: Jeff

Date: 12 Mar, 2012 23:22:21

Message: 5 of 8

On Tuesday, March 13, 2012 4:30:11 AM UTC+13, Gabriela Sicilia wrote:
> Hello, I need to generate three random correlated variables: corr (x1,x2 )= -0,9; corr (x1,x3)= 0.9 and corr (x2, x3) =0.

That pattern of correlations is impossible. With the specified x1/x2 and x1/x3 correlations, the x2/x3 correlation must be negative.

>In addition, x1 and x1 are uniform (a,b) distributed and x2 is a normal (mu, sigma) distributed variable.
As others have mentioned, there are various ways of producing correlations when some of the marginals are not normal. At the link below is a program that can be used to generate correlated non-normal random variables in a few different ways (described in its documentation). Sorry this is not matlab code, but you could use it to generate the values externally and then read them into matlab.

http://psy.otago.ac.nz/miller/progs/randgen.zip

Of course, first you must select a correlation matrix that is possible.

Subject: Generate three correlated variables

From: Gabriela Sicilia

Date: 13 Mar, 2012 09:07:12

Message: 6 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <a9a33dc8-7105-4f54-930e-d7d73b5fe17c@w5g2000yqi.googlegroups.com>...
> Maybe not uniquely, but maybe all she requires is "A" solution - any
> solution at all that satisfies the requirements.

Thanks everyone for your help. Exactly, what I need is "one" possible solution. Basically, what I want to generate is an instrumental variable. I 'm simulating an endogenous model (where x1 is the endogenous variable and x2 is the noise, so they are correlated strongly), and I want to generate a third variable x3 (the instrument) which is significally correlated with x1 but is not with x2. It could exist a weack negative correlation between x2 and x3, but it can't be a significative correlation.

Thans againg in advance,
Gabriela.

Subject: Generate three correlated variables

From: Peter Perkins

Date: 14 Mar, 2012 17:24:33

Message: 7 of 8

On 3/13/2012 5:07 AM, Gabriela Sicilia wrote:
> Thanks everyone for your help. Exactly, what I need is "one" possible
> solution.

Did you read the link I posted?

Subject: Generate three correlated variables

From: slama najla

Date: 6 Jun, 2012 16:24:07

Message: 8 of 8

Peter Perkins <Peter.Remove.Perkins.This@mathworks.com> wrote in message <jjqk8h$cr7$1@newscl01ah.mathworks.com>...
> On 3/13/2012 5:07 AM, Gabriela Sicilia wrote:
> > Thanks everyone for your help. Exactly, what I need is "one" possible
> > solution.
>
> Did you read the link I posted?


please can any one telle me how can i get a correlation between two 3d matrix(corr2 isn't applicable).Thanks

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us