Skip to main content

I have fitted a cox model on a pooled dataset of multiple studies, say studystudies 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 studystudies 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 B, and/or C when I only want to output the linear predictor (type="lp")? As the linear predictor is independent fromof 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.

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.

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.

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 studies 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 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.

Add code formatting and reformulate title
Source Link
llrs
  • 4.7k
  • 1
  • 19
  • 42

R predict function from stratified cox model; why can't I just output Output the linear predictor from a 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)

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")

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

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"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
I could not find any question like this so maybe I am thinking the wrong way. Help is very much appreciated!

Nienke

R predict function from stratified cox model; why can't I just output the linear predictor?

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

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.

edited title
Source Link

R predict function from stratified cox modelmodel; why can't I just output the linear predictor?

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

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

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

R predict function from stratified cox model; why can't I just output the linear predictor?

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

Source Link
Loading