Learn R Programming

lsmeans (version 0.9)

pairwise.lsmc: Contrast families

Description

These functions return standard sets of contrasts coefficients. The name of any of these functions (with the .lsmc omitted) may be used in the left-hand side of a spec formula in lsmeans.

Usage

pairwise.lsmc(levs, ...)
revpairwise.lsmc(levs, ...)

poly.lsmc(levs, max.degree = min(6, k - 1))

trt.vs.ctrl.lsmc(levs, ref = 1)
trt.vs.ctrl1.lsmc(levs, ...)
trt.vs.ctrlk.lsmc(levs, ...)

Arguments

levs
Vector of factor levels
...
Additional arguments, ignored but needed to make these functions interchangeable
max.degree
The maximum degree of the polynomial contrasts in poly.lsmc
ref
Reference level (or control group) in trt.vs.ctrl.lsmc

Value

  • A data.frame or list, each column (or list entry) containing contrast coefficients for levs. The names attribute is used to label the results in lsmeans

Details

pairwise.lsmc and revpairwise.lsmc generate contrasts for all pairwise comparisons among least-squares means at the levels in levs. The distinction is in which direction they are subtracted. For factor levels A, B, C, D, pairwise.lsmc generates the comparisons A-B, A-C, A-D, B-C, B-D, and C-D, wereas revpairwise.lsmc generates B-A, C-A, C-B, D-A, D-B, and D-C. poly.lsmc generates orthogonal polynomial contrasts, assuming equally-spaced factor levels. These are derived from the poly function, but an ad hoc algorithm is used to scale them to integer coefficients that are (usually) the same as in published tables of orthogonal polynomial contrasts. trt.vs.ctrl.lsmc and its relatives generate contrasts for comparing one level with each of the other levels. The argument ref should be the index (not the label) of the reference level. trt.vs.ctrl1.lsmc is the same as trt.vs.ctrl , ref=1), and trt.vs.ctrlk.lsmc is the samme as trt.vs.ctrl , ref=length(levs))

See Also

lsmeans

Examples

Run this code
### View orthogonal polynomials for 4 levels
poly.lsmc(1:4)

### Setting up a custom contrast function
helmert.lsmc = function(levs, ...) {
  M = as.data.frame(contr.helmert(levs))
  names(M) = paste(levs[-1],"vs earlier")
  attr(M, "desc") = "Helmert contrasts"
  M
}
lsmeans(Oats.lme, helmert ~ Variety)

Run the code above in your browser using DataLab