Choice Modeling - Diagnostic - Experimental Design - Numeric Design extension

From Q
Jump to: navigation, search

Create an output containing a numeric version of the design

Outputs a numeric version of a Choice Modeling - Experimental Designchoice model experimental design output, with the labels of attributes replaced by integers.


The table below shows the numeric version of a design with 2 attributes, Color and Speed, each of which has 3 levels.


See Choice Modeling - Experimental Design


includeWeb("QScript R Output Functions");

var is_displayr = (!!Q.isOnTheWeb && Q.isOnTheWeb());
if (!is_displayr)
    if (Q.fileFormatVersion() >= 17.13)
        alert("Please update Q to use this feature from the extension button, or run it from the menu via Automate > Browse Online Library > Choice Modeling > Diagnostic > Experimental Design > Numeric Design.");

function main() {

    // The following 2 variables contain information specific to this diagnostic.
    var required_class = "ChoiceModelDesign";
    var output_name_suffix = "";
    var item = checkSelectedItemClass(required_class);
    if (item == null)
        return false;
    var r_name = stringToRName(item.referenceName);

    // The following lines contain the R code to run
    var expression = "sapply(" + r_name + "$, as.numeric)";

    return createROutput(item, expression, output_name_suffix);