Choice Modeling - Ensemble

From Q
Jump to: navigation, search

Create an ensemble of Choice Models by averaging the respondent parameters. The output may either be a table comparing the underlying models and the ensemble, or histograms of respondent parameters of the ensemble. In either case, functions to save variables (e.g. Individual-level Coefficients) may be applied to the ensemble.

Example

Comparison table

Histograms of ensemble parameters

Options

Input models At least 2 Choice Models.

Ensemble Whether to create an ensemble by taking the average of the respondent parameters across the models.

Output

Comparison A table comparing metrics from models (and the ensemble, if selected).
Ensemble Histograms of respondent parameters, as per the underlying Choice Model outputs.

Code

var controls = [];
var modelsInput = form.dropBox({label: "Input models", types:["RItem:FitChoice"], name: "formModels",
                               multi: true, required: true, min_inputs: 2,
                               prompt: "Select at least 2 Choice Models."});
controls.push(modelsInput);

var ensemble = form.checkBox({label: "Ensemble", name: "formEnsemble", default_value: true,
                              prompt: "Whether to create an ensemble of the models."});
controls.push(ensemble);

if (ensemble.getValue()) {
    var output = form.comboBox({label: "Output", 
              alternatives: ["Comparison", "Ensemble"], name: "formOutput", default_value: "Comparison",
              prompt: "A table comparing the models, or histograms of ensemble respondent coefficients."});
    controls.push(output);
}
form.setInputControls(controls);

if (ensemble.getValue())
    form.setHeading('Ensemble of Choice Models');
else
    form.setHeading('Compare Choice Models');
library(flipChoice)
ensemble <- ChoiceEnsemble(formModels,
                           !formEnsemble,
                           get0("formOutput", ifnotfound = "Comparison"))