# Standard error for the difference of coefficients in logistic regression

Suppose I fit a logistic regression where my covariates are ordinal. Can I determine the standard error for the log odds ratio between consecutive categories?

I'm inclined to say yes. Since the coefficients of the model are the MLE, then they have asymptotic normal distribution. So, if I wanted the variance for the difference between $\beta_j$ and $\beta_i$, I would compute

$$\operatorname{Var}(\beta_j) + \operatorname{Var}(\beta_i) - 2\operatorname{Cov}(\beta_j, \beta_i)$$

Then just take the square root of the above quantity to obtain the standard error of $\beta_j - \beta_i$. Is that correct?

• Yes, that is correct. If $\hat\beta_j$ and $\hat\beta_i$ are estimated coefficients for levels of a factor, then the model would usually be setup such that the covariance between them is zero. – Gordon Smyth Mar 2 '18 at 1:25

Yes, that is correct. You can verify that this works with software:

. sysuse auto, clear
(1978 Automobile Data)

. xtile mpg_cat = mpg, nq(4)

. logit foreign i.mpg_cat, nolog
note: 2.mpg_cat != 0 predicts failure perfectly
2.mpg_cat dropped and 11 obs not used

Logistic regression                             Number of obs     =         63
LR chi2(2)        =       5.92
Prob > chi2       =     0.0519
Log likelihood = -37.799736                     Pseudo R2         =     0.0726

------------------------------------------------------------------------------
foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
mpg_cat |
2  |          0  (empty)
3  |   1.299283    .654819     1.98   0.047     .0158614    2.582705
4  |   1.481605   .7288133     2.03   0.042     .0531567    2.910052
|
_cons |  -1.481605   .4954337    -2.99   0.003    -2.452637   -.5105723
------------------------------------------------------------------------------

. matrix list e(V)

symmetric e(V)[5,5]
foreign:    foreign:    foreign:    foreign:    foreign:
1b.         2o.          3.          4.
mpg_cat     mpg_cat     mpg_cat     mpg_cat       _cons
foreign:1b.mpg_cat           0
foreign:2o.mpg_cat           0           0
foreign:3.mpg_cat           0           0   .42878788
foreign:4.mpg_cat           0           0   .24545455   .53116883
foreign:_cons           0           0  -.24545455  -.24545455   .24545455

. display "diff = " 1.481605 - 1.299283
diff = .182322

. display "SE(diff) = " sqrt(.7288133^2 + .654819^2 - 2*.24545455)
SE(diff) = .68487053

. lincom  4.mpg_cat - 3.mpg_cat

( 1)  - [foreign]3.mpg_cat + [foreign]4.mpg_cat = 0

------------------------------------------------------------------------------
foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) |   .1823216   .6848705     0.27   0.790        -1.16    1.524643
------------------------------------------------------------------------------


The coefficients and their standard errors are shown in the regular output, but the covariances are the off-diagonal terms in the e(V) matrix.