Below are the configuration settings for creating a choice model of housing type. In order to create this model for estimation purposes, we will exclude the few households that are in non-residential property types, and only keep those in multi-family, condominium, and single-family housing. These are reflected by building type id values of 4, 12, and 19, respectively, in the seattle parcel data. Filtering the data to include only these three values can be done with the numpy logical_or command, but since it takes only two arguments, we need to create a nested comparison, as shown below. Since there are three housing types represented in this data, and we want to create a binary choice outcome for simplicity, it is necessary to create a dependent variable that is 2 if the household occupies a single family house, and 1 otherwise. In this example, since we will use the entire household table, we draw a small sample of 5% of the agents to use in estimating the model.
| [1.5pt] Configuration Entry | Node | Value |
| Model Name | housing_type_choice_model | |
| Choice Set | Init | [1, 2] |
| Choice Attribute | Init | single_family=(household.disaggregate |
| (building.building_type_id)==19)+1 | ||
| Estimation Size Agents | Init.Estimation Config | 0.05 |
| Agent Set | Run, Prepare for Run, Estimate, Prepare for Estimate | household |
| Agent Filter | Prepare for Run | numpy.logical_or(numpy.logical_or(household. |
| disaggregate(building.building_type_id)==4,household. | ||
| disaggregate(building.building_type_id)==12),household. | ||
| disaggregate(building.building_type_id)==19) | ||
| Specification Table | Prepare for Run | housing_type_choice_model_specifications |
| Coefficients Table | Prepare for Run, Prepare for Estimate | housing_type_choice_model_coefficients |
Figure 5.6 shows the housing type choice model configuration in progress. For a binary choice model such as this, the specification of the model is quite similar to the specification of the regression model, but there are some subtle differences. The most important one is that, as this model is implemented in OPUS now, it requires at least one variable in each equation - that is - per alternative. We typically assign the constant to alternative 1, and all other variables to alternative 2. In a future revision of the code, the base alternative will not take any variables (this is the more standard implementation). Figure 5.7 shows the initial specification of the housing type choice model, with a constant for the other housing types, and income and has_children included in the utility specification for the single family housing alternative.
Once the model is specified, it needs to be added to the list of models to estimate, and selected as the model to estimate, as was the case in the preceding regression model example. Once the model has been added and the project saved, the model can be estimated with the normal right-click option on the models to estimate node. The results are shown in Figure 5.8.