Significance Testing - Color Significant Cells

From Q
Jump to: navigation, search

This rule changes the color of the cells in the table when the results in the cells are found to be significant. This is equivalent to Q's standard Cell Comparisons, indicated by the arrows and font colors, except that the whole cell will be colored rather than just the fonts.

Example

ColorSignificantCells.PNG

Technical details

The results shown as significant will match the results shown by Q's standard Cell Comparisons testing, which is indicated by arrows and font colors. To remove the arrows or font colors (or both), make a selection from the Show significance menu above the table.

How to apply this rule

For the first time in a project

  • Select the table(s)/chart(s) that you wish to apply the rule to.
  • Start typing the name of the Rule into the Search features and data box in the top right of the Q window.
  • Click on the Rule when it appears in the QScripts and Rules section of the search results.

OR

  • Select Automate > Browse Online Library.
  • Choose this rule from the list.

Additional applications of the rule

  • Select a table or chart that has the rule and any table(s)/chart(s) that you wish to apply the rule to.
  • Click on the Rules tab (bottom-left of the table/chart).
  • Select the rule that you wish to apply.
  • Click on the Apply drop-down and choose your desired option.
  • Check New items to have it automatically applied to new items that you create. Use Edit > Project Options > Save as Template to create a new project template that automatically uses this rule.

Removing the rule

  • Select the table(s)/chart(s) that you wish to remove the rule from.
  • Press the Rules tab (bottom-right corner).
  • Press Apply next to the rule you wish to remove and choose the appropriate option.

How to modify the rule

  • Click on the Rules tab (bottom-left of the table/chart).
  • Select the rule that you wish to modify.
  • Click Edit Rule and make the desired changes. Alternatively, you can use the JavaScript below to make your own rule (see Customizing Rules).

JavaScript

includeWeb("Table JavaScript Utility Functions")
 
// Form for picking colors
form.setSummary("Color significant cells");
var high_color_picker = form.newColorPicker("hcolor");
high_color_picker.setDefault("YellowGreen");
high_color_picker.lineBreakAfter = true;
var high_label = form.newLabel("Higher results:");
var low_label = form.newLabel("Low results:");
var low_color_picker = form.newColorPicker("lcolor");
low_color_picker.setDefault("Orange");
form.setInputControls([high_label, high_color_picker, low_label, low_color_picker]);
var high_color = high_color_picker.getValue();
var low_color = low_color_picker.getValue();
 
// Color the cells
colorSignificantCells(table, high_color, low_color);
if (belowTableExists())
    colorSignificantCells(below_table, high_color, low_color);
if (rightTableExists())
   colorSignificantCells(right_table, high_color, low_color);
 
 
function colorSignificantCells(table_object, high_color, low_color) {
    if (table_object.availableStatistics.indexOf('z-Statistic') > -1) {
        // Existing colors in table
        var colors = table_object.cellColors;
        // To evaluate coloring
        var significant = table_object.cellSignificance;
        var zs = table_object.get('z-Statistic');
 
        // Work out which cells to color
        for (var row = 0; row < table_object.numberRows; row++) {
            for (var col = 0; col < table_object.numberColumns; col++) {
                if (significant[row][col]) {
                    if (zs[row][col] > 0)
                        colors[row][col] = high_color;
                    else
                        colors[row][col] = low_color;
                }             
            }
        }
        table_object.cellColors = colors;
    }
}

See also

Personal tools
Namespaces

Variants
Actions
Navigation
Categories
Toolbox