0

I am working with a collaborator who uses SAS, while I am more familiar with R. My collaborator has created a GLIMMIX Procedure Type III test of fixed effects with custom hypothesis tests (using a CONTRAST Statement). I have found a way to recreate the type III test of fixed effects using:

car::Anova(model, type = 3, test = "F"

My question is, is there a way to replicate the CONTRAST Statement? Specifically, if my model is:

glm(Response ~ Group, data = dataset, family = "binomial")

and I get the type III F test of fixed effect of the Group variable as above, is there a way to test between the levels of the Group variable?

The contrast statement output in SAS gives an arbitrary label, Num DF, Den DF, F value and Pr > F. I'm looking for this type of output in R to contrast each experimental Group to a control Group.

ZDinges
  • 53
  • 5

1 Answers1

0

Thanks to Ben Bolker's suggestion, I've found code that works!

model <- glm(Response ~ Group, data = dataset, family = binomial)

emm.object <- emmeans(model, ~ Group)
joint_tests(emm.object) #Produces similar to type III test, but check
contrastlist <- list ("Control vs. Group 1" = c(1, -1, 0, 0), "Control vs. Group 2" = c(1, 0, -1, 0), "Control vs. Group 3" = c(1, 0, 0, -1))
tcontrast <- data.frame(contrast(emm.object, contrastlist))

F-values <- tcontrast$t.ratio^2

Notes: sometime contrasts give you a z.ratio instead of a t.ratio. Not sure if this is different for our purposes or not. The F-value is just the t.ratio squared, from this: https://stats.stackexchange.com/questions/55236/prove-f-test-is-equal-to-t-test-squared

I found an example of emmeans contrast that mentioned just square the t.ratio for the F value, but I cannot find the right webpage anymore.

ZDinges
  • 53
  • 5