find_same_col: Find column with same non-positive values

View source: R/find_same_col.R

find_same_colR Documentation

Find column with same non-positive values

Description

The inverse matrix of a contrast matrix has a useful property where, after removing the row corresponding to the intercept, the reference level is the column index where each value in that column is (1) the same and (2) less than or equal to 0.

Usage

find_same_col(invmatrix)

Arguments

invmatrix

Inverse of the hypothesis matrix

Details

For a contrast matrix generated from an expression x, with number of levels n, consider the inverse matrices from solve(.contrasts_to_hypotheses(x)) below for different x:

  • contr.treatment: The first column contains all 0s, hence the reference level is the first level

  • contr.SAS: The last column contains all 0s, hence the reference level is the last level

  • scaled_sum_code: The first column contains all -1/n, hence the reference level is the first level

  • helmert_code: While the first column contains all negative numbers, they are not the same EXCEPT if n=2

Note that "reference level" here is defined as a level from which every other level is compared to via pairwise comparisons.

Value

Integer index of the reference level, if there is no reference level, NA is returned


contrastable documentation built on Oct. 1, 2024, 5:07 p.m.