Interpreting GLM output with categorical data I am having trouble identifying which reference level R is using for my response variable matnew. I know it sometimes chooses alphabetically, which in this case is "Fail", but I'm not sure if actually it would use "Pass" since this variable comes first with A,B,C.. I tried to set the reflevel myself but the coefficient estimates did not change whether I chose "Pass" or "Fail" when I experimented with this. Is there a way to test the baseline level?
Another issue I am having is in interpreting the output. For instance, for school MS (reference level is GP) does this mean that going from school GP to MS is associated with an average change of -1.0569 in the log odds of a student passing (or failing, depending on the reference level) math? Thank you for any insight provided.
Code:
d3$matnew[d3$mat.grade=="A"|d3$mat.grade=="B"|d3$mat.grade=="C"] <- "Pass"
d3$matnew[d3$mat.grade=="D" |d3$mat.grade=="F"] <- "Fail"


library(geepack)
glm_fit_math <- glm(factor(matnew) ~ absences.x + Medu + school + 
schoolsup+famsup+goout, 
           data = d3,
           family = binomial)
summary(glm_fit_math)

Output:


You can use levels() function to see the levels of a factor, and the reference level is the first character returned by this function. For example,
x = factor(c("Fail", "Pass"))
levels(x)
# output is:
#[1] "Fail" "Pass"

So, "Fail" is the reference level.
Logistic model by glm() function fits a 0-1 response variable, and the response value of 1 means the probability of success. Changing the factor back into a 0-1 variable would be helpful, such as change the data of Fail to 0 and Pass to 1, which would model the probability of pass.
d3$matnew[d3$mat.grade=="A"|d3$mat.grade=="B"|d3$mat.grade=="C"] <- 1 # "Pass"
d3$matnew[d3$mat.grade=="D" |d3$mat.grade=="F"] <- 0 #"Fail"

Or if a factor is used, you can also check the model to see how the response variable is used in modelling. From the fitted model, check $y where y is the response variable used in the model, and $model which is the original data. Comparing the two things can give you an idea about which level is modelled as success.
set.seed(1214)
y = as.factor(rbernoulli(10))
y
# output is:
#[1] TRUE  TRUE  FALSE TRUE  TRUE 
#[6] TRUE  FALSE FALSE FALSE FALSE
#Levels: FALSE TRUE

x = rnorm(10)
model1 <- glm(y ~ x, family = binomial())

model1$y
# output is:
# 1  1  0  1  1  1  0  0  0  0 
model1$model
#     y           x
#1   TRUE -1.80433919
#2   TRUE  0.05786102
#3  FALSE -1.23232211
#4   TRUE -1.64980827
#5   TRUE  0.87854220
#6   TRUE -0.59077164
#7  FALSE  0.07888135
#8  FALSE -0.16824491
#9  FALSE  0.32182848
#10 FALSE -1.23651163


In the above example, TRUE is corresponding to 1, so the probability of having TRUE is modelled.
