Transition probabilities dependent on age and cycle


I am in the process of creating a Markov model that will be analysed using microsimulation. I want to model different age groups separately (i.e. run the whole model separately for e.g. 10,000 30-year olds and then for 10,000 35-year olds). Transition probabilities in the model depend both on age and cycle. I have a variable "AgeGroup" that determines age in the model (defined at the root node). Is there a way of assigning the right transition probabilities based on e.g. a single table that includes the following columns:
- Age group
- cycle
- transition probability

Ideally, I would first like to filter the table for the right age group and then look for the right transition probability using the _stage keyword. However, I haven't been able to do this in TreeAge. Any help would be greatly appreciated!



  • Hi,

    An issue is that, regardless of the starting age group, as _stage increases, the age-group should change.

    Let's imagine that you have 5-year age groups: 25- 29, 30-34, 35-39.....etc.

    Let's assume, furthermore, that your cycle length is a year

    You could set up a table with age-groups as rows and _cycles as columns with the transition probabilities in the cells. Age groups would be represented by numbers which would serve as the index for the table.

    You'd like to move across the columns, from column 1 representing the first year of a five year age group to column 5 representing the last year of a five-year age group.

    At the root define CurrentAge = StartAge + _stage

    Where StartAge is the age at the beginning for a given age group, e.g. 25 for running the 25 - 29 age group.

    Use a nested 'if' statement for CurrentAgeGrp = if(CurrentAge<=29;1;CurrentAge<=34;2)......)

    Note that a second table could be created to avoid a messy 'if' statement. The former would list all of the integer ages and the corresponding age group numbers.

    CurrentColumn = mod(CurrentAge; 5) +1

    TransitionProb = tblTransProbs[CurrentAgeGrp; CurrentColumn]


    Comment actions Permalink
  • A note of explanation regarding the mod() function:

    CurrentColumn = mod(CurrentAge; 5) +1

    The modulo function does the type of integer division we learned in grade school: 7 goes into 5 once with two left over. Modulo gives the remainder, mod(7;5) = 2. 

    mod(25;5) = 0, mod(26;5) = 1.....mod(29; 5) = 4, mod (30;5) = 0 etc. Since there is no column 0 in a TreeAge table we add 1.0 to the expression:

    mod(25;5) + 1 = 1, mod(26;5) + 1 = 2.....mod(29; 5) + 1 = 5, mod (30;5)+ 1 = 1

    When _stage = 30, CurrentAgeGrp goes to 2, i.e. the second row of the table and CurrentColumn goes back to 1


    Comment actions Permalink
  • Thank you so much David! This was a great help and I have been able to finalise the model.

    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post