Skip to main content
1 of 4

R predict function from stratified cox model

My question:

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. Help is very much appreciated!

Nienke