Enum Class ContrastCoding

java.lang.Object
java.lang.Enum<ContrastCoding>
ubic.gemma.core.util.math.linearmodels.ContrastCoding
All Implemented Interfaces:
Serializable, Comparable<ContrastCoding>, Constable

public enum ContrastCoding extends Enum<ContrastCoding>
How a categorical factor's levels are turned into columns of a design matrix, which is what decides what each coefficient of that factor means.

Both codings give a factor with k levels k-1 columns, so the model has the same rank either way and nothing downstream of the fit changes shape. What changes is the question each coefficient answers.

Author:
paul
See Also:
  • Enum Constant Details

    • TREATMENT

      public static final ContrastCoding TREATMENT
      Each level gets an indicator column; one level has none and is the baseline. A coefficient is that level's difference from the baseline. R's contr.treatment, and Gemma's behaviour everywhere until this enum existed.

      This is the right coding when one level is a control that the others are meant to be read against — a wild-type, an untreated arm, a vehicle.

    • SUM_TO_ZERO

      public static final ContrastCoding SUM_TO_ZERO
      Each level gets a column, the one left over takes -1 in all of them, and a coefficient is that level's deviation from the mean of the level means. R's contr.sum; also called deviation or sum-to-zero coding.

      This is the coding for a factor with no control level — a panel of tissues, a set of cell lines, a collection of time points treated symmetrically. Under treatment coding one of those has to be nominated as the baseline, every other level is then reported relative to that arbitrary choice, and the nominated one gets no contrast of its own. Here every level is reported against the same reference and none of them is privileged.

      🛑 The reference is the mean of the LEVEL means, not the mean of the samples. They differ whenever the levels have different numbers of samples, and the level means are what the model estimates.

      The deviations sum to zero by construction, so the level without a column of its own is still fully determined: its deviation is minus the sum of the others.

  • Method Details

    • values

      public static ContrastCoding[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ContrastCoding valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null