How does one set the arguments to make it intercept only in survival package or otherwise and what does intercept only really mean with regards to a cox proportion hazards model.
2 Answers
The standard way in R regression formulas to make what I would call a "null model" rather than an "intercept-only" model is to use ~1
as the only term. (Turns out that you can also use ~0
as the only term.) In survival models the "intercept" is the baseline hazard (the estimate against which all the covariate estimates are referenced to), which in the the survival
package can be found for models containing covariates using the basehaz
function. So an "intercept only" Cox model, if I understand your intent, would just be the unadjusted Kaplan-Meier estimate.
test1 <- list(time=c(4,3,1,1,2,2,3), # example code ?coxph
status=c(1,1,1,0,1,1,0),
x=c(0,2,1,1,1,0,0),
sex=c(0,0,0,0,1,1,1))
# Fit a stratified model
nullfit <- coxph(Surv(time, status) ~ 0, test1) # Null model
survfit( nullfit)
# ----
Call: survfit(formula = nullfit)
n events median 0.95LCL 0.95UCL
[1,] 7 5 3 2 NA
# ----
png(); plot( survfit( nullfit) ); dev.off()

- 258,963
- 21
- 364
- 487
Without any other context, an "intercept only" model, is just the mean. Basically, if you are doing a regression of y over x, the intercept only model is a flat line at the mean value of y (at all values at x).

- 85
- 4
-
I don't think your answer addresses the differences between survival regression models and ordinary regression. In the context of survival regression models the "flat line" you are alluding to would be the relative hazard which is what Cox models estimate. The "y-value" would be the survival times (or the survival estimate) neither of which would be "flat". – IRTFM Jul 09 '22 at 18:19