Difference between revisions of "Correlate Dists"

 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[category:Multivariate Distribution Functions]]
+
[[Category:Multivariate Distribution Functions]]
 +
[[Category: Multivariate Distributions library functions]]
  
= Correlate_Dists(dists ; rankcorrs ; I,J : IndexType ) =
+
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 +
 
 +
== Correlate_Dists(dists, rankCorrs, I, J) ==
  
 
Used to create several distributions, with arbitrary marginals, that have given pairwise [[RankCorrel|rank correlations]].
 
Used to create several distributions, with arbitrary marginals, that have given pairwise [[RankCorrel|rank correlations]].
  
Reorders the samples in dists so as to match the desired rank correlations between distributions as closely as possible.  The matrix Dists, indexed by I, specifies the marginal distributions, one such marginal for each element of I. RankCorrs must be symmetric and positive definite, and the diagonal should contain all ones.
+
Reorders the samples in «dists» so as to match the desired rank correlations between distributions as closely as possible.  The matrix «dists», indexed by «I», specifies the marginal distributions, one such marginal for each element of «I». «RankCorrs» must be symmetric and positive definite, and the diagonal should contain all ones.
  
 
The result will be distributions having the same margins as the original input, but with rank correlations close to those of the rankcorrs matrix.
 
The result will be distributions having the same margins as the original input, but with rank correlations close to those of the rankcorrs matrix.
Line 11: Line 14:
 
If you need to define a single univariate distribution with a given [[RankCorrel|rank correlation]] relative to one other univariate distribution, then the [[Correlate_With]] function is a bit easier to use.
 
If you need to define a single univariate distribution with a given [[RankCorrel|rank correlation]] relative to one other univariate distribution, then the [[Correlate_With]] function is a bit easier to use.
  
= Library =
+
== Library ==
 +
Multivariate Distributions library functions ([[media:Multivariate Distributions.ana |Multivariate Distributions.ana]])
 +
:Use [[File menu|File]] &rarr; '''Add Library...''' to add this library
  
Multivariate Distributions.ana
+
== Notes ==
 +
Why must «rankCorrs» be positive definite?  This requirement arises from the fact that not all combinations of rank correlations are logically consistent.  As an extreme example, suppose we wanted the rank correlation of <code>X1</code> and <code>X2</code> to be +1, the rank correlation of <code>X1</code> and <code>X3</code> to be +1, but the rank correlation of <code>X2</code> and <code>X3</code> to be -1% (or anything other than +1). This is clearly not possible to achieve, and the matrix containing these rank correlations would not be positive definite.  The positive definite requirement captures this requirement that the specified rank correlations be self-consistent in the general case.
  
= Notes =
+
The function returns a re-ordering that comes ''as close as possible'' to achieving the specified rank correlations.  With a finite sample size, it might not be possible to obtain the precise rank correlation, but as your sample size increases, the sample rank correlation approaches the desired rank correlation specified in the «rankCorrs» parameter.
 
 
Why must rankCorrs be positive definite?  This requirement arises from the fact that not all combinations of rank correlations are logically consistent.  As an extreme example, suppose we wanted the rank correlation of X1 and X2 to be +1, the rank correlation of X1 and X3 to be +1, but the rank correlation of X2 and X3 to be -1% (or anything other than +1). This is clearly not possible to achieve, and the matrix containing these rank correlations would not be positive definite.  The positive definite requirement captures this requirement that the specified rank correlations be self-consistent in the general case.
 
 
 
The function returns a re-ordering that comes ''as close as possible'' to achieving the specified rank correlations.  With a finite sample size, it might not be possible to obtain the precise rank correlation, but as your sample size increases, the sample rank correlation approaches the desired rank correlation specified in the rankcorrel parameter.
 
 
 
= Example =
 
  
 +
== Example ==
 
If you would like to work through an example, you can start up Analytica and work through the following steps:
 
If you would like to work through an example, you can start up Analytica and work through the following steps:
 
* Select "Add Library..." from the file menu.
 
* Select "Add Library..." from the file menu.
* Select "Multivariate Distributions.ana" and press OK.  On the next dialog, select "Link".
+
* Select "Multivariate Distributions.ana" and press '''OK'''.  On the next dialog, select "Link".
* Create two index nodes and title them I and J.  Set both their definitions to [1,2,3]
+
* Create two index nodes and title them <code>I</code> and <code>J</code>.  Set both their definitions to <code>[1, 2, 3]</code>
* Create a variable node, title it "Desired Corr".  Set its definition to a Table and select indexes I and J.
+
* Create a variable node, title it <code>Desired_Corr</code>.  Set its definition to a ''Table'' and select indexes <code>I</code> and <code>J</code>.
* Fill in the edit table of Desired_Corr to:
+
* Fill in the edit table of <code>Desired_Corr</code> to:
    [ 1    0.5   -0.2 ]
+
 
    [ 0.5    1     0.6 ]
+
:{|class="wikitable"
    [ -0.2  0.6    1 ]
+
! !! colspan=3|I &#9654;
* Create a chance node and title it "Marginals".  Set its definition to a Table and select index I.
+
|-
* Fill in the edit table of Marginals as:
+
! J &#9660; !! 1 !! 2 !! 3
    [  Gamma(2,3) ]
+
|-
    [  LogNormal(3,5) ]
+
! 1
    [  Uniform(-3,3)  ]
+
|1  
* Create another chance node and title it "Final Dists". 
+
| 0.5
* Enter the following definition for Final_Dists:
+
| -0.2
Correlate_Dists( Marginals, Desired_Corr, I, J )
+
|-
* Press CTRL-U to access the uncertainty settings dialog.  Set sample size to 10K.
+
! 2
 +
|0.5     
 +
|1
 +
|0.6
 +
|-
 +
! 3
 +
-0.2   
 +
|0.6     
 +
|1  
 +
|}
 +
 
 +
* Create a chance node and title it <code>Marginals</code>.  Set its definition to a ''Table'' and select index <code>I</code>.
 +
* Fill in the edit table of <code>Marginals</code> as:
 +
:{| class="wikitable"
 +
! colspan=3|I &#9654;
 +
|-
 +
! 1
 +
! 2
 +
! 3
 +
|-
 +
|Gamma(2, 3)
 +
|LogNormal(3, 5)  
 +
|Uniform(-3, 3)
 +
|}
  
Now Final_dists contains the correlated distributions.  If you want to split these out into separate variables, you can follow these steps:
+
* Create another chance node and title it <code>Final_Dists</code>.   
* Create a variable node and title it X1Set its definition to:
+
* Enter the following definition for <code>Final_Dists</code>:
Final_dists[I=1]
+
:<code>Correlate_Dists(Marginals, Desired_Corr, I, J)</code>
* Repeat set 11 for X2 and X3, with definitions Final_dists[I=2] and Final_dists[I=3].
 
  
 +
* Press ''Ctrl+U'' to access the Uncertainty Settings dialog.  Set sample size to 10K.
 +
:Now <code>Final_dists</code> contains the correlated distributions.  If you want to split these out into separate variables, you can follow these steps:
 +
* Create a variable node and title it <code>X1</code>.  Set its definition to: 
 +
:<code>Final_dists[I = 1]</code>
  
= See Also =
+
* Repeat set <code>X1</code> for <code>X2</code> and <code>X3</code>, with definitions <code>Final_dists[I = 2]</code> and <code>Final_dists[I = 3]</code>.
  
 +
== See Also ==
 
* [[Correlate_With]]
 
* [[Correlate_With]]
 
* [[Gaussian]]
 
* [[Gaussian]]
 
* [[RankCorrel]]
 
* [[RankCorrel]]
 +
* [[Rank]]
 +
* [[Gamma]]
 +
* [[LogNormal]]
 +
* [[Uniform]]
 +
* [[Multivariate distributions]]
 +
* [[media:Multivariate Distributions.ana |Multivariate Distributions.ana]]

Latest revision as of 20:32, 24 May 2016


Correlate_Dists(dists, rankCorrs, I, J)

Used to create several distributions, with arbitrary marginals, that have given pairwise rank correlations.

Reorders the samples in «dists» so as to match the desired rank correlations between distributions as closely as possible. The matrix «dists», indexed by «I», specifies the marginal distributions, one such marginal for each element of «I». «RankCorrs» must be symmetric and positive definite, and the diagonal should contain all ones.

The result will be distributions having the same margins as the original input, but with rank correlations close to those of the rankcorrs matrix.

If you need to define a single univariate distribution with a given rank correlation relative to one other univariate distribution, then the Correlate_With function is a bit easier to use.

Library

Multivariate Distributions library functions (Multivariate Distributions.ana)

Use FileAdd Library... to add this library

Notes

Why must «rankCorrs» be positive definite? This requirement arises from the fact that not all combinations of rank correlations are logically consistent. As an extreme example, suppose we wanted the rank correlation of X1 and X2 to be +1, the rank correlation of X1 and X3 to be +1, but the rank correlation of X2 and X3 to be -1% (or anything other than +1). This is clearly not possible to achieve, and the matrix containing these rank correlations would not be positive definite. The positive definite requirement captures this requirement that the specified rank correlations be self-consistent in the general case.

The function returns a re-ordering that comes as close as possible to achieving the specified rank correlations. With a finite sample size, it might not be possible to obtain the precise rank correlation, but as your sample size increases, the sample rank correlation approaches the desired rank correlation specified in the «rankCorrs» parameter.

Example

If you would like to work through an example, you can start up Analytica and work through the following steps:

  • Select "Add Library..." from the file menu.
  • Select "Multivariate Distributions.ana" and press OK. On the next dialog, select "Link".
  • Create two index nodes and title them I and J. Set both their definitions to [1, 2, 3]
  • Create a variable node, title it Desired_Corr. Set its definition to a Table and select indexes I and J.
  • Fill in the edit table of Desired_Corr to:
I ▶
J ▼ 1 2 3
1 1 0.5 -0.2
2 0.5 1 0.6
3 -0.2 0.6 1
  • Create a chance node and title it Marginals. Set its definition to a Table and select index I.
  • Fill in the edit table of Marginals as:
I ▶
1 2 3
Gamma(2, 3) LogNormal(3, 5) Uniform(-3, 3)
  • Create another chance node and title it Final_Dists.
  • Enter the following definition for Final_Dists:
Correlate_Dists(Marginals, Desired_Corr, I, J)
  • Press Ctrl+U to access the Uncertainty Settings dialog. Set sample size to 10K.
Now Final_dists contains the correlated distributions. If you want to split these out into separate variables, you can follow these steps:
  • Create a variable node and title it X1. Set its definition to:
Final_dists[I = 1]
  • Repeat set X1 for X2 and X3, with definitions Final_dists[I = 2] and Final_dists[I = 3].

See Also

Comments


You are not allowed to post comments.