1

I am running a multilevel logistic regression, using the function glmer from package lme4 in R. My binomial outcome (or response-) variable is coded as c and g.

My question is: how can I know which level of the outcome variable is taken as the reference outcome?

It seems the default reference is the first alphabetically (so c in my case), is this true?

I am guessing this after using the levels and relevel functions:

levels(data$Outcome)  
# [1] "c" "g"

test <- relevel(data$Outcome, ref = "g")   
# levels(test)  
# [1] "g" "c"

This seems to say that c was the reference before, but this is rather circumstantial.

My homework:
I did not find the answer using ?glmer, or the online pdf manual of lme4, or these related posts:

For the case of a 0/1 coded response:
Using glmer for logistic regression, how to verify response reference

Got the tip of using the 'recode' function from:
Logistic regression - defining reference level in R

Community
  • 1
  • 1

1 Answers1

1

You need to change your reference level's order. This post demonstrates how do so. In your case write it this way:

data$Outcome <- factor(data$Outcome, levels = c("g", "c"))

Edit based upon OP's comment- To answer your question: Yes, factor levels are alphabetical by default. This R-Blogger's post discusses it more.

Community
  • 1
  • 1
Richard Erickson
  • 2,568
  • 8
  • 26
  • 39
  • Following your suggestion sucesfully reversed sign for all log-odds estimates (e.g. my intercept -1.19 became 1.19). I also realised that `g` is my rarest outcome, meaning that `c` was indeed coded as `0` (which I referred to as the default) and `g` as `1`. In other words: the outcome that is first alphabetically is indeed the 'default'; the answer to my question is 'YES'. – Nibood_the_slightly_advanced Mar 30 '16 at 10:06