Seminar on POHEM – Tables

30
1 1 Seminar on POHEM – Tables Philippe Finès September 2011

description

Seminar on POHEM – Tables. Philippe Finès September 2011. 1. Introduction. In the process of developing a program in POHEM, a few tools exist Debugging – step by step analysis of the statements executed, with a display of the values of the variables used - PowerPoint PPT Presentation

Transcript of Seminar on POHEM – Tables

Page 1: Seminar on POHEM –  Tables

11

Seminar on POHEM – Tables

Philippe FinèsSeptember 2011

Page 2: Seminar on POHEM –  Tables

22

Introduction

• In the process of developing a program in POHEM, a few tools exist– Debugging – step by step analysis of the

statements executed, with a display of the values of the variables used

– Tables – storage and display of values produced during the execution

– BioBrowser – display of biographies of individuals in the simulation

Page 3: Seminar on POHEM –  Tables

33

Usage of tables

• End-user• Developer

Page 4: Seminar on POHEM –  Tables

4

Usage of tables for an end-user

Page 5: Seminar on POHEM –  Tables

5

POHEM screenOnce the execution is finished, one can open a

table and display its contents on the screen

Page 6: Seminar on POHEM –  Tables

6

… or do File > Export > ExcelIn this screen, the user selects

the statisticsthe table style

the tables to export

Page 7: Seminar on POHEM –  Tables

7

In this screen, the user indicates the directory and name of the exported table

Page 8: Seminar on POHEM –  Tables

8

Excel sheet exported from POHEM (Pivot format)

Sex Age groupCalendar Year

Persons alive (N)

Current Prevalence count (P)

Startup Prevalence count (S)

Incidence count (I)

Current Prevalence rate (P/N)

Startup Prevalence rate (S/N)

Incidence rate (I/R)

Current PY Prevalence Rate (Q/Y)

Person-years alive (Y)

Person-years with OA (Q)

Person-years at risk of OA Incidence (R)

Deaths (D)

Had OA at time of death (X)

Persons alive (Unit) (U)

Female [20,25[ 2001 369481 1256 1021 235 0.00339936 0.002763336 0.000638 0.003080603 369421.9 1138.042 368283.8 120 1 369481Female [20,25[ 2002 375496 1273 831 263 0.00339018 0.002213073 0.000703 0.003015292 375440.1 1132.062 374308.1 108 0 448200Female [20,25[ 2003 382205 1253 695 203 0.00327835 0.001818396 0.000533 0.003019312 382145.8 1153.817 380992 122 0 455438Female [20,25[ 2004 387051 1268 576 269 0.00327605 0.001488176 0.000697 0.002917793 386992.3 1129.163 385863.1 115 0 463116Female [20,25[ 2005 390440 1205 494 221 0.00308626 0.001265239 0.000568 0.0028175 390382.2 1099.902 389282.3 124 0 468326Female [20,25[ 2006 392664 1212 507 229 0.00308661 0.00129118 0.000585 0.002793235 392595.5 1096.612 391498.9 125 0 471594Female [20,25[ 2007 391220 1202 517 232 0.00307244 0.001321507 0.000595 0.0027496 391154.2 1075.518 390078.7 124 0 470793Female [20,25[ 2008 389366 1205 499 228 0.00309477 0.001281571 0.000587 0.002806603 389310.4 1092.64 388217.8 120 0 469365Female [20,25[ 2009 388774 1214 522 220 0.00312264 0.001342682 0.000568 0.002847141 388720.8 1106.743 387614 123 0 470128Female [20,25[ 2010 390885 1247 545 239 0.0031902 0.001394272 0.000613 0.002874111 390817.1 1123.252 389693.8 137 1 471963Female [20,25[ 2011 393249 1251 537 228 0.00318119 0.001365547 0.000582 0.002886452 393194.7 1134.938 392059.8 120 0 474363Female [20,25[ 2012 397931 1285 534 265 0.0032292 0.001341941 0.000668 0.002903035 397875 1155.045 396720 106 0 476040Female [20,25[ 2013 401566 1340 553 267 0.00333694 0.001377109 0.000667 0.003008136 401508.2 1207.791 400300.4 120 1 479739Female [20,25[ 2014 401588 1334 557 239 0.00332181 0.001386994 0.000597 0.003016041 401537.2 1211.053 400326.2 110 0 482362Female [20,25[ 2015 399053 1267 521 232 0.00317502 0.001305591 0.000583 0.002886634 398996.7 1151.757 397844.9 117 0 482203Female [20,25[ 2016 396140 1251 506 246 0.00315797 0.001277326 0.000623 0.002851215 396086.4 1129.328 394957.1 103 0 479516Female [20,25[ 2017 389413 1248 506 243 0.00320482 0.001299392 0.000626 0.002874149 389360 1119.079 388240.9 105 1 472434Female [20,25[ 2018 382545 1198 474 235 0.00313166 0.00123907 0.000616 0.002817127 382492.1 1077.529 381414.5 113 0 464483Female [20,25[ 2019 375764 1113 426 204 0.00296197 0.00113369 0.000544 0.002694999 375704.4 1012.523 374691.9 119 0 456486Female [20,25[ 2020 366775 1117 446 214 0.00304546 0.001216004 0.000585 0.002754118 366720.7 1009.992 365710.7 106 0 447469Female [20,25[ 2021 357604 1059 430 224 0.00296138 0.001202447 0.000628 0.002654078 357556.1 948.982 356607.1 95 0 437971Female [20,25[ 2022 0 0 0 0 0 0 0 357509 1059 357509

Page 9: Seminar on POHEM –  Tables

9

Incidence rate of OA by year and sex

Page 10: Seminar on POHEM –  Tables

10

Persons-years with OA and deaths by year and sex

Page 11: Seminar on POHEM –  Tables

11

Usage of tables for a developer

Page 12: Seminar on POHEM –  Tables

1212

Example of code for Tablexxx.mpp: Table.OA.mpp

Page 13: Seminar on POHEM –  Tables

13

Example 1partition HUI_CAT_PRE_SURG_4 {0.245, 0.544, 0.75};partition OA_AGE_GROUP {5,10, 15, 20, 25, 30, 35, 40, 45, 50,

55, 60, 65, 70, 75, 80, 85, 90 };partition YEAR_2001_to_2021

{2001,2002,2003,2004,2005,2006,2007,2008,2009,2010, 2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,

2021,2022};

table Person tgHUIcat_MR_OK_4{

sex+*split(truncated_age,OA_AGE_GROUP)+*split(gHUI_OA,HUI_CAT_PRE_SURG_4)+*split(calendar_year,YEAR_2001_2021) +* { unit,first_entrances(OA_Event_State,OA_Primary_Surgery),

value_at_first_entrance(OA_Event_State,OA_Primary_Surgery,gHUI_OA),

value_at_first_entrance(OA_Event_State,OA_Primary_Surgery,gHUI_OA)/

first_entrances(OA_Event_State,OA_Primary_Surgery)}

};

• These statements may be declared anywhere (i.e. in this module or in another)

• For each sex (+ total)

• For each age category (+ total)

• For each category of HUI pre surgery (+ total)

• For each year from 2001 to 2021 (+ total)

• Compute the following:

– Nb of persons– Nb of time the state is a Primary

Surgery– Value of HUI the 1st time the state is

a Primary Surgery– Average value of HUI the 1st time the

state is a Primary Surgery

• Purpose: – We wanted to verify that the average

HUI lies within its boundaries (debugging)

– We wanted to know whether the probability of having a primary surgery varies with HUI pre-surgery

Page 14: Seminar on POHEM –  Tables

14

Example 2table Person tAMIevents_CulturalOrigin [dominant &&

alive && calendar_year==pStartYear] //EN AMI events by cultural origin

{{

nz_delta( duration()), // countentrances( cad_state, DH_MI1 ),

// INDEX AMI incidence

entrances( gDiabetes, DIAB_YES ), // Diabetes incidence

duration(), // pyduration( cad_state, DH_MI1 ),

// INDEX AMI prevalence pyduration( gDiabetes, DIAB_YES ),

// Diabetes prevalence py

nz_delta( duration( cad_state, DH_MI1 )), // INDEX AMI prevalence counts

nz_delta( duration( gDiabetes, DIAB_YES )) // Diabetes prevalence counts

}* sex+ // sex* gCulturalOrigin+ // cultural origin

};

• Among living persons in 2001 (filter)

• By sex (+ total)• By cultural origin (+ total)

• Compute the following:

– Nb of persons– Nb of persons with AMI – Nb of persons with

Diabetes

• Purpose: – We wanted to count the

incidence and prevalence of these 2 risk outcomes

Page 15: Seminar on POHEM –  Tables

15

Example 3partition YEAR_2001_to_2021

{2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,

2011,2012,2013,2014,2015,2016,2017,2018,2019,2020, 2021,2022};

table Person tHUImeanb{

split(calendar_year,YEAR_2001_to_2021)+*sex+*OA_Event_State+ *{

unit,duration(),weighted_duration ( gHUI_OA ),weighted_duration ( gHUI_OA ) / unit,weighted_duration ( gHUI_OA ) / duration()

}};

• For each year from 2001 to 2021 (+ total)

• For each sex (+ total)

• For each state

• Compute the following:

– Nb of persons– Duration of time spent in

that state (i.e. persons-years)

– “Sum of values of HUI”– Average HUI per individual

(not recommended)– Average HUI per person-

year

• Purpose: – We wanted to compute the

average HUI per OA state (see next slide)

Page 16: Seminar on POHEM –  Tables

16

Example 4actor Person (in PersonCore.mpp){//EN Integer age when actor started

LIFE_SPAN lifespan_age_start;

table Person Life_Expectancy//EN Life expectancy, HALE and average HUI of initial population

{sex+*lifespan_age_start+*{

unit, //EN Nb personsduration(), //EN Person-years decimals=2

N.B.: “decimals=2” is a correct statement, it is used in the label part

weighted_duration(gHUI_OA), //EN Total HUIduration()/unit, //EN LE decimals=2weighted_duration(gHUI_OA)/unit, //EN HALE decimals=2weighted_duration(gHUI_OA)/duration() //EN Average HUI decimals=2

}};

This title appears in the list of tables

All that appears after the // is a label in the table

Page 17: Seminar on POHEM –  Tables

17

Example 4 – Excel file producedTable: Life_ExpectancyTable Description:Life expectancy, HALE and average HUI of initial populationData:Value

Selected Quantities

Sex

Integer age when actor started

Nb persons

duration( ) Total HUI LE HALE Average

HUILE + age at start

HALE + age at start

Female 0 0 0 0Female 1 0 0 0 1 1Female 2 0 0 0 2 2Female 3 0 0 0 3 3Female 4 0 0 0 4 4Female 5 0 0 0 5 5Female 6 0 0 0 6 6Female 7 0 0 0 7 7Female 8 0 0 0 8 8Female 9 0 0 0 9 9Female 10 0 0 0 10 10Female 11 0 0 0 11 11Female 12 0 0 0 12 12Female 13 0 0 0 13 13Female 14 0 0 0 14 14Female 15 0 0 0 15 15Female 16 0 0 0 16 16Female 17 0 0 0 17 17Female 18 200555 13433178 10459027 66.98002 52.15042 0.778597 84.98002 70.15042Female 19 201689 13321747 10371668 66.05093 51.42407 0.778552 85.05093 70.42407Female 20 215860 14039474 10918810 65.03972 50.58283 0.777722 85.03972 70.58283Female 21 215906 13806643 10729425 63.94747 49.69489 0.77712 84.94747 70.69489Female 22 212144 13345176 10360368 62.90621 48.83649 0.776338 84.90621 70.83649Female 23 207714 12867378 9963293.3 61.94757 47.9664 0.774306 84.94757 70.9664Female 24 208775 12703938 9824618.2 60.8499 47.0584 0.773352 84.8499 71.0584Female 25 191400 11452823 8819640.3 59.83711 46.07963 0.770084 84.83711 71.07963Female 26 192195 11295475 8674833.7 58.77091 45.13558 0.767992 84.77091 71.13558

Last 2 columns computed in excel

Page 18: Seminar on POHEM –  Tables

18

Example 4 – Excel file producedLE and HALE, fem ales

0102030405060708090

100

18 38 58 78 98

age at s tart of s im ulation

LE (LE at age at start + age at start) HALE (HALE at age at start + age at start)

Page 19: Seminar on POHEM –  Tables

19

Example 4 – Excel file producedAverage HUI, m ales and fem ales

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

18 38 58 78 98

age at start of s im ulation

Females Males

Page 20: Seminar on POHEM –  Tables

20

Example 5partition OA_AGE_GROUP {5,10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 }; table Person tnboaCA //EN Nb of OAs in CA{

sex+*split(truncated_age,OA_AGE_GROUP)+*{unit, //EN Units (0A)

entrances(alive, FALSE), //EN Deathsvalue_at_entrances (alive, FALSE, IndexOA_event),

//EN counts the number of IndexOA_event at time of Deathevent(entrances(IndexOA_event, TRUE))/duration(IndexOA_event,FALSE),

// Incidence rate decimals=9 event(entrances(IndexOA_event, TRUE)), // New incident casesduration(IndexOA_event,FALSE), // Denominator for incidencenz_delta(duration(PrevOA_event, TRUE))/nz_delta(duration()), // Prevalence 2001 rate decimals=9nz_delta(duration(PrevOA_event, TRUE)), // Numerator of prevalencenz_delta(duration()), // Denominator of prevalence

/* nz_delta(duration(IndexOA_event, TRUE)) +nz_delta(duration(PrevOA_event, TRUE)), // Cumulative prevalence */nz_delta(duration(IndexOA_event, TRUE)) , // Cumulative prevalence

/* (nz_delta(duration(IndexOA_event, TRUE))+nz_delta(duration(PrevOA_event, TRUE)))/nz_delta(duration()), // Prevalence rate */nz_delta(duration(IndexOA_event, TRUE))/nz_delta(duration()), // Prevalence rate decimals=9duration(IndexOA_event, TRUE),duration(), duration(IndexOA_event, TRUE)/duration()}*calendar_year+

};

This title appears in the list of tables

All that appears after the // is a label in the table

Page 21: Seminar on POHEM –  Tables

21

Example 5 – Excel file producedRows with label in italics

computed in excelTable: tOA_CanadaTable Description:Osteoarthritis outcomes for CanadaData:Value

Sex Age group Selected Quantities 1999 2000 2001 2002 2003 2004 2005Female All Persons alive (N) 0 0 11872764 12066684 12273169 12473520 12672943Female All Current Prevalence count (P) 0 0 1645494 1696440 1748481 1799000 1849808Female All Current Prevalence rate (P/N) 0.138594 0.140589 0.142464 0.144226 0.145965Female All Startup Prevalence count (S) 0 0 1559879 1523746 1486721 1447408 1407469Female All Startup Prevalence rate (S/N) 0.131383 0.126277 0.121136 0.116038 0.111061

New prevalence 85615 172694 261760 351592 442339Rate of new prevalence 0.007211 0.014312 0.021328 0.028187 0.034904Persons at risk 10312885 10421190 10576729 10725039 10873943

Female All Incidence count (I) 0 0 85615 87657 90861 92848 95139Incidence rate (based on number of persons) 0.008302 0.008411 0.008591 0.008657 0.008749

Female All Person-years alive (Y) 0 0 11831481 12023403 12227322 12425133 12622128Female All Person-years with OA (Q) 0 0 1583716 1632367 1681318 1729587 1777872Female All Current PY Prevalence Rate (Q/Y) 0.133856 0.135766 0.137505 0.139201 0.140854Female All Person-years at risk of OA Incidence (R) 0 0 10247765 10391036 10546004 10695545 10844256Female All Incidence rate (I/R) 0.008355 0.008436 0.008616 0.008681 0.008773Female All Deaths (D) 0 0 82169 85976 90849 95577 100791Female All Had OA at time of death (X) 0 0 38330 40642 43557 46198 48935

Dead without OA 43839 45334 47292 49379 51856Cumul deaths 82169 164338 250314 341163 436740Cumul dead with OA 38330 78972 122529 168727 217662Cumul dead without OA 43839 89173 136465 185844 237700

Female All Persons alive (Unit) (U) 0 0 11872764 14464653 14702997 14938177 15187638

Page 22: Seminar on POHEM –  Tables

22

Example 5 – Excel file produced

0

2000000

4000000

6000000

8000000

10000000

12000000

14000000

16000000

18000000

2001 2006 2011 2016 2021 2026

Number of persons Number of PY Number of persons at risk Number of PY at riskNumber of persons with OA Number of PY with OA Startup prevalence (persons) New prevalence (persons)

Females

Page 23: Seminar on POHEM –  Tables

23

• Thank you

• Questions?

Page 24: Seminar on POHEM –  Tables

24

APPENDIX: The “derived states” in ModGen(from ModGen documentation)

Page 25: Seminar on POHEM –  Tables

25

• Derived states associated with changes to actor states• Listed in alphabetic order:• changes( state )

The number of times the classification state has changed so far in the simulation.e.g.    changes (dfle) records the number of times the disability status has changed.  Consider a person who survived to age 77 and whose disability status changed every 10 years from the age of 15 onwards. The value of changes would be zero until the person turned 15 years old, 1 until the person turned 25 years old,  2 until the person’s 35 birthday, and so on. At the age of death changes would equal 7.

• entrances( variable, state )The number of times the variable has entered the state to that point in time in the simulation. e.g.    entrances ( dfle, SEVERE_DIS)  records the number of times an individual has entered the severe disability state to that point in the simulation. If a person survived to age 75, and his disability status entered the severe state at age 25 and 60, then the value returned by entrances is 0 until he turned 25 , 1 until he turns 60, and 2 for the remainder of his life.

• exits( variable, state )The number of times the variable exited the state so far in the simulated lifetime.e.g.    exits ( dfle, SEVERE_DIS)  records the number of times an individual has exited the severe disability state to that point in the simulation. If a person survived to age 75, and his disability status entered the severe state at age 25 and 60 and exited the severe status at 31, then the value returned by exits is 0 until he turned 31 and 1 for the remainder of his life.

• undergone_change( variable )The value of this function is 1 if  the variable has changed its state by that point in the simulation and 0 otherwise.e.g.    Consider a person who survived to age 75 and who became disabled at age 68. Then, the value of  undergone_change( dfle)  is 0 until he turns 68 year old and 1 for the remainder of his life.

• undergone_entrance( variable, state )The value of this function is 1 if  the variable has entered the state by that point in the simulation and 0 otherwise.e.g.   Consider a person who survived to age 75 and who became severely disabled at age 68. Then, the value of  undergone_entrance(dfle, SEVERE_DIS)  is 0 until he turns 68 year old and 1 for the remainder of his life.

• transitions( variable, from state, to state )The number of times the variable has entered the "to state" from the "from state" so far in the simulated lifetime.eg.     transitions ( dfle, MILD_DIS, MEDIUM_DIS)  records the number of times an individual left the mild disability state to enter the medium disability state so far in the simulation.

Page 26: Seminar on POHEM –  Tables

26

• value_at_changes ( variable,  recorded variable )The sum of the values of  the recorded variable when the variable changes.  This function is used, in conjunction with changes, to calculate the average value of a recorded variable as the variables has changed so far in a simulation.e.g. value_at_changes ( dfle, age)  records the sum of each age at which the disability status changes. If a person survived to age 77, and his disability status changed every 10 years from age 15 onwards, then the value returned by the function at the age of death is 15+25+35+45+55+65+75 = 260. The average age of change would be given by dividing this result by the number of changes: 260/7=37.1

• value_at_entrances ( variable, state, recorded variable)The sum of the values of the recorded variable at which the value of variable entered the state. This function is used, in conjunction with entrances, to calculate the average value of a recorded variable for entrances into a state over the simulated lifetime.e.g.    value_at_entrances ( dfle, SEVERE_DIS, age)  records the sum of each age at which the disability status entered the severe state.  If a person survived to age 75, and his disability status entered the severe state at age 25 and 60, then the value of value_at_entrances is 0 to his 25th birthday, 25 to his 60 birthday, and 85 until the time of his death.

• value_at_exits ( variable, state, recorded variable )The sum of the values of the recorded variable at which the value of variable exited the state. This function is used, in conjunction with exits to calculate the average value of a recorded variable for exits out of a state over the simulated lifetime.eg.     value_at_exits ( dfle, SEVERE_DIS, age) records the sum of each age at which the disability status left the severe state.  If a person survived to age 75, and his disability status entered the severe state at age 25 and 60 and exited the severe status at 31, then the value of value_at_exits is 0 to his 31st birthday, and 31 until the time of his death.

• value_at_first_change( variable, recorded variable )The value of  the recorded variable at which time the value of variable first changed.  If the variable has not yet changed its the state at that point in the lifetime, then the function has a value of zero.e.g.    value_at_first_change ( dfle, age)  records the age of a person at which the disability status first changed.  If a person survived to age 70, and his disability status changed at age 25 and 60, then the value of value_at_first_change is 0 until he turned 25 and 25 for the remainder of his life.

Page 27: Seminar on POHEM –  Tables

27

• value_at_first_entrance( variable, state, recorded variable )The value of  the recorded variable at which time the value of variable first entered the state.  If  the variable has not yet entered the state at that point in the lifetime, then the function has a value of zero.e.g.    value_at_first_entrance ( dfle, SEVERE_DIS, age)  records the age of a person at which the disability status first entered the severe state.  If a person survived to age 70, and his disability status entered the severe state at age 25 and 60, then the value of value_at_first_entrance is 0 until he turned 25 and 25 for the remainder of his life.

• value_at_transitions ( variable, from state, to state, recorded variable )The sum of the values of  the recorded variable at which the value of variable  left the from state and entered the to state.  This function is used, in conjunction with transitions, to calculate the average value of a recorded variable as the variables has changed so far.eg.     value_at_transitions ( dfle, MILD_DIS, MEDIUM_DIS, age)  records the sum of each age at which the disability status left the mild state and entered the severe state.

• value_at_latest_change( variable, recorded variable )The value of the recorded variable at which the value of variable last changed.  If the classification variable never changed, then the function returns a zero.e.g.    value_at_latest_change ( dfle, age)  records the age of a person at which the disability status last changed its state.  If a person survived to age 75, and his disability status changed age 25 and at 60, then the value returned by value_at_latest_entrance is 0 to his 25 birthday, 25 to his 60th birthday,  and 60 until the time of his death.

• value_at_latest_entrance(variable, state, recorded variable)The value of the recorded variable at which the value of variable last entered the state.  If the classification variable never entered the classification state, then the function returns a zero.e.g.    value_at_latest_entrance ( dfle, SEVERE_DIS, age)  records the age of a person at which the disability status last entered the severe state.  If a person survived to age 75, and his disability status entered the severe state at age 25 and at 60, then the value returned by value_at_latest_entrance is 0 to his 25 birthday, 25 to his 60th birthday,  and 60 until the time of his death.

Page 28: Seminar on POHEM –  Tables

28

• Derived states associated with durations of actor states• The following expressions accumulate the values of a variable over the range of time an actor

was in a specified state.  When these expressions are used inside a table specification, then Modgen duration is only calculated for the time the actor is in the domain of the table.  For example, if a table filter included residency status, then the duration of immigrant actor would only count the time the actor was a resident.

• A subset of these functions or expressions operate on states over "spells" (i.e. periods of time over which a state assumes a specific value).  These spell functions fall into two classes, those that operate on a "current” or “active" spell, and those that operate on a "completed” or “previous" spell.  These two classes of functions behave very differently.  In particular, the "active" functions are saw-tooth in form, returning to zero at the end of each spell, whereas the "completed" functions are step-like in form.

•  • active_spell_delta ( variable, state, analysis variable )

This reports on the change that the analysis variable has undergone since the variable has been in the state.eg.     active_spell_delta ( dfle, MILD_DIS, earnings)  records the sum of earnings over the time an individual has currently been in the mild disability state in the simulation.

• active_spell_duration ( variable, state )The length of time the variable has currently been in the state from its last transition from a previous state in the simulation.  If the actor has been in the same state for its entire lifetime to date, then the value of this function is zero.eg.     active_spell_duration ( dfle, MILD_DIS)  records the length of time an individual has currently been in the mild disability state in the simulation.  Consider a person who has survived to age 75, his disability status entered the mild state at age 20, exited the mild state at 25, returned to it at aged 60, and stayed in this state until the time of his death.  The value of active_spell_duration is 0 until he turned 20, 1 when he is 21, 2 when he is 22, and so on until his 25th birthday.  At that point active_spell_duration would return to zero,  until age 60 where it would be incremented by 1 for each year until he died.

Page 29: Seminar on POHEM –  Tables

29

• active_spell_weighted_duration ( variable, state, weighting variable )This is a weighted version of active_spell_duration.  It could be used to determine, for example, the income earned so far during the current (on-going) spell of employment.  This would be done by using the earnings rate variable as the weighting variable.

• completed_spell_delta (variable, state, analysis variable)This reports on the change that the analysis variable has undergone in the last completed spell in which the variable was in the state.eg.     completed_spell_delta (dfle, MILD_DIS, earnings)  records the sum of earnings over the previous completed time an individual was in the mild disability state in the simulation.

• completed_spell_duration(variable, state)The length of time the variable was last in the state. If the actor has been in the same state for its entire lifetime to date, then the value of this function is zero.eg.     completed_spell_duration ( dfle, MILD_DIS)  records the length of time an individual was last in the mild disability state.  Consider a person survived to age 75, and his disability status entered the mild state at age 20, exited the mild state at 25, returned to it at aged 60, and stayed in this state until the time of his death.  The value of completed_spell_duration is 0 until he turned 25, and 5 until the time of the actor’s death.

• completed_spell_weighted_duration (variable, state, weighting variable)This is a weighted version of completed_spell_duration.  It could be used to determine, for example, the income earned during a previous spell.  This would be done by using the earnings rate variable as the weighting variable.

• duration( variable, state )   or   duration()The length of time the value of the actor variable has been in the state so far in the simulated lifetime.  If the variable and state are not specified, then duration cumulates duration during the existence of the actor.  It performs the same function as duration(life_status, ALIVE).eg.     duration ( dfle, MILD_DIS)  records the length of time an individual has ever been in the mild disability state.  Consider a person who has survived to age 75, his disability status entered the mild state at age 20, exited the mild state at 25, returned to it at aged 60, and stayed in this state until the time of his death.  The value of duration is 0 until he turned 20, 1 when he is 21, 2 when he is 22, and so on until his 25th birthday.  At that point duration would keep the same value, 5,  until age 60 where it would be incremented by 1 until the year of his death.

• duration_trigger(state, value, elapsed_time )This function is a logical state informing if the duration of a specific state at a specific value reached a specified time period.e.g. logical worked6months = duration_trigger(employed, TRUE, 0.5 ) states the value of the derived state worked6months is TRUE if the individual has been working for at least 6 months, FALSE in any other case.  It also implicitly creates an event with the waiting time being the specified time.  In the above example, the waiting time would be 0.5.

Page 30: Seminar on POHEM –  Tables

30

• duration_counter(state, value, size of time interval);• or• duration_counter(state, value, size of time interval, maximum value);• This function is like duration_trigger(), except that it counts the number of intervals of specified size that have

elapsed since a particular state reached a particular value.• e.g.  int curtate_age = duration_counter(alive, TRUE, 1)  • will count the number of years elapsed since the person is alive, i.e. the person’s integerized age.  Implicit events

will also be created at each birthday.• Due to the creation of implicit events, using duration_counter() can be expensive, since it may continue to be

updated (perhaps monthly) long after its usefulness is at an end (e.g. after retirement, or beyond the largest value needed by a time function).  For that reason, it is possible to use an optional fourth argument: the maximum count it’s allowed to reach.  Once it reaches that maximum, Modgen will cease updating the value.

• e.g. int curtate_age_below_50 = duration_counter(alive, TRUE, 1, 50)• will count the number of years elapsed since the person is alive as long as that number is lower than or equal to

50.  At any point during a person’s life, curtate_age_below_50 would be either the age (integer) of the person, or 50.

• weighted_cumulation(state1,state2)“state1” is the state whose cumulation is observed. Whenever the value of “state1” changes the difference is mutiplied by the value of “state2” and added to the derived state. The new state is useful for creating a constant dollar version of some state cumulated in current dollars.

• weighted_duration ( variable, state,  weighting variable )• or• weighted_duration (weighting variable)

This function uses the values of the weighting variable, which is always a rate variable (i.e. earnings rates, wage rates,  etc.) to the sum of this variable over the duration of time the variable has, so far, been in the state.  This function, essentially, converts a rate variable into a accumulating variable.  If the variable and state are missing from the specification, then the value of the function is the sum of the weighting variable to the current point in the actor’s lifetime.eg.     weighted_duration ( dfle, MILD_DIS, earnings_rate)  records the total earnings of an actor while it has, so far, been in the mild disability state.   Consider a person who survived to age 75, and his disability status entered the mild state at age 60, left it at aged 65, and his annual earnings are $10,000.  The value of weighted_duration is, at age 60, is 10000*1, at aged 61 is 10000*2, and so on to age 65 where the value of this function is 10000*5 = 50000. This value is maintained for the duration of the actor’s lifetime.

•