This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Contrasts in R

Hi everyone,

In R, I want to do exactly what limma package does for "makeContrasts" (I do not have expression data).

I have two factor variables say X (levels=X1,X2) and Y (levels=Y1,Y2). I ran an lme model with an interaction term between X and Y and used the "emmeans" package to get contrasts. The emmeans though return e.g:

contrast      estimate   SE  df t.ratio p.value
 X1 - Y1    -0.141 1.58 180  -0.090  0.9997
 X1 - X2      1.949 1.03 175   1.894  0.2322
 Y1 - Y2    2.239 1.01 175   2.208  0.1228
 X2 - Y2     0.148 1.57 175      0.095  0.9997

What I need now, is the contrast of (Y1-Y2) - (X1-X2). Is this possible using emmeans or in base R? How do I create the contrasts table along with p-values etc?

Any help would be greatly appreciated.

Thanks in advance

contrasts r

have you looked into model.matrix?

0 answers

No answers yet.

Log in to answer this question.