Learn R Programming

RVAideMemoire (version 0.9-79)

user.cont: 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').

Value

user.cont.emmc

the function to be called by emmeans

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.

See Also

emmeans

Examples

Run this code
# NOT RUN {
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(levels(fact),1:3))
mat
cont.emmc <- user.cont(mat)
EMM <- emmeans(model,~fact)
contrast(EMM,"cont")
# }

Run the code above in your browser using DataLab