5.11. Step 11: Ethnicity¶
5.11.1. Model Description¶
At this step we add a state ethnicity to the model. The implementation of ethnicity is generic, the number and interpretation of the distinguished population groups depending on a specific country context. Ethnicity is inheritable. For immigrants it depends on sex and district of landing.
5.11.2. The new Ethnicity.mpp Module¶
This module implements the ethnicity variable. For persons cretated from the starting population, ethnicity is read from file. For new-borns, ethnicity is inherited (using a transition probability matrix parameter) from the mother. For immigrants, ethnicity is sampled from a distributional parameter. Accordingly, the ethnicity module has two parameters:
- A transition matrix by sex for the transmission of ethnic group from mother to child
- A distributional parameter by sex and district of landing for sampling the ethnicity of immigrants
The initialisation of ethnicity has to be added to the Start() function; the following two functions are available from this module:
- GetInheritedEthnicity(MothersEthnicity) samples and returns the ethnicity for a given mother’s ethnicity
- GetImmigrantsEthnicity() samples and returns the an immigrant’s ethnicity.
The implementation of ethnicity is generic – it can e.g. correspond to religion, caste, visible minority – and the classification of the population into groups will depend on the specific country context. Therefore the classification ETHNICITY is declared in the _CountryContext.mpp module.
////////////////////////////////////////////////////////////////////////////////////////////////////
// Parameters
////////////////////////////////////////////////////////////////////////////////////////////////////
parameters
{
//EN Transmission of ethnic group from mother to child
cumrate EthnicTransmission[SEX][ETHNICITY][ETHNICITY];
//EN Ethnicity of immigrants
cumrate EthnicityImmigrants[SEX][DISTRICT_NAT][ETHNICITY];
};
parameter_group PG_Ethnicity //EN Ethnicity
{
EthnicTransmission,
EthnicityImmigrants
};
////////////////////////////////////////////////////////////////////////////////////////////////////
// Actor States and Functions
////////////////////////////////////////////////////////////////////////////////////////////////////
actor Person
{
ETHNICITY ethnicity = { ETHNO_00 }; //EN Ethnicity
ETHNICITY GetInheritedEthnicity(ETHNICITY eMothersEthnicity); //EN Inherit ethnicity at birth
ETHNICITY GetImmigrantsEthnicity(); //EN Sample immigrants ethnicity
};
////////////////////////////////////////////////////////////////////////////////////////////////////
// Implementation
////////////////////////////////////////////////////////////////////////////////////////////////////
ETHNICITY Person::GetInheritedEthnicity(ETHNICITY eMothersEthnicity)
{
int nSex = (int)sex;
int nEthnicity;
int nMothersEthnicity = (int)eMothersEthnicity;
Lookup_EthnicTransmission(RandUniform(24), nSex, eMothersEthnicity, &nEthnicity);
return (ETHNICITY)nEthnicity;
}
ETHNICITY Person::GetImmigrantsEthnicity()
{
int nSex = (int)sex;
int nDistrict = (int)district_immi;
int nEthnicity;
Lookup_EthnicityImmigrants(RandUniform(27), nSex, nDistrict, &nEthnicity);
return (ETHNICITY)nEthnicity;
}
table Person TabTestEthno
{
person_type+ *
district_int+*
{
duration()
}
* calendar_year
* ethnicity+
};
5.11.3. Defining Ethnic Groups in _CountryContext.mpp¶
classification ETHNICITY //EN Ethnic Group
{
ETHNO_00, //EN Ethnic Group A
ETHNO_01 //EN Ethnic Group B
};
5.11.4. Initializations in the Start() Function¶
The state ethnicity is added to the list of variables initiated in the Start() Function.
// Initialize states
if (person_type == PT_START) // Person comes from starting population
{
// (A) States from Starting population file
time = peObservation->pmc[PMC_BIRTH];
sex = (SEX)(int)peObservation->pmc[PMC_SEX];
family_role = peObservation->fam_role;
district_int = (DISTRICT_INT)(int)peObservation->pmc[PMC_DISTRICT];
district_birth = (DISTRICT_INT)(int)peObservation->pmc[PMC_DOB];
educ_one_startpop = (EDUC_ONE_LEVEL)(int)peObservation->pmc[PMC_EDUC];
ethnicity = (ETHNICITY)(int)peObservation->pmc[PMC_ETHNO];
// (B) Other states
time_of_birth = time;
calendar_year = (int)time_of_birth;
ever_resident = is_resident;
// (C) Links to head resp. spouse
// (uncomment when modeling families) if (pePers) peHHead = pePers;
}
else if (person_type == PT_CHILD) // Person born in simulation
{
// (A) States corresponding to Starting population file variables
if (RandUniform(4) < 100.0 / (100.0 + SexRatio[RANGE_POS(SIM_YEAR_RANGE, calendar_year)]))
{
sex = FEMALE;
}
else sex = MALE;
time = pePers->time;
family_role = FR_CHILD;
district_int = pePers->district_int;
district_birth = district_int;
ethnicity = GetInheritedEthnicity(pePers->ethnicity);
// (B) Other states
time_of_birth = time;
calendar_year = (int)time_of_birth;
ever_resident = is_resident;
educ_mother = pePers->educ_one_fate;
// (C) Links to head resp. spouse
// (uncomment when modeling families) if (pePers) peHHead = pePers;
}
else // Person is an immigrant
{
// (A) States corresponding to Starting population file variables
int nSex, nYear, nAge, nDistrict;
Lookup_NumberImmigrantsTable(RandUniform(7), &nYear, &nSex);
Lookup_AgeImmigrants(RandUniform(8), nSex, &nAge);
Lookup_DestinationImmigrants(RandUniform(9), nSex, SPLIT(nAge, AGE5_PART), &nDistrict);
sex = (SEX)nSex;
time_of_immigration = MIN(SIM_YEAR_RANGE) + nYear + RandUniform(12);
family_role = FR_HEAD;
district_int = DISTI_ABROAD;
district_immi = (DISTRICT_NAT)nDistrict;
time = time_of_immigration - (nAge + RandUniform(11));
district_birth = DISTI_ABROAD;
ethnicity = GetImmigrantsEthnicity();
// (B) Other states
time_of_birth = time;
calendar_year = (int)time;
ever_resident = FALSE;
}