Choice Modeling - Compare Models

From Q
Jump to navigation Jump to search

Compare the performance of multiple Choice Models by producing a table of metrics from each model

How to Create

  1. Add the object by selecting from the menu Anything > Advanced Analysis > Choice Modeling > Compare ModelsAutomate > Browse Online Library > Choice Modeling > Compare Models
  2. In Inputs > Input models select at least 2 choice models

Example


Output Example:


Input Example:
Two or more choice models, similar to below:


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.

Additional Properties

When using this feature you can obtain additional information that is stored by the R code which produces the output.

  1. To do so, select Create > R Output.
  2. In the R CODE, paste: item = YourReferenceName
  3. Replace YourReferenceName with the reference name of your item. Find this in the Report tree or by selecting the item and then going to Properties > General > Name from the object inspector on the right.
  4. Below the first line of code, you can paste in snippets from below or type in str(item) to see a list of available information.

For a more in depth discussion on extracting information from objects in R, checkout our blog post here.

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: false,
                              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);

var heading_text = 'Compare Choice Models';
var plural_text = 'Comparisons of Choice Models';
if (ensemble.getValue()) {
  heading_text = 'Ensemble of Choice Models';
  plural_text = 'Ensembles of Choice Models';
}
if (!!form.setObjectInspectorTitle)
    form.setObjectInspectorTitle(heading_text, plural_text);
else 
    form.setHeading(heading_text);
library(flipChoice)
comparison <- ChoiceEnsemble(formModels,
                             !formEnsemble,
                             get0("formOutput", ifnotfound = "Comparison"))