# Understand robust se vs naive se from marginal means survival model [duplicate]

I ran a marginal means survival model that included some time-invariant and time-varying covariates (see this post for relevant information). I am trying to understand why the robust standard errors of time-varying covariates (for most cases) were smaller than the normal standard errors. See the output below:

Call:
coxph(formula = Surv(start, stop, status) ~ timeinvar1 + timeinvar2 + timeinvar3 +
timeinvar4 + timeinvar5 + timevar1 + timevar2 + timevar3 + timevar4 + timevar5 +
timevar6 + timevar7 + timevar8 + timevar9 + timevar10 + timevar11 + timevar12, data = df, method = "breslow", cluster = id)

n= 6238, number of events= 4900

coef   exp(coef)   se(coef)  robust se      z Pr(>|z|)
timeinvar1    -0.0297847  0.9706545  0.0265703  0.0298450 -0.998   0.3183
timeinvar2    -0.0006781  0.9993221  0.0007405  0.0013068 -0.519   0.6038
timeinvar3     0.0822066  1.0856801  0.0325223  0.0558329  1.472   0.1409
timeinvar4    -0.0492858  0.9519090  0.0204549  0.0245615 -2.007   0.0448 *
timeinvar5    -0.1403031  0.8690948  0.0232954  0.0309357 -4.535   5.75e-06 ***
timevar1       0.1089786  1.1151385  0.1063589  0.0449649  2.424   0.0154 *
timevar2       0.0140678  1.0141672  0.0909205  0.0618708  0.227   0.8201
timevar3      -0.0596030  0.9421385  0.2009912  0.1137355 -0.524   0.6002
timevar4       0.0641278  1.0662287  0.3879597  0.2440149  0.263   0.7927
timevar5       0.1421777  1.1527815  0.1671703  0.1022506  1.390   0.1644
timevar6      -0.2292206  0.7951531  0.3221017  0.1822969 -1.257   0.2086
timevar7       0.1625964  1.1765617  0.1458495  0.0740169  2.197   0.0280 *
timevar8       0.0522071  1.0535939  0.0854054  0.1032372  0.506   0.6131
timevar9       0.4351499  1.5451946  0.0652591  0.0781522  5.568   2.58e-08 ***
timevar10      0.2900672  1.3365173  0.2339454  0.0901727  3.217   0.0013 **
timevar11     -0.1223035  0.8848797  0.3276422  0.1131383 -1.081   0.2797
timevar12     -0.3083615  0.7346497  0.3078949  0.1392103 -2.215   0.0268 *


This is a marginal means model (see this article for more information). timeinvar1 to timeinvar5 are time-invariant covariates and timevar1 to timevar12 are time-varying covariates. Note that most of the robust standard errors of time-varying covariates (except timevar8 and timevar9) were smaller than the normal standard errors but most of the robust standard errors of time-invariant covariates (except timeinvar2) were larger than the normal standard errors. I understand that in general robust standard errors are supposed to be larger due to cluster effect but why the it is reversed for time-varying covariates in the survival context.

• This can happen even in ordinary least squares with robust standard errors. See this page for an introduction.
– EdM
Nov 4, 2022 at 18:25
• To be more precise, very little can be said in particular with over 20 variables involved, not knowing whether the hazards are in fact proportional, or whether the working correlation matrix is in fact correct. In general, you might begin investigation under the assumption that the exchangeable working correlation specified by cluster(id) will reduce the influence of repeated measures within a cluster, i.e. multiple observations of the same subject with varying time covariates. Nov 4, 2022 at 18:26
• Thanks @AdamO. Can you provide more guidance on how I go about testing the part the assumption that the exchangeable working correlation specified by cluster(id) will reduce the influence of repeated measures within a cluster? Is this something along the line of examining serial correlation?
– cliu
Nov 4, 2022 at 18:36
• @EdM I understand the general idea in the OLS setting but just don't know what parts do time-invariant and time-varying covariates play in this.
– cliu
Nov 4, 2022 at 18:43
• There is indeed a way that this can occur preferentially with time-varying covariates. I provided an answer to try to explain.
– EdM
Nov 5, 2022 at 14:16

Although you can get smaller robust than "naive" coefficient standard errors even in ordinary least squares, the way that the robust standard errors are calculated for Cox models might tend to make that more likely when there are time-varying covariates.

The robust standard errors are based on the "dfbeta" residuals from the model. That's a matrix with one row for each observation and one column for each coefficient. Each entry represents the estimate of how much the value of that coefficient would change if that observation were omitted. If $$D$$ is the matrix of dfbeta values, then the robust variance is the matrix product $$D'D$$. Therneau and Grambsch show in Chapter 7 how that robust estimate is related to jackknife and "sandwich" robust estimates.

If there is only one observation per individual, you thus can calculate robust standard errors from the square roots of the diagonal elements of $$D'D$$. Each is the square root of the sum of the squares of the individual dfbeta residuals for a coefficient. Figure 7.5 of Therneau and Grambsch illustrates that the robust variance estimates are unbiased, but they have more variance than the usual estimates based on the Fisher information matrix. Thus sometimes the robust standard errors are higher and sometimes they are lower than the standard estimates, as you can see by browsing the examples in that book.

When there are multiple observations (rows) per individual, the dfbeta residuals are first added up within individuals, and those clustered dfbeta values define the matrix $$D$$. That's where a time-fixed and a time-varying covariate might be expected to differ.

Say that an individual has longer survival than might be expected from a value of a particular time-fixed covariate. Then removing any one of that individual's observations from analysis would tend to raise the estimate of that coefficient's value, for a positive dfbeta residual. The sum over multiple observations for the individual in the clustered dfbeta values would tend to be even more positive.

If the value of an individual's covariate can change over time, however, then there might be positive dfbeta residuals for some of that individual's observations and negative residuals for others. The sum over all observations for the individual thus could be close to zero. If that happens for many individuals, then the sum of the squares of the clustered dfbeta residuals for that coefficient could be small, leading to small robust standard errors.

• Thank you for the intuitive answer! So would you say in general robust standard errors are preferred over naive ones when both time-invariant and time-varying covariates are present?
– cliu
Nov 6, 2022 at 1:19
• @cliu if an individual can have at most one event and there is no other clustering (e.g. by treatment center) you should not use robust standard errors with time-varying covariates. Then the rows represent individual observations. Robust standard errors (or frailty/random-effect analysis) are needed when an individual can have more than one event. Then times-to-events within individuals can be correlated and need to be accounted for. See this page, and Chapter 8 of Therneau and Grambsch.
– EdM
Nov 6, 2022 at 6:27