user.cont: User defined contrasts for EMMeans

View source: R/user.cont.R

user.contR Documentation

User defined contrasts for EMMeans

Description

Returns a function usable by emmeans for user defined contrasts.

Usage

user.cont(cont)

Arguments

cont

any matrix of contrasts (see 'Details').

Details

In these matrices, each line is a comparison (= contrast) and each colum is a level of the factor. Rules for writing contrasts are:

- levels not involved in the comparison must have a null value

- levels to be compared must have opposite signs

- levels can be grouped (for example 2 -1 -1 give a comparison of the first level against the group composed by the two others)

- the sum of all values of a contrast must be null.

Value

user.cont.emmc

the function to be called by emmeans

Author(s)

Maxime HERVE <maxime.herve@univ-rennes1.fr>

See Also

emmeans

Examples

require(car)
require(emmeans)

tab <- data.frame(
  response <- c(rpois(30,1),rpois(30,3),rpois(30,10)) ,
  fact <- gl(3,30,labels=LETTERS[1:3])
)
model <- glm(response~fact,family="poisson",data=tab)
Anova(model)
mat <- matrix(c(1,-1,0,0,1,-1,2,-1,-1),nrow=3,byrow=TRUE,dimnames=list(1:3,levels(fact)))
mat
cont.emmc <- user.cont(mat)
EMM <- emmeans(model,~fact)
contrast(EMM,"cont")

RVAideMemoire documentation built on Nov. 6, 2023, 5:07 p.m.