How to include the interaction between a covariate and time for a non-proportional hazards model?












0















How to include the interaction between a covariate and and time for a non-proportional hazards model?



I often find that the proportional hazards assumption for the Cox regressions doesn’t hold.



Take the following data as an example.



> head(data2)
no np_p age_dx1 race1 mr_dx er_1 pr_1 sct_1 surv_mo km_stts1
1 20 1 2 4 1 2 2 4 52 1
2 33 1 3 1 2 1 2 1 11 1
3 67 1 2 4 4 1 1 3 20 1
4 90 1 3 1 3 3 3 2 11 1
5 143 1 2 4 3 1 1 2 123 0
6 180 1 3 1 3 1 1 2 9 1


First, I fitted a Cox regression model.



> fit2 <- coxph(Surv(surv_mo, km_stts1) ~ np_p + age_dx1 + race1 + mr_dx + er_1 + pr_1 + sct_1, data = data)


Second, I assessed the proportional hazards assumption.



> check_PH2 <- cox.zph(fit2, transform = "km")
> check_PH2
rho chisq p
np_p 0.00946 0.0748 7.84e-01
age_dx1 -0.00889 0.0640 8.00e-01
race1 -0.03148 0.7827 3.76e-01
mr_dx -0.03120 0.7607 3.83e-01
er_1 -0.14741 18.5972 1.61e-05
pr_1 0.05906 2.9330 8.68e-02
sct_1 0.17651 23.8030 1.07e-06
GLOBAL NA 53.2844 3.26e-09


So, this means that the hazard function of er_1 and sct_1 were nonproportional over time (Right?).



In my opinion, I can include the interaction between these two covariates and time seperately in the model. But I don't know how to perform it using R.



Thank you.










share|improve this question























  • In R, an interaction is denoted using a * symbol. Is this what you're after?

    – Roman Luštrik
    Dec 31 '18 at 10:49











  • @RomanLuštrik Thank you for your answer. In other words, I want to know how to deal with the non-proportionality in the Cox regression model when the assumption is not met. I've read many papers including interactions between time and the covariate in this situation.

    – Lin Caijin
    Dec 31 '18 at 12:08


















0















How to include the interaction between a covariate and and time for a non-proportional hazards model?



I often find that the proportional hazards assumption for the Cox regressions doesn’t hold.



Take the following data as an example.



> head(data2)
no np_p age_dx1 race1 mr_dx er_1 pr_1 sct_1 surv_mo km_stts1
1 20 1 2 4 1 2 2 4 52 1
2 33 1 3 1 2 1 2 1 11 1
3 67 1 2 4 4 1 1 3 20 1
4 90 1 3 1 3 3 3 2 11 1
5 143 1 2 4 3 1 1 2 123 0
6 180 1 3 1 3 1 1 2 9 1


First, I fitted a Cox regression model.



> fit2 <- coxph(Surv(surv_mo, km_stts1) ~ np_p + age_dx1 + race1 + mr_dx + er_1 + pr_1 + sct_1, data = data)


Second, I assessed the proportional hazards assumption.



> check_PH2 <- cox.zph(fit2, transform = "km")
> check_PH2
rho chisq p
np_p 0.00946 0.0748 7.84e-01
age_dx1 -0.00889 0.0640 8.00e-01
race1 -0.03148 0.7827 3.76e-01
mr_dx -0.03120 0.7607 3.83e-01
er_1 -0.14741 18.5972 1.61e-05
pr_1 0.05906 2.9330 8.68e-02
sct_1 0.17651 23.8030 1.07e-06
GLOBAL NA 53.2844 3.26e-09


So, this means that the hazard function of er_1 and sct_1 were nonproportional over time (Right?).



In my opinion, I can include the interaction between these two covariates and time seperately in the model. But I don't know how to perform it using R.



Thank you.










share|improve this question























  • In R, an interaction is denoted using a * symbol. Is this what you're after?

    – Roman Luštrik
    Dec 31 '18 at 10:49











  • @RomanLuštrik Thank you for your answer. In other words, I want to know how to deal with the non-proportionality in the Cox regression model when the assumption is not met. I've read many papers including interactions between time and the covariate in this situation.

    – Lin Caijin
    Dec 31 '18 at 12:08
















0












0








0








How to include the interaction between a covariate and and time for a non-proportional hazards model?



I often find that the proportional hazards assumption for the Cox regressions doesn’t hold.



Take the following data as an example.



> head(data2)
no np_p age_dx1 race1 mr_dx er_1 pr_1 sct_1 surv_mo km_stts1
1 20 1 2 4 1 2 2 4 52 1
2 33 1 3 1 2 1 2 1 11 1
3 67 1 2 4 4 1 1 3 20 1
4 90 1 3 1 3 3 3 2 11 1
5 143 1 2 4 3 1 1 2 123 0
6 180 1 3 1 3 1 1 2 9 1


First, I fitted a Cox regression model.



> fit2 <- coxph(Surv(surv_mo, km_stts1) ~ np_p + age_dx1 + race1 + mr_dx + er_1 + pr_1 + sct_1, data = data)


Second, I assessed the proportional hazards assumption.



> check_PH2 <- cox.zph(fit2, transform = "km")
> check_PH2
rho chisq p
np_p 0.00946 0.0748 7.84e-01
age_dx1 -0.00889 0.0640 8.00e-01
race1 -0.03148 0.7827 3.76e-01
mr_dx -0.03120 0.7607 3.83e-01
er_1 -0.14741 18.5972 1.61e-05
pr_1 0.05906 2.9330 8.68e-02
sct_1 0.17651 23.8030 1.07e-06
GLOBAL NA 53.2844 3.26e-09


So, this means that the hazard function of er_1 and sct_1 were nonproportional over time (Right?).



In my opinion, I can include the interaction between these two covariates and time seperately in the model. But I don't know how to perform it using R.



Thank you.










share|improve this question














How to include the interaction between a covariate and and time for a non-proportional hazards model?



I often find that the proportional hazards assumption for the Cox regressions doesn’t hold.



Take the following data as an example.



> head(data2)
no np_p age_dx1 race1 mr_dx er_1 pr_1 sct_1 surv_mo km_stts1
1 20 1 2 4 1 2 2 4 52 1
2 33 1 3 1 2 1 2 1 11 1
3 67 1 2 4 4 1 1 3 20 1
4 90 1 3 1 3 3 3 2 11 1
5 143 1 2 4 3 1 1 2 123 0
6 180 1 3 1 3 1 1 2 9 1


First, I fitted a Cox regression model.



> fit2 <- coxph(Surv(surv_mo, km_stts1) ~ np_p + age_dx1 + race1 + mr_dx + er_1 + pr_1 + sct_1, data = data)


Second, I assessed the proportional hazards assumption.



> check_PH2 <- cox.zph(fit2, transform = "km")
> check_PH2
rho chisq p
np_p 0.00946 0.0748 7.84e-01
age_dx1 -0.00889 0.0640 8.00e-01
race1 -0.03148 0.7827 3.76e-01
mr_dx -0.03120 0.7607 3.83e-01
er_1 -0.14741 18.5972 1.61e-05
pr_1 0.05906 2.9330 8.68e-02
sct_1 0.17651 23.8030 1.07e-06
GLOBAL NA 53.2844 3.26e-09


So, this means that the hazard function of er_1 and sct_1 were nonproportional over time (Right?).



In my opinion, I can include the interaction between these two covariates and time seperately in the model. But I don't know how to perform it using R.



Thank you.







r cox-regression






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 31 '18 at 9:25









Lin CaijinLin Caijin

12




12













  • In R, an interaction is denoted using a * symbol. Is this what you're after?

    – Roman Luštrik
    Dec 31 '18 at 10:49











  • @RomanLuštrik Thank you for your answer. In other words, I want to know how to deal with the non-proportionality in the Cox regression model when the assumption is not met. I've read many papers including interactions between time and the covariate in this situation.

    – Lin Caijin
    Dec 31 '18 at 12:08





















  • In R, an interaction is denoted using a * symbol. Is this what you're after?

    – Roman Luštrik
    Dec 31 '18 at 10:49











  • @RomanLuštrik Thank you for your answer. In other words, I want to know how to deal with the non-proportionality in the Cox regression model when the assumption is not met. I've read many papers including interactions between time and the covariate in this situation.

    – Lin Caijin
    Dec 31 '18 at 12:08



















In R, an interaction is denoted using a * symbol. Is this what you're after?

– Roman Luštrik
Dec 31 '18 at 10:49





In R, an interaction is denoted using a * symbol. Is this what you're after?

– Roman Luštrik
Dec 31 '18 at 10:49













@RomanLuštrik Thank you for your answer. In other words, I want to know how to deal with the non-proportionality in the Cox regression model when the assumption is not met. I've read many papers including interactions between time and the covariate in this situation.

– Lin Caijin
Dec 31 '18 at 12:08







@RomanLuštrik Thank you for your answer. In other words, I want to know how to deal with the non-proportionality in the Cox regression model when the assumption is not met. I've read many papers including interactions between time and the covariate in this situation.

– Lin Caijin
Dec 31 '18 at 12:08














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53985737%2fhow-to-include-the-interaction-between-a-covariate-and-time-for-a-non-proportion%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53985737%2fhow-to-include-the-interaction-between-a-covariate-and-time-for-a-non-proportion%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas