This assumes that age
is continuous (i.e. calculated as days instead of years). Note that for a coxph()
model, the predicted quantities include type=c("lp", "risk", "expected", "terms", "survival")
. The last is survival probability at a give time. None of them gives (median) survival time, which must be acquired from survfit(coxph(), newdata = , times =)
.
If the data only record integer age, discrete survival analysis will be more appropriate. See discussions at Discrete-Time Event History (Survival) Model in R and book Tutz, G., & Schmid, M. (2016). Modeling discrete time-to-event data. Springer Nature. https://doi.org/10.1007/978-3-319-28158-2. It essentially entails glm(mort ~ s(age) + black + rich + black:rich + ...), family = binomial("cloglog"))
where s()
is a smoothing curve and the data must be restructured so that each patient has several rows, each for a year until the death year where age
increases by 1 for each year. For your data, probably age
is the only predictor that varies by row within the same patient.
Note that both glht()
and marginaleffects::comparisons()
conduct Wald tests, whichan extension of the single-coefficient z test based on large-sample asymptotic. For generalized linear models, maximum-likelihood estimates are consistent but biased, so the test is meaningful only if the sample size is large enough. While the former function tests only coefficients, the latter can also test difference in predicted probabilities.
Wald tests require a well-behaving likelihood function (sufficiently approximating to a quadratic curve at its maximum). Basically it means the coefficient and its standard error should not be very large. For the Wald test caveats, see Likelihood ratio vs. score vs. Wald test: Different p values, which to use?. To conduct likelihood-ratio on linear combinations of coefficients, which many test routines do not provide directly, see Likelihood-ratio and score tests of a (non)linear combination of coefficients.