I have fitted a cox model on a pooled dataset of multiple studies, say studies A, B, and C. As these studies have different baseline hazard functions, I stratified for 'study' in the model.
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 studies A, B, and C.
When I have
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 of 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.