# Interpreting coefficients of ordinal independent variables in logistic regression in R

I have conducted a logistic regression in R

> Model <- glm(A ~ B + C, family = "binomial", data = Data)
> summary(Model)

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)          -1.6138   678.6939  -0.002   0.9981
BPu                   1.0003     0.5539   1.806   0.0709 .
C.L                  21.2450  2146.2181   0.010   0.9921
C.Q                   1.2210  1813.8853   0.001   0.9995
C.C                   9.8965  1073.1091   0.009   0.9926
C^4                  -0.3275   405.5973  -0.001   0.9994

exp(coef(Model))

(Intercept)           BPu               C.L                 C.Q
1.991295e-01       2.719031e+00       1.684921e+09       3.390646e+00
C.C             C^4
1.986151e+04       7.207529e-01



As I understand it when the independent variable, B, (a binary variable) changes to Pu this is associated with an increase in the log odds of a "success" in the dependent by 1.0003, or that odds of increasing the dependent variable are multiplied by 3.22 relative to the intercept, and this change is near significant.

Can I say a similar statement for the variable CR, a 5 level ordinal variable? I've found online that L, Q, C, ^4 represent linear quadratic, cubic ... but I haven't found an answer outlining what I can practically say about these coefficients or how to interpret them.

I understand that the influence is likely to be insignificant, but which P value do I use? What can I say about the other coefficients?

I think a lot of your answers can be found in the answer to a similar question. The one caveat is that the linear, quadratic, cubic, and quartic terms do not directly correspond to numeric effects as though you used the factor levels as a raw number. You can see this by typing contr.poly(5) in $$R$$ to see how the various levels are coded (beyond the intercept = constant = all 1's).

• Thanks for this answer. Would you mind expanding on what contr.poly(5) tells me. Additionally, suppose C.L (in the example above) had a significant p value here, what statement can be made about that ordinal variable? By statement, I mean something similar to the first paragraph after my example. Jul 25, 2020 at 16:09
• contr.poly(n) tells you the encoding for a factor with n levels (omitting the encoding for the base = constant which is just all ones. The weights create orthogonal polynomials; however, that also lets you figure out the effect of a given factor level: take the product of encoding values for that factor and coefficient estimates. If C.L has a significant $p$-value, that is evidence that there is a significant linear relationship with respect to your ordinal factor. (For the above: increases in the factor lead to significant increases in the log-odds for the dependent variable.) Jul 26, 2020 at 23:58

I understand that the influence is likely to be insignificant, but which P value do I use? What can I say about the other coefficients?

The model turns the single categorical/ordinal variable effectively into 4 variables and reports coefficients and error estimates for each independently.

If you want a single p-value then what you can do is compare two models with and without the addition of the $$C$$ parameter and use that p-value for the significance. This comparison can be made with a chi-square test.

Below is an example

### generate data with approximately equal z-values for the ordered class polynomial categories
set.seed(1)
n = 100
class = c(rep(c(1,2,3,4,5),n))
class_val = poly(c(1,2,3,4,5),4)[,] %*% 1/c(1.996,3.688,5.525,3.747)
class_val
#             [,1]
# [1,] -0.59036857
# [2,]  0.08605809
# [3,]  0.71579404
# [4,] -5.64019429
# [5,]  5.42871073
y = rbinom(length(class), 1, p = (1+ exp(-1-1*class_val[class,1]) )^-1 )

### use two models on e with and one without the class
mod0 = glm(y ~1, family = binomial)
mod1 = glm(y ~ ordered(class), family = binomial)

### summary of results
summary(mod1)
anova(mod0,mod1,test="Chisq")


The table with t-tests is not significant

> summary(mod1)

Call:
glm(formula = y ~ ordered(class), family = binomial)

Deviance Residuals:
Min        1Q    Median        3Q       Max
-1.94788  -0.20101   0.00013   0.57012   2.79715

Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)         3.744    130.453   0.029    0.977
ordered(class).L    9.599    412.528   0.023    0.981
ordered(class).Q    9.881    348.650   0.028    0.977
ordered(class).C    9.248    206.265   0.045    0.964
ordered(class)^4    4.563     77.962   0.059    0.953

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 632.75  on 499  degrees of freedom
Residual deviance: 319.38  on 495  degrees of freedom
AIC: 329.38

Number of Fisher Scoring iterations: 17


But a chi-squared test is significant

> anova(mod0,mod1,test="Chisq")
Analysis of Deviance Table

Model 1: y ~ 1
Model 2: y ~ ordered(class)
Resid. Df Resid. Dev Df Deviance  Pr(>Chi)
1       499     632.75
2       495     319.38  4   313.38 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


The reason for the difference is because I constructed this example on purpose to have all the linear, quadratic, cubic and quadratic coefficients to be more or less equal and with an equal moderate effect. But the anova function compares all of them together.

(with this example I am not saying whether your case is gonna do the same, but it is to stress that this type of test is different from individual t-tests)