Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Adam Olszewski <adam.olszewski@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: graphing interactions after -stpm2- |
Date | Tue, 27 Aug 2013 00:06:43 -0400 |
Hello, I was wondering if someone could advise me about how to graph an interaction effect between a categorical and continuous variable in a survival model. Specifically, I would like to fit a model with interaction and then plot the hazard ratio for the categorical variable on Y-axis against the continuous predictor on X-axis. I would like to do it fitting a flexible parametric model using the user-written -stpm2- command (available from SSC). I imagine the series of commands being something like: sysuse cancer.dta * binarize for simplicity recode drug 1=0 2/3=1 stpm2 drug##c.age, df(3) eform sca(h) * predict hr, (..... - this is what I cannot figure out line hr age I tried various permutations of hrnum/hrdenom option as well as margins, but I cannot get the right result. I would imagine that predict hr, hrn(drug 1 age .) hrd(drug 0 age .) should work, but it produces a flat line. I assume I am missing something simple. A solution for a Cox model might help too, since perhaps I could figure out the stpm2 equivalent. Best, Adam Olszewski * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/