Choice Modeling - Diagnostic - Experimental Design - Numeric Design

From Q
Jump to navigation Jump to 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.

Example

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

References

See Choice Modeling - Experimental Design

Code

includeWeb("QScript R Output Functions");

main();

function main() {

    // The following 2 variables contain information specific to this diagnostic.
    var required_class = "ChoiceModelDesign";
    var output_name_suffix = "numeric.design";
    
    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 + "$labeled.design, as.numeric)";

    return createROutput(item, expression, output_name_suffix);
}