Skip to main content
3 of 4
Add code formatting and reformulate title
llrs
  • 4.7k
  • 1
  • 19
  • 42

Output the linear predictor from a stratified cox model?

I have fitted a cox model on a pooled dataset of multiple studies, say study A, B and C. As these studies have different baseline hazard functions, I stratified for 'study' in the model.

Like this:

df$SurvObj <- with(df, Surv(event_rd, event == 1))

fit <- coxph(SurvObj ~ cov1 + cov2 + cov3 + cov4 + strata(study),data=df)

Now, I want to assess whether I can use the beta coefficients from the above model to predict the event probability in a new study, study D. The baseline hazard in study D is different from those in study A, B and C.

When I have

predict(fit,type="lp",newdata=studyD,reference="strata")

I get this error:

Error in model.frame.default(data = studyD, formula = ~hba1c + sbp + : factor strata(study) has new levels study=4

Why does R require that I match the strata of study D with those in study A,B and/or C when I only want to output the linear predictor (type="lp")? As the linear predictor is independent from the baseline hazard function in this case.

I suppose it should be possible to extract the linear predictor for individuals in study D and then manually calculate the event probability using the baseline hazard of study D.

Does anybody know how to do this?
I could not find any question like this so maybe I am thinking the wrong way.