# How does SAS compute standard error

I need help with estimated standard errors in SAS. I'm doing logistic regression of and I obtained the score, standard error, pd and lower and upper limit of confidence interval. I also computed these estimates manually for a few observations and I was able to replicate the results for pd and the confidence intervals.

I used following formulas for pd and intervals:

pd=1/(1+exp(-(xbeta)));

up_test=1/(1+exp(-(xbeta+probit(1-0.05/2)*std)));

lo_test=1/(1+exp(-(xbeta-probit(1-0.05/2)*std)));


But when I manually computed the standard error I obtained different results than the ones produced automatically from model.

My question is, what is the formula for standard error used in logistic regression in SAS?

I tried using results from maximum likelihood:

$$\sqrt{(se(intercept)^2 + se(score)^2*(score-averagescore)^2}$$

, where $$se$$ is the standard error but it doesn't work.

I hope I described my problem clearly, because i'm not an expert on this. :)

• You missed the covariance. Commented Jul 19, 2019 at 13:17
• I am voting to leave this open. It's framed in the context of SAS, but any software will do this. Commented Jul 20, 2019 at 10:30

Following up @Björn and @PeterFlom's answer: you've forgotten (or maybe didn't know) to account for the covariance between the intercept and score-effect estimates. If you want to calculate the standard error of the linear predictor $$\beta_0 + \beta_1 x$$ (intercept + slope*predictor value), it will be $$\sqrt{\sigma^2_0 + x^2 \sigma^2_1 + 2 x \sigma_{01}}$$

This is the equivalent of @Björn's answer with $$a=1$$, $$b=x$$, $$X=\beta_0$$, $$Y=\beta_1$$, or @PeterFlom's answer with $$\hat V_b = \left( \begin{array}{cc} \sigma^2_0 & \sigma_{01} \\ \sigma_{01} & \sigma^2_1 \end{array} \right)$$.

• This is the solution that is was looking for. But can you explain me what is σ01 in that covarience matrix? I dont know hot to get it. σo and σ1 are clear for me. Commented Jul 23, 2019 at 10:13
• σ01 is the covariance between the estimates of β0 and β1. It looks like you might use the COVB option to the MODEL statement in PROC GENMOD to get the covariance matrix of the parameters ... ?? Commented Jul 23, 2019 at 13:43
• Now it works! I found also option COVOUT in PROC LOGISTIC, which also display covariance matrix. Thank you for Your help Commented Jul 23, 2019 at 14:29

SAS computes the SE of $$\eta_i$$ as "the square root of the quadratic form $$(1,x')\hat{V}_b(1,x')$$ where $$\hat{V}_b$$ is the estimated covariance matrix of the parameter estimates."

Although you framed this as a question about SAS (which would be off topic) I believe that this is not specific to SAS.

It is not really clear what you want SEs for. For an individual model parameter, software will typically use the observed (or asymptotic) Fisher information, which you usually get almost automatically when numerically maximizing the log-likelihood. If we are talking about combinations of parameters such as a SE for a*(parameter 1) + b*(parameter2), then it depends a little on how they are combined. In case of such a simple sum, you can get the SE via the usual formula for how variances add up: $$\text{Var}(aX+bY) = a^2 \text{Var}(X) + b^2 \text{Var}(Y) + 2ab\text{Cov}(X,Y)$$ (of course with the square root taken). For more complex functions than summation, it may be harder and I would guess that most software packages would use the delta method.