Learn R Programming

lsmeans (version 1.00-00)

pairwise.lsmc: Contrast families

Description

These functions return standard sets of contrast 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, each column containing contrast coefficients for levs. The "desc" attribute is used to label the results in lsmeans, and the "adjust" attribute gives the default adjustment method for multiplicity.

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 (or the average over specified levels) with each of the other levels. The argument ref should be the index(es) (not the labels) of the reference level(s). trt.vs.ctrl1.lsmc is the same as trt.vs.ctrl , ref=1), and trt.vs.ctrlk.lsmc is the same 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