Hi, John,

it should work the same way as without interaction (but make sure
to use the fitted object "coxfit", not just "fit" in our call of
survfit, and note that age*rx already expands to age + rx + age:rx
so that age + rx is redundant in your formula):

coxfit <- coxph(Surv(futime, fustat) ~ age+rx+age*rx, data = ovarian)
plot(survfit(coxfit, newdata=data.frame(age=60,rx=2)))

Or do I missunderstand your question?

 Hth  --  Gerrit

---------------------------------------------------------------------
Dr. Gerrit Eichner                   Mathematical Institute, Room 212
gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104          Arndtstr. 2, 35392 Giessen, Germany
http://www.uni-giessen.de/eichner
---------------------------------------------------------------------

Am 20.05.2021 um 21:15 schrieb Bert Gunter:
Perhaps this might be useful:

https://rpubs.com/tf_peterson/interactionplotDemo

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, May 20, 2021 at 10:29 AM Sorkin, John <jsor...@som.umaryland.edu>
wrote:

Colleagues,

I hope someone can tell me how to plot a cox model that contains an
interaction term.

I know that plot(survfit(. . . . )) can be used to plot a Cox model, i.e..
coxfit <- coxph(Surv(futime, fustat) ~ age+rx, data = ovarian)
plot(survfit(fit, newdata=data.frame(age=60,rx=2)))

but I don't know how to plot a cox model with an interaction, i.e.

coxfit <- coxph(Surv(futime, fustat) ~ age+rx+age*rx, data = ovarian)
plot(survfit(fit, newdata=data.frame(???????)))

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to