5.18. Step 18: Table Output

5.18.1. Model Description

At this step we add various modules for table output by topic. We also add a tracking module which specifies which states to include in a database of individual life-courses which can by visualized by the BioBrowser tool.

The set of tables can easily be extended. Users can also disable individual tables within the graphical User-Interface in order to speed up simulation runs.

The table modules are self-contained. The only exception are some time-dependent output dimensions which can vary by country context. They are declared in the _CountryContext.mpp module.

5.18.2. The TablesPopulation.mpp Module

This module contains core demographic projection tables of the model.



////////////////////////////////////////////////////////////////////////////////////////////////////
// Types and States used in tables only
////////////////////////////////////////////////////////////////////////////////////////////////////

actor Person
{
    //EN Year
    SIM_YEAR_RANGE sim_year = COERCE(SIM_YEAR_RANGE, calendar_year);

    //EN Education Level
    EDUC_ONE_LEVEL tab_primary_level = (educ_one_grade_passed == 0) ? EOL_LOW :
        (educ_one_grade_passed == MAX(EDUC_ONE_GRADE0)) ? EOL_HIGH : EOL_MEDIUM;
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// Tables
////////////////////////////////////////////////////////////////////////////////////////////////////


table_group TG01_PopulationTables           //EN Population
{
    TabTotalPopulationSexDistrict,
    TabTotalPopulationSexRegion,
    TabPopulationAgeSexDistrict,
    TabCensusPopulations,
    TabCensusPopulationsEthnic
};

table Person TabTotalPopulationSexDistrict  //EN Total population by sex and district
[in_projected_time && is_resident]
{
    sex + *
    {
        duration()   //EN Average Population
    }
    * district_nat +
    * sim_year
};

table Person TabTotalPopulationSexRegion  //EN Total population by sex and region
[in_projected_time && is_resident]
{
    sex + *
    {
        duration()   //EN Average Population
    }
    * region_nat +
    * sim_year
};

table Person TabPopulationAgeSexDistrict  //EN Age Pyramids by District
[in_sel_years && is_resident]
{
    sel_years *                         //EN Calendar Year
    sex + *                             //EN Sex
    {
        duration()                      //EN Average Population
    }
    * split(integer_age, AGE5_PART)     //EN Age group
    * district_nat +                    //EN District
};

table Person TabCensusPopulations       //EN Census by age group, education, sex and district
[trigger_entrances(in_census_year, TRUE) && is_resident]
{
    census_year *
    sex + *
    district_nat + *
    {
        unit                            //EN Persons
    }
    * split(integer_age, AGE5_PART) +   //EN Age group
    * tab_primary_level +               //EN Primary School Level
};


table Person TabCensusPopulationsEthnic  //EN Census by age group, sex and ethnicity
[trigger_entrances(in_census_year, TRUE) && is_resident]
{
    census_year  *
    sex + *
    {
        unit                            //EN Persons
    }
    * split(integer_age, AGE5_PART) +   //EN Age group
    * ethnicity +                       //EN Primary Level
};








5.18.3. The TablesFertility.mpp Module

This module contains a set of tables related to births and fertility.



////////////////////////////////////////////////////////////////////////////////////////////////////
// Types and States used in tables only
////////////////////////////////////////////////////////////////////////////////////////////////////

partition   AGE_15_17_19{ 15,17,19 };                         //EN Age groups

actor Person
{
    FERTILE_AGE_RANGE tab_fert_age = COERCE(FERTILE_AGE_RANGE, integer_age);    //EN Age

    //EN Mother never entered school
    logical tab_moth_noeduc = (educ_mother == EOL_LOW) ? TRUE : FALSE;
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// Tables
////////////////////////////////////////////////////////////////////////////////////////////////////

table_group TG03_FertilityTables                                                        //EN Fertility
{
    TabFertilityRatesBirths,
    RTAB_NepBirthsByEducMother,
    TabAverageAgeAtBirth,
    RTAB_NepBirthsByAgeMother,
    TabBirthsByMothersNeverSchool
};

table Person TabFertilityRatesBirths    //EN Fertility rates and births by age
[in_projected_time && WITHIN(FERTILE_AGE_RANGE, integer_age) && sex == FEMALE
 && is_resident]
{
   {
        parity / duration(),    //EN Fertility rates decimals=4
        parity                  //EN Births
    }
    * tab_fert_age
    * sim_year
};

table Person RTAB_NepBirthsByEducMother         //EN Births by mothers ducation
[in_projected_time && person_type == PT_CHILD && is_resident]
{
    district_nat + *

    {
        entrances(is_alive, TRUE)                                       //EN Births
    }
    * sim_year
    * educ_mother +
};

table Person TabAverageAgeAtBirth                   //EN Average age at birth by education
[in_projected_time && sex == FEMALE && is_resident]
{
    {
        value_at_transitions(parity,0,1,age) / transitions(parity,0,1), //EN Average age at first birth decimals=2
        value_at_changes(parity,age) / changes(parity)                  //EN Average age at birth decimals=2
    }
    * sim_year                                                           //EN Calendar Year
    * tab_primary_level +
};

table Person RTAB_NepBirthsByAgeMother             //EN Births by district and age of mother
[in_projected_time && is_resident && sex==FEMALE]
{
    district_nat + *
    {
        parity                                      //EN Births
    }
    * sim_year                                  //EN Calendar Year
    * split(integer_age,AGE_15_17_19) +         //EN Age group
};


table Person TabBirthsByMothersNeverSchool         //EN Proportion of births by mothers who never entered school
[in_projected_time && person_type == PT_CHILD && is_resident]
{
    {
        value_at_entrances(is_alive, TRUE, tab_moth_noeduc) / entrances(is_alive, TRUE)         //EN Births by mothers never in school decimals=4
    }
    * sim_year
    * district_nat +
};

5.18.4. The TablesMortality.mpp Module

This module contains a set of output tables related to mortality.



////////////////////////////////////////////////////////////////////////////////////////////////////
// Types and States used in tables only
////////////////////////////////////////////////////////////////////////////////////////////////////

//EN Age Group
partition TAB_AGEC5{ 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95 };

range     TAB_CMORT_RANGE{ 0,4 };                                           //EN Age

actor Person
{
    TAB_CMORT_RANGE tab_cmortage = COERCE(TAB_CMORT_RANGE, integer_age);    //EN Age
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// Tables
////////////////////////////////////////////////////////////////////////////////////////////////////

table_group TG02_Mortality                                  //EN Mortality
{
    TabNumberDeaths,
    TabDeathsByAge,
    TabChildDeathsByAge,
    TabSurvivalToAge5
};

table Person TabNumberDeaths                                //EN Deaths
[in_projected_time && is_resident]
{
    sex + *
    {
        transitions(is_alive, TRUE, FALSE)                  //EN Deaths
    }
    * sim_year
    * district_nat +
};

table Person TabDeathsByAge                                 //EN Mortality by age
[in_projected_time && is_resident]
{
    sex+ *
    {
        transitions(is_alive, TRUE, FALSE),                 //EN Deaths
        transitions(is_alive, TRUE, FALSE) / duration()     //EN Mortality Rate decimals=4
    }
    * split(integer_age, TAB_AGEC5)                         //EN Age group
    * sim_year                                              //EN Calendar Year
};

table Person TabChildDeathsByAge                            //EN Child Mortality
[in_projected_time && is_resident && WITHIN(TAB_CMORT_RANGE,integer_age)]
{
    district_nat + *
    {
        transitions(is_alive, TRUE, FALSE),                 //EN Deaths
        transitions(is_alive, TRUE, FALSE) / duration()     //EN Mortality Rate decimals=4
    }
    * tab_cmortage                                          //EN Age
    * sim_year                                              //EN Calendar Year
};

table Person TabSurvivalToAge5                              //EN Child survival to 5th birthday by district of birth
[in_projected_time && district_birth != DISTI_ABROAD && year_of_birth >= MIN(SIM_YEAR_RANGE)]
{
    {
        transitions(integer_age, 4, 5) / unit               //EN Survival decimals=4
    }
    * tab_sim_yob                                           //EN Year of birth
    * aggregate(district_birth,DISTRICT_NAT) +              //EN District of birth
};




5.18.5. The TablesMigration.mpp Module

This module contains a set of output tables related to migration.



////////////////////////////////////////////////////////////////////////////////////////////////////
// Table Groups
////////////////////////////////////////////////////////////////////////////////////////////////////

table_group TG04_MigrationTables                    //EN Migration
{
    TG04a_ImmigrationTables,
    TG04b_EmigrationTables,
    TG04c_InternalMigrationTables
};

table_group TG04a_ImmigrationTables                 //EN Immigration
{
    TabNumberImmigrants,
    TabImmigrationSexProvinceAge

};

table_group TG04b_EmigrationTables                  //EN Emigration
{
    TabNumberEmigrants,
    TabEmigrationRatesNumberAge
};

table_group TG04c_InternalMigrationTables           //EN Internal Migration
{
    TabInternalMigrationRate
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// Immigration
////////////////////////////////////////////////////////////////////////////////////////////////////

table Person TabNumberImmigrants                    //EN Immigrants
[in_projected_time]
{
    sex+ *
    {
        entrances(is_resident, TRUE)                //EN Immigrants
    }
    * sim_year
    * district_immi+
};

table Person TabImmigrationSexProvinceAge           //EN Immigration by sex, district and age group
[in_sel_years]
{
    sel_years *
    sex + *
    {
        unit                                        //EN Immigrants
    }
    * split(integer_age, AGE5_PART) +               //EN Age group
    * district_nat +
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// Emigration
////////////////////////////////////////////////////////////////////////////////////////////////////

table Person TabEmigrationRatesNumberAge //EN Emigration rates and numbers by age group
[in_projected_time]
{
    sex + *
    district_nat + *
    {
        transitions(has_emigrated, FALSE, TRUE) / duration(),   //EN Emigration rates decimals=4
        transitions(has_emigrated, FALSE, TRUE)                 //EN Emigrants
    }
    * split(integer_age, AGE5_PART) +                           //EN Age group
    * sim_year
};

table Person TabNumberEmigrants                                 //EN Emigrants
[in_projected_time]
{
    sex+ *
    {
        entrances(has_emigrated, TRUE)                          //EN Number Emigrants
    }
    * sim_year
    * district_nat+
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal Migration
////////////////////////////////////////////////////////////////////////////////////////////////////

table Person TabInternalMigrationRate                       //EN Internal out migration rate
[ in_projected_time  && is_resident ]
{
    sex + *
    {
        number_migrations / duration()                      //EN Migration rate decimals=4
    }
    * split(integer_age, AGE5_PART)                         //EN Age group
    * district_nat +
};

5.18.6. The TablesPrimaryEducation.mpp Module

This module contains a set of tables related to primary school attainment, grade progression and school planning.



////////////////////////////////////////////////////////////////////////////////////////////////////
// States only used in tables
////////////////////////////////////////////////////////////////////////////////////////////////////

actor Person
{
    SIM_YEAR_RANGE tab_sim_yob = COERCE(SIM_YEAR_RANGE,year_of_birth);      //EN Year of birth
    logical is_child = (integer_age < 15);                                  //EN Child < 15
    logical is_old = (integer_age >= 60);                                   //EN Person 60+

    //EN Person 15-59 never enterd primary
    logical is_aded0 = (!is_child && !is_old && educ_one_fate == EOL_LOW);

    //EN Person 15-59 uncompleted primary
    logical is_aded1 = (!is_child && !is_old && educ_one_fate == EOL_MEDIUM);

    //EN Person 15-59 primary graduate
    logical is_aded2 = (!is_child && !is_old && educ_one_fate == EOL_HIGH);

    logical has_passed_primary = (educ_one_grade_passed == MAX(EDUC_ONE_GRADE));

    //EN Not attending primary school
    logical tab_out_of_primary = (educ_one_status != EOS_WAIT && educ_one_status != EOS_ATTEND
        && !has_passed_primary);
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// Tables
////////////////////////////////////////////////////////////////////////////////////////////////////

table_group TG05_PrimaryEducation       //EN Primary Education
{
    PopPyramidByEduc,
    TabEducFateDistrYob,
    TabEducFateByGroup,
    TabEduc15ByDistrict,
    TabEduc15ByDistrictBirth,
    TabPrimarySchoolPlanning,
    TabPrimSchoolEntries,
    TabPopProvAgeEducSex,
    TabPrimSchoolEntries,
    TabPrimSchoolGraduations,
    TabPrimSchoolOutOfSchool9to11
};

table Person PopPyramidByEduc           //EN Population pyramids by education and district
[in_sel_years && is_resident]
{
    sel_years *
    sex + *
    district_nat + *
    split(integer_age, AGE5_PART) *             //EN Age group
    {
        duration(tab_primary_level,EOL_LOW),    //EN Never entered primary school
        duration(tab_primary_level,EOL_MEDIUM), //EN Primary school non-completer
        duration(tab_primary_level,EOL_HIGH)    //EN Primary school graduate
    }
};

table Person TabEducFateByGroup                 //EN Primary education fate by parents education
[in_projected_time && trigger_changes(calendar_year) && integer_age == 0 && person_type == PT_CHILD]
{
    educ1_group + *
    {
        unit
    }
    * tab_sim_yob
    * educ_one_fate +
};

table Person TabPrimarySchoolPlanning   //EN Students by grade, required teachers and classrooms
[in_projected_time && trigger_changes(calendar_year) && is_educ_one_student && is_resident]
{
    district_nat + *
    {
        unit,                                   //EN Students
        value_out(educ_one_required_teachers),  //EN Number of teachers required
        value_out(educ_one_required_rooms)      //EN Number of classrooms
    }
    * sim_year
    * educ_one_grade +
};

table Person TabPopProvAgeEducSex       //EN Population by district, age group, sex and education
[in_projected_time && is_resident]
{
    district_nat + *
    sex + *
    {
        duration(is_child,TRUE),    //EN Children < 15
        duration(is_aded0, TRUE),   //EN Persons 15-59 never entered primary school
        duration(is_aded1, TRUE),   //EN Persons 15-59 primary school non-completer
        duration(is_aded2, TRUE),   //EN Persons 15-59 primary school graduate
        duration(is_old,TRUE)       //EN Persons 60+
    }
    * sim_year                      //EN Calendar Year
};

table Person TabEducFateDistrYob    //EN Primary education fate by district of birth
[trigger_changes(calendar_year) && integer_age == 0 && is_resident]
{
    district_birth + *
    {
        unit
    }
    * year_of_birth
    * educ_one_fate +
};

table Person TabEduc15ByDistrict      //EN Education composition of 15 year old by district of residence
[integer_age == 15 && in_projected_time && is_resident]
{
    district_nat + *
    sex + *
    {
        duration(educ_one_fate,EOL_LOW)    / duration(),    //EN Never entered primary school decimals=4
        duration(educ_one_fate,EOL_MEDIUM) / duration(),    //EN Primary school non-completer decimals=4
        duration(educ_one_fate,EOL_HIGH)   / duration()     //EN Primary school graduate decimals=4
    }
    * sim_year
};

table Person TabEduc15ByDistrictBirth      //EN Education composition of 15 year old by district of birth
[integer_age == 15 && in_projected_time && is_resident]
{
    district_birth + *
    sex + *
    {
        duration(educ_one_fate,EOL_LOW)    / duration(),    //EN Never entered primary school decimals=4
        duration(educ_one_fate,EOL_MEDIUM) / duration(),    //EN Primary school non-completer decimals=4
        duration(educ_one_fate,EOL_HIGH)   / duration()     //EN Primary school graduate decimals=4
    }
    * sim_year
};

table Person TabPrimSchoolEntries                           //EN Primary school new entries by District
[in_projected_time && is_resident]
{
    {
        entrances(educ_one_grade_attended,1)    //EN School entries
    }
    * sim_year
    * district_nat +
};

table Person TabPrimSchoolGraduations                       //EN Primary school graduations by District
[in_projected_time && is_resident]
{
    {
        entrances(has_passed_primary,TRUE)                  //EN School Graduates
    }
    * sim_year
    * district_nat +
};

table Person TabPrimSchoolOutOfSchool9to11                  //EN Out of school children age 9-11
[in_projected_time && is_resident && integer_age >= 9 && integer_age <= 11]
{
    {
        duration(tab_out_of_primary,TRUE)/duration()        //EN Out of school decimals=4
    }
    * sim_year
    * district_nat +
};

5.18.7. The TablesSecondaryEducation.mpp Module

This module adds a set of tables related to secondary education.



////////////////////////////////////////////////////////////////////////////////////////////////////
// Tables
////////////////////////////////////////////////////////////////////////////////////////////////////

table_group TG08_Secondary    //EN Secondary education
{
    School2TrackTab
};

table Person School2TrackTab //EN Secondary School Enrolment
[trigger_changes(calendar_year) && in_projected_time && is_resident && educ_two_status == ETS_ATTEND]
{
    {
        unit          //EN Students
    }
    * sim_year
    * educ_two_grade_attended +
};

5.18.8. The TablesUnion.mpp Module

This module contains a set of output tables related to first marriage.



////////////////////////////////////////////////////////////////////////////////////////////////////
// Tables
////////////////////////////////////////////////////////////////////////////////////////////////////

table_group TG_05_UnionTables                               //EN First union formation
{
    TabUnionFormation,
    TabAgeAtFirstUnionFormation,
    TabUnionFormationByAge
};

table Person TabUnionFormation      //EN First union formation by education and age
[WITHIN(AGE_UNION, integer_age) && sex == FEMALE && in_projected_time && is_resident ]
{
    {
        //EN Proportion of women who ever entered a union decimals=4
        duration(in_union,TRUE) / duration()
    }
    * educ_one_fate +
    * age_union
    * sim_year
};

table Person TabAgeAtFirstUnionFormation //EN Age at first union formation
[sex == FEMALE && in_projected_time && is_resident]
{
    {
        //EN Average age at first union formation decimals=2
        value_at_transitions(in_union, FALSE, TRUE,age) / transitions(in_union, FALSE, TRUE)
    }
    * educ_one_fate +
    * sim_year
};

table Person TabUnionFormationByAge       //EN  First union formations by age group (females)
[in_projected_time && is_resident && sex == FEMALE]
{
    {
        transitions(in_union, FALSE, TRUE) //EN Number Marriages
    }
    * sim_year                                              //EN Calendar Year
    * split(integer_age,AGE_15_17_19) +                    //EN Age group
};

5.18.9. The Tracking.mpp Module

This module contains a list of states to be tracked over the life-course for visual output using the BioBrowser tool. Tracking is primarily used for testing and validation purposes. The module is optional and can be removed



////////////////////////////////////////////////////////////////////////////////////////////////////
// Actor state track_me for creating a sample of persons to be tracked
////////////////////////////////////////////////////////////////////////////////////////////////////

actor Person
{
    logical track_me = (RandUniform(33)<0.01) ? TRUE : FALSE;
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// Tracking list
////////////////////////////////////////////////////////////////////////////////////////////////////

track Person
[track_me]
{
    integer_age,
    educ_one_fate,
    educ_one_grade_attended,
    educ_one_grade_passed,
    educ_one_status,
    educ_one_grade_fate,
    educ_two_grade_attended,
    educ_two_grade_passed,
    educ_two_status
};

5.18.10. New dimensions in _CountryContext.mpp



////////////////////////////////////////////////////////////////////////////////////////////////////
// Table Output Time Points
////////////////////////////////////////////////////////////////////////////////////////////////////

classification  TAB_SEL_YEARS           //EN Selected Years
{
    TSY_2000,                           //EN 2001
    TSY_2010,                           //EN 2011
    TSY_2020,                           //EN 2021
    TSY_2030,                           //EN 2031
    TSY_2040,                           //EN 2041
    TSY_2050,                           //EN 2051
    TSY_2060                            //EN 2061
};

classification TAB_CENSUS_YEAR          //EN Census Year
{
    TCY_2000,                           //EN Census 2001
    TCY_2010                            //EN Census 2011
};

actor Person
{
    //EN In Census Year
    logical in_census_year = calendar_year == 2000 || calendar_year == 2010;

    //EN Census Year
    TAB_CENSUS_YEAR census_year = (calendar_year == 2010) ? TCY_2010 : TCY_2000;

    //EN In selected year
    logical in_sel_years = calendar_year == 2000 || calendar_year == 2010
        || calendar_year == 2020 || calendar_year == 2030 || calendar_year == 2040
        || calendar_year == 2050 || calendar_year == 2060;

    //EN Year
    TAB_SEL_YEARS sel_years = (calendar_year == 2001) ? TSY_2000 :
        (calendar_year == 2011) ? TSY_2010 :
        (calendar_year == 2021) ? TSY_2020 :
        (calendar_year == 2031) ? TSY_2030 :
        (calendar_year == 2041) ? TSY_2040 :
        (calendar_year == 2051) ? TSY_2050 : TSY_2060;
};