1000
1
1
2
0
-1
Time
Dynamic simulation periods are specified in Time's definition. This is usually a list of numbers or labels, typically in some unit of time (days, weeks, months, etc.). Use the ÒDynamic()Ó function in your variables to perform dynamic simulation.
[0,1,2]
Correl
jtue
11. Julta 2005 13:07
jtue
11. Julta 2005 15:23
48,24
1,92,111,481,300,17
0,Model Correl,2,2,0,1,N:\Huippuyksikko\Tutkimus\Mallit\Functions\Correl_1.ANA
Group
['< 1','Adults','Elderly']
200,64,1
48,12
2,102,90,476,396
2,23,15,188,207,0,MIDM
21.3.2005 Jouni Tuomisto
Nimetty uudelleen Groups -> Group
Desired correlation
Table(Row,Col)(
1,0.99,
0.99,1
)
200,120,1
48,24
2,638,90,416,303,0,MIDM
52425,39321,65535
Graphtool:0
Distresol:10
Diststeps:0
Cdfresol:5
Cdfsteps:1
Symbolsize:6
Baroverlap:0
Linestyle:1
Frame:1
Grid:1
Ticks:1
Mesh:1
Scales:1
Rotation:45
Tilt:0
Depth:70
Frameauto:1
Showkey:1
Xminimum:0
Xmaximum:1
Yminimum:0
Ymaximum:1
Zminimum:0
Zmaximum:1
Xintervals:0
Yintervals:0
Includexzero:0
Includeyzero:0
Includezzero:0
Statsselect:[1,1,1,1,1,0,0,0]
Probindex:[0.05,0.25,0.5,0.75,0.95]
[Col,Row]
[Col,Row]
Correlated values
ug/m3/year/age
This node creates an exposure table to each age groups from year 2002 to year 2200.
The 0-1 year old exposure is assumed to be valid for years 1-6 years, adults exposure valid for years 7-59 and elder exposure for years 60-110.
Between 2002 and 2025 the exposure is changed linearly from year 2002 exposure to year 2025 exposure. Exposure before and after 2002 is assumed to be stable.
correlate(Samples_to_correlate,Desired_correlation1)
320,32,1
48,24
2,261,3,476,810
2,579,86,345,567,0,MEAN
Graphtool:0
Distresol:10
Diststeps:1
Cdfresol:5
Cdfsteps:1
Symbolsize:6
Baroverlap:0
Linestyle:1
Frame:1
Grid:1
Ticks:1
Mesh:1
Scales:1
Rotation:45
Tilt:0
Depth:70
Frameauto:1
Showkey:1
Xminimum:0
Xmaximum:1
Yminimum:0
Ymaximum:1
Zminimum:0
Zmaximum:1
Xintervals:0
Yintervals:0
Includexzero:0
Includeyzero:0
Includezzero:0
Statsselect:[1,1,1,1,1,0,0,0]
Probindex:[0.05,0.25,0.5,0.75,0.95]
[Group,Col]
[0,0,0,0]
21.3.2005 Jouni Tuomisto
Exposure_data-solmu sulautettu thn solmuun. Vanhoista solmuista tehtiin kopiot Old partsiin.
14.4.2005 Marko Tainio
Solmun laskeminen kulutti muistia niin paljon, ett mallia ei saatu ajettua. Poistin kaavasta muistisypn osuuden (alla) ja siirsin laskennan Life expectance -solmuun.
Poistettu koodi:
var d:= if Year<2002 then a else if Year < 2025 then c else b;
var e:= if Year<2002 then a else max([0,c]);
var f:= if Year<2010 then a else b;
array(Scenario,[0,a,e,d,f,10])
Row
This is the row index for the arrays. The number of rows and cols must be equal.
[1,2]
56,88,1
48,12
1,104,114,416,303,0,MIDM
22.3.2005 Jouni Tuomisto
Aiemmin kytss oli Num_vars, joka mritteli montako muuttujaa pistetn korreloimaan. Tm oli kmpel tapa, ja muutin asian niin, ett Samples_to_correlate on indeksoitu Cols-indeksill, jota voi muutta taulua muokatessa. Rows ja Rows1 taas mritelln copyindex(cols), jolloin ne mukautuvat tilanteeseen automaattisesti kunhan tm taulu on kunnossa.
Col
This is the column index for the arrays. The number of rows and cols must be equal.
[1,2]
56,64,1
48,12
2,136,146,416,303,0,MIDM
22.3.2005 Jouni Tuomisto
Aiemmin kytss oli Num_vars, joka mritteli montako muuttujaa pistetn korreloimaan. Tm oli kmpel tapa, ja muutin asian niin, ett Samples_to_correlate on indeksoitu Cols-indeksill, jota voi muutta taulua muokatessa. Rows ja Rows1 taas mritelln copyindex(cols), jolloin ne mukautuvat tilanteeseen automaattisesti kunhan tm taulu on kunnossa.
(data:prob; correl)
Correlate
Correlate version 1. (24.3.2005)
This model reorders a group of probabilistic variable samples so that they mimic a desired correlation structure as closely as possible.
Input variables
Data: The variables to be correlated. They may be of any distribution type; lognormal, beta, normal, etc., even different distributions for each variable are allowed. They must all have the same sample size. All the variables must be in one array indexed by Col index, one variable per one row of Col. If you are explicitly providing the samples (not analytically specifying distributions) then index this node by Run, and set the sample size in the Uncertainty Setup menu to equal the number of samples you have. The array data MUST have indexes Run and Col, but it may have other dimensions as well. Each additional dimension is treated independently.
Correl: This is the correlation matrix of the distributions from which I would like to sample. Being a Spearman correlation matrix, it must be symmetric. It must be indexed by Col and Row indexes.
Col, Row: Indexes for data variables and correlation matrix. These are NOT parameters in the function but global variables. They must be of the same size and content. It is recommended that they are lists of numbers 1..number of variables. The indexes are located beside the Correlate function. Note that if you have several groups of correlated variables, you must use the same Col and Row indexes even if the groups are not of the same size.
Introduction
For more information on this method see Iman, R.L., and Conover, W.J., "A distribution free approach to inducing rank correlation among input variables", Commun. Statist.-Simula. Computa. (Marcel Dekker,Inc.), 11(3), 1982, 311-334.
This model reorders a group of probabilistic variable samples so that they mimic a desired correlation structure as closely as possible.
The Scores local variable requires columns with identical numbers, but rearranged (i.e., Median Hypercube sampling). This variable should be hardwired to a MHS sample of the desired sample size (or a set of Van Der Warden scores-see Iman and Conover ref) if other portions of your model require selection of a different sampling technique.
The procedure
Var b:
This takes the Cholesky decomposition of the correlation matrix.
The desired correlation matrix, reindexed so that the inner product can be taken.
Var a:
In order to generate the joint normal we start with a vector of independent unit normal variables. It should contain the same numbers (scores) in each column, rearranged randomly. Median Latin Hypercube sampling provides the appropriate sample. If you want to use another sampling technique in your model, you should hard-wire this node to contain an MLH sample of the appropriate sample size (or a set of Van Der Warden Scores-see the Iman and Conover ref).
The calculations adjust the transformed matrix to account for the fact that the scores' correlation matrix is not the identity matrix; i.e., the scores samples are slightly correlated.
The correlation matrix for the scores.
The decomposition of the scores correlation matrix.
The inversion of the decomposed correlation matrix.
The matrix [inner] product of the decomposed desired correlation matrix (Var b) and the transformed score correlation matrix.
The transpose of the product provides us with a final matrix. In the next step we multiply the scores by this matrix to create a sample with the precise correlation matrix desired.
After adjusting for the correlation in the Scores, we arrive at a set of score samples that have exactly the desired correlation. The transformation of the unit normal scores affects their marginal distributions slightly.
The ranks of the unit normal sample points are used to reorder the desired sample. Used to rerank the samples in the desired distributions, simulating the desired correlation while preserving the marginal distributions of the sample.
Var c:
The ranks of your samples to be correlated.
This reordered sample matrix is the primary output of this model. It contains the samples reordered so that they mimic (as closely as possible) the desired correlation structure.
Larger sample sizes provide samples which more closely match the desired correlation structure.
This work is based on 'Correlated distributions.ana' file that accompanies Analytica program. It was further developed by Jouni Tuomisto and Marko Tainio, National Public Health Institute (KTL), Finland, in 2005.
for z[col,run]:= data do (
index row1:= copyindex(Row);
var b:= Decompose(correl);
b:= array(row1,Row,b);
var scores:= sample(normal(0*Row,1));
var a:= Correlation(Scores,Scores[Row=Col]);
a:= Decompose(a,Row,Col);
a:= invert(a,Row,Col);
a:= sum(b*a,Row);
a:= array(Col,Row,transpose(a,row1,Col));
a:= Sum((Scores*a),Row);
a:= Rank(a,Run);
var c:= rank(z,run);
for x:=run do (
for y:=Col do (
z[Col=y,run=subindex((c[Col=y]),(a[Col=y,run=x]), run)])))
56,32,1
48,24
2,323,39,476,671
data,correl
24.3.2005 Jouni Tuomisto
Parin viime pivn aikana yhdistin koko korrelaatiomokkulan yhdeksi funktioksi siten, ett descriptionit yhdistettiin sujuvaksi tekstiksi. Hommassa huomattiin virhe, eli se, ett ikryhmt olivat korreloituneet vahvasti. Tm johtuu siit, ett datassa ylimriset indeksit jostain syyst korreloidaan keskenn identtisell rankingill. Tst pstiin sill, ett luotiin uusi loop z, joka ajaa koko homman lpi jokaiselle runin ja colin lisksi olevalle indeksille rivi rivilt.
Tllin ilmeni uusi ongelma: jos col mritelln local variableksi, ohjelma kaatuu, mutta jos se pidetn global variablena, homma toimii moitteetta. Tm johtaa siis siihen, ett yhdess mallissa voidaan kytt vain yht col ja row -indeksi, vaikka korreloitavia muuttujapareja tai -ryhmi olisi useampiakin. Tmn kanssa on kuitenkin elminen.
Samples to correlate
Table(Group,Col)(
Uniform(0,1),Normal(0,1),
Uniform(0,0.8),Normal(0.2,1),
Uniform(0,0.6),Normal(0.4,1)
)
200,32,1
48,24
2,308,164,416,303,0,MIDM
2,56,66,416,303,0,SAMP
[Col,Group]
[Col,Run]
[0,0,0,0]
rankcorrel
rankcorrel(Correlated_values[col=1],Correlated_values[col=2])
432,32,1
48,24
2,642,422,416,303,0,MIDM