1
votes

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

1

1 Answers

1
votes

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.