Subscript ranges

Use this forum to post Vensim related questions.
Post Reply
jv104
Junior Member
Posts: 9
Joined: Thu Mar 25, 2010 10:53 am

Subscript ranges

Post by jv104 »

Hi,

I am trying to create an SIS (infection) model using subscripts and subranges to represent age groups and gender but I am getting confused with subscript mapping. There are 3 different infection rates depending on the age of the contact partner which I am trying to capture in the rate lr t:

1. those who contract the condition as a result of contact with someone of the opposite <b>***</b> in the same age group as the index patient

2. those who contract the condition as a result of contact with someone of the opposite <b>***</b> in the age group below the index patient

3. those who contract the condition as a result of contact with someone of the opposite <b>***</b> in the age group above the index patient

I have 4 age groups 12-15, 16-20,21-25 and 26-40. I am having trouble with points 2 and 3 above as the 12-15 age group does not have a younger age group and the 26-40 age group does not have an older group.

I have worked through the examples in chapter 17 and also searched the web and this forum, any advice or tips would be greatly received.

Many thanks

Joe
Attachments
subcript age gender mix.mdl
(4.08 KiB) Downloaded 198 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

One way to do this is to forget about mapping and use a matrix to capture all possible interactions between age groups. Here's an outline of a simplified version of your problem:

age: (age1-age4)
fromAge <-> age
toAge <-> age

totalInfections[toAge] = sum(infections[fromAge!,toAge])
infections[fromAge,toAge] = uninfected[toAge]*infected[fromAge]*contactRate[fromAge,toAge]*probInfection[fromAge,toAge]

I may not have the functional form totally right, but the key idea is that probInfection and contactRate would capture the likelihood of interaction and probability of infection across groups. They'd be square [age x age] matrices, and any interaction that doesn't occur would just be reflected with a 0. This wastes a few clock cycles compared to the mapping approach, but it's a lot easier and you won't notice unless the arrays are big. The VECTOR SELECT function can be used for a speedup, but it's more complicated.

Tom
jv104
Junior Member
Posts: 9
Joined: Thu Mar 25, 2010 10:53 am

Post by jv104 »

Thanks Tom, that sounds promising I will look into Matrices and see if I can use them, the logic makes sense.

Joe
Post Reply