2. Parameters

As JAS-mine supports a clear distinction between modelling classes and data structures, parameters are loaded and stored in a specific class, Parameters.java. The class makes use of the ExcelAssistant.loadCoefficientMap() method to read the parameters from MS Excel files: this requires to specify a .xls file, a sheet name, the number of key columns and the number of value columns (it is also possible to load the parameters from a table in the input database). Parameters are then stored in MultiKeyCoefficientMap objects, which are basically standard Java maps with multiple keys (Box 1).

public static void loadParameters() {

 // probabilities
 pBirth = ExcelAssistant.loadCoefficientMap("input/p_birth.xls", "Sheet1", 1, 59);
 pDeathM = ExcelAssistant.loadCoefficientMap("input/p_death_m.xls", "Sheet1", 1, 59);
 pDeathF = ExcelAssistant.loadCoefficientMap("input/p_death_f.xls", "Sheet1", 1, 59);
 pMarriage = ExcelAssistant.loadCoefficientMap("input/p_marriage.xls", "Sheet1", 3,4);
 pDivorce = ExcelAssistant.loadCoefficientMap("input/p_divorce.xls", "Sheet1", 2, 59);
 pInWork = ExcelAssistant.loadCoefficientMap("input/p_inwork.xls", "Sheet1", 3, 59);


 // regression coefficients
 coeffMarriageFit = ExcelAssistant.loadCoefficientMap("input/reg_marriage.xls", "Sheet1", 1, 1);
 coeffDivorce = ExcelAssistant.loadCoefficientMap("input/reg_divorce.xls", "Sheet1", 1, 1);
 coeffInWork = ExcelAssistant.loadCoefficientMap("input/reg_inwork.xls", "Sheet1", 3, 1);

 // definition of regression models
 regMarriageFit = new LinearRegression(coeffMarriageFit);
 regDivorce = new LogitRegression(coeffDivorce);
 regInWork = new LogitRegression(coeffInWork);

}

Box 1. The Parameters.loadParameters() method.

There are two types of parameters in demo07: probabilities and regression coefficients. 

2.1 Probabilities

Birth (pBirth) and death (pDeathM and pDeathF) probabilities have one key (age), while the value columns refer to different simulation years: birth and death probabilities are therefore age- and year-specific. 

Divorce probabilities (pDivorce) have two keys (the lower and upper bounds defining age groups), while value columns refer again to different simulation years: divorce probabilities are therefore age group- and year-specific. 

Marriage (pMarriage) and employment (pInWork) probabilities have three keys (the lower and upper bounds defining age groups and gender). Value columns in pMarriage refer to different civil states: marriage probabilities are therefore age group-, gender- and civil state-specific. Value columns in pInWork refer to different simulation years: employment probabilities are therefore age group-, gender- and year-specific. 

Table 3 shows how the p_birth.xls file looks like.

Table 3. Extract from the p_birth.xls file
Simulation year
age 2002 2060
15 0.00068 0.00075
16 0.00186 0.00181
50 0.00010 0.00021

2.2 Regression Coefficients

Regression coefficients can have one key (coeffMarriageFit and coeffDivorce) which is the regressor variable name, and a corresponding value with the estimated coefficient. They might have additional keys, as in coeffInWork, if the coefficients are differentiated by some other variables (gender and employment state, in this example). Table 4 shows what the corresponding reg_inwork.xls file looks like. Note that the name of the regressor variable must appear in the first column, as the regression classes expect it to be the first key in the MultiKeyCoefficientMap instance. The name of the headings for the additional key columns must match the name of a field in the relevant class, in this case, the Person class.

Table 4 Extract from the reg_inwork.xls file
regressors gender workState coefficients
age Male Employed -0.19660
isMarried Male Employed 0.18928
workIntercept Male Employed 3.55461
age Male NotEmployed 0.97809
workIntercept Male NotEmployed -12.39108
age Female Employed -0.27405
isMarried Female Employed -0.09068
workIntercept Female Employed 3.64871
age Female NotEmployed 0.82176
isMarried Female NotEmployed -0.55910
workIntercept Female NotEmployed -10.48043

The appropriate regression models are then defined based on the regression coefficients.