multi dimensioal array
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
multi dimensioal array
Hi,
I am building a population level model with aging and population having attributes.
The data I have looks like this
Age # of Patients SBP (average) HbA1c (average) BMI (average) TotaltoHDL (average)[/b]
25 1 109.8082 10.2271 31.6328 4.2518
26 1 97.0217 7.2728 30.2394 4.1116
27 1 131.4675 6.3382 29.6187 4.0322
28 2 134.8824 7.4660 27.7229 3.4343
29 2 152.9983 9.3213 23.2516 6.3040
The aging model from age 25 to 29 is working fine. My problem come from adding the attributes(characteristics) to each individual person in each age cohort.
Literature suggests make a stock of each attribute and simulate, which is totally understandable, but my problem is in defining the initial population with these attributes.
I am building a population level model with aging and population having attributes.
The data I have looks like this
Age # of Patients SBP (average) HbA1c (average) BMI (average) TotaltoHDL (average)[/b]
25 1 109.8082 10.2271 31.6328 4.2518
26 1 97.0217 7.2728 30.2394 4.1116
27 1 131.4675 6.3382 29.6187 4.0322
28 2 134.8824 7.4660 27.7229 3.4343
29 2 152.9983 9.3213 23.2516 6.3040
The aging model from age 25 to 29 is working fine. My problem come from adding the attributes(characteristics) to each individual person in each age cohort.
Literature suggests make a stock of each attribute and simulate, which is totally understandable, but my problem is in defining the initial population with these attributes.
- Attachments
-
- Test 2b.mdl
- Model
- (6.92 KiB) Downloaded 180 times
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
Re: multi dimensioal array
Ok I figured it out.
For example, set Age subscript for BMI. In equation editor add vale vertically followed by a , and last value no comma and hot enter.
Watch out for array dimension. You must enter same number of values for BMI as Age, other wise error will generated.
For example, set Age subscript for BMI. In equation editor add vale vertically followed by a , and last value no comma and hot enter.
Watch out for array dimension. You must enter same number of values for BMI as Age, other wise error will generated.
Re: multi dimensioal array
Often the easiest way to enter multidimensional arrays of constants is to put them in a spreadsheet and reference that via GET XLS or GET DIRECT.
Another option is to paste them in as a TABBED ARRAY (this is in the subtype menu for constants in the equation editor).
You can also use a delimited syntax directly in a constant's expression, like:
1,2,3;
7,6,5;
4,8,9;
3,6,3;
Yet another option is to supply a default value in the equation, then list the actual values in a .cin file.
See also: http://vensim.com/documentation/22070.h ... sub=tabbed
Another option is to paste them in as a TABBED ARRAY (this is in the subtype menu for constants in the equation editor).
You can also use a delimited syntax directly in a constant's expression, like:
1,2,3;
7,6,5;
4,8,9;
3,6,3;
Yet another option is to supply a default value in the equation, then list the actual values in a .cin file.
See also: http://vensim.com/documentation/22070.h ... sub=tabbed
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
Re: multi dimensioal array
Thanks Tom for your reply. It was quite helpful. I tried with GET DIRECT CONSTANTS. It dint't work
I added a subscript of SBP, but when I ran the model it gave me dimensional inconsistency.
For each age and gender it is mapping for each element of SBP group.
AGE24 MALE SBPAGE24
AGE24 MALE SBPAGE25
and so on.
Would it work if I map SBP onto age. I am trying this out now.
I am attaching the current model file and data file.
Please advice
Thanks
I added a subscript of SBP, but when I ran the model it gave me dimensional inconsistency.
For each age and gender it is mapping for each element of SBP group.
AGE24 MALE SBPAGE24
AGE24 MALE SBPAGE25
and so on.
Would it work if I map SBP onto age. I am trying this out now.
I am attaching the current model file and data file.
Please advice
Thanks
- Attachments
-
- data.xlsx
- (20.65 KiB) Downloaded 170 times
-
- Test 2e.mdl
- (4.57 KiB) Downloaded 188 times
Re: multi dimensioal array
Try the sample models in the help system for some examples of various GET layouts.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
Re: multi dimensioal array
I tried GET XLS data. But I am not been able to get what I want; for each age cohort, number of patients and their blood pressure.
I would really appreciate of there is some some vensim code for this.
I would really appreciate of there is some some vensim code for this.
Re: multi dimensioal array
I think you're trying to treat the array dimensions like database columns. When you dimension something with [age,gender,sbp] you're creating a 43 x 2 x 42 matrix. I doubt you need that. Also, when you make a 2D GET XLS call, Vensim expects a matrix, but your spreadsheet supplies a list. Again, check the subscripted GET examples in the help system. These will be in c:\users\public\Vensim\models\functionexamples if you can't activate the links in the help.
You might take a look at the cohort model associated with the SHIFT IF TRUE function for an example: http://vensim.com/documentation/fn_shift_if_true.htm
Also, cohort modeling is easier in Ventity:
https://www.systemdynamics.org/assets/c ... /P1363.pdf
https://www.systemdynamics.org/assets/c ... /S1363.zip
You might take a look at the cohort model associated with the SHIFT IF TRUE function for an example: http://vensim.com/documentation/fn_shift_if_true.htm
Also, cohort modeling is easier in Ventity:
https://www.systemdynamics.org/assets/c ... /P1363.pdf
https://www.systemdynamics.org/assets/c ... /S1363.zip
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
Re: multi dimensioal array
Hi Tom,
Thanks once again for your reply. I feel quite embarrassed that despite your so much input I am not able to get what I require.
I tried GET XLS SUBSCRIPT its works.
Then I put that subscript in equation for stock and aging.
But as before, problem is from giving initial value for population stock.
Initial population [gender,age]. When I set SBP subscripts it becomes Initial population [sbp,gender,age] *Gender is actual number of patients of each <b>***</b>
In equation editor
Equation subscripts [Male,age] and values I enter are like one column for each entry of AGE array (total element of 43)
1,
2,
3,
.
.
To me it looks like here I am doing something wrong.
SBP MALE AGE
109 1 24
110 3 25
120 5 26
I need to have something like this.
May be I am think in C or mat lab and Vensim works differnetly
Please guide!
Thanks once again for your reply. I feel quite embarrassed that despite your so much input I am not able to get what I require.
I tried GET XLS SUBSCRIPT its works.
Then I put that subscript in equation for stock and aging.
But as before, problem is from giving initial value for population stock.
Initial population [gender,age]. When I set SBP subscripts it becomes Initial population [sbp,gender,age] *Gender is actual number of patients of each <b>***</b>
In equation editor
Equation subscripts [Male,age] and values I enter are like one column for each entry of AGE array (total element of 43)
1,
2,
3,
.
.
To me it looks like here I am doing something wrong.
SBP MALE AGE
109 1 24
110 3 25
120 5 26
I need to have something like this.
May be I am think in C or mat lab and Vensim works differnetly
Please guide!
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: multi dimensioal array
Can you upload the model you have? I'm not really following what you are describing.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
Re: multi dimensioal array
The EXCEL file is the one I want to input as in BASELINE POPULATION in the model.
there are no births or deaths, population is fixed.
My aim is to have for each age cohort with number of patients (male and female) and their respective SBP in the BASELINE POPULATION.
there are no births or deaths, population is fixed.
My aim is to have for each age cohort with number of patients (male and female) and their respective SBP in the BASELINE POPULATION.
- Attachments
-
- data - Copy.xlsx
- (13.08 KiB) Downloaded 163 times
-
- Test 2e.mdl
- (4.08 KiB) Downloaded 183 times
Re: multi dimensioal array
"SBP" is an attribute of the patient (blood pressure?), right? In that case I think we don't want it to be an array dimension. I'll take another look.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
Re: multi dimensioal array
yes, SBP is blood pressure. And it is an attribute of a patient. Each age cohort has different SBP. To me Array was the only option I could apply. Nevertheless,
I will be waiting for your guidelines.
Thank you
I will be waiting for your guidelines.
Thank you
Re: multi dimensioal array
This version has the GET functions working.
BP needs to be implemented as a coflow attribute, not as an extra dimension. You could essentially copy-paste the population structure and adapt it for the BP attribute./*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
Re: multi dimensioal array
Thanks once again.
I will implement BP as a co-flow structure. I see that you have corrected equations too.
You added recruitment inflow to model, I can understand the logic, but in my case the population doesn't change, it only ages. So, I made it equal to zero.
I will implement BP as a co-flow structure. I see that you have corrected equations too.
You added recruitment inflow to model, I can understand the logic, but in my case the population doesn't change, it only ages. So, I made it equal to zero.
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
Re: multi dimensioal array
I replicated the structure for BP. For age 25 to 35 the BP attribute vale remain constant but for age 36 till 65 with each step of simulation the BP value changes.
My requirement is to keep these values constant for each age cohort for entire simulation run.
As there is no inflow or outflow exept aging.
I have attached the model. Please advise.
Thanks
My requirement is to keep these values constant for each age cohort for entire simulation run.
As there is no inflow or outflow exept aging.
I have attached the model. Please advise.
Thanks
- Attachments
-
- Test 2g.mdl
- (5.83 KiB) Downloaded 185 times
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: multi dimensioal array
The model does not simulate, it's missing the Excel file needed to run it.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
Re: multi dimensioal array
Model behave a bit better now. I have made aging of BP equal to zero.
- Attachments
-
- dataTF.xlsx
- (12.31 KiB) Downloaded 160 times
-
- Test 2g1.mdl
- (5.82 KiB) Downloaded 172 times
Re: multi dimensioal array
So the problem is that it misbehaves when you remove the *0 from SBP aging?
One suggestion: define units for the whole model. That might reveal an issue that's easy to overlook.
One suggestion: define units for the whole model. That might reveal an issue that's easy to overlook.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: multi dimensioal array
... or, if you want SBP to be a static function of age, so that it doesn't move with the cohorts, the *0 might be the right thing to do. You could also eliminate the SBP flow dynamics easily, and treat it like an array or lookup.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Junior Member
- Posts: 14
- Joined: Thu Jul 06, 2017 2:03 am
- Vensim version: DSS
Re: multi dimensioal array
Thanks for your feedback and suggestions.