Choice Modeling - Diagnostic - Experimental Design - Numeric Design

From Q
Jump to: navigation, search

Outputs a numeric version of an Choice Modeling - Experimental Design output, with the labels of attributes replaced by integers. You must first select the output to use this QScript.

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);
}