[R] coxph: how to define interaction terms?

David Winsemius dwinsemius at comcast.net
Tue Oct 29 17:56:25 CET 2013

On Oct 29, 2013, at 4:38 AM, rm wrote:

> Any ideas would be much appreciated; I suspect that this problem of
> constructing the dummies applies not only to function coxph but to other
> regression models in R as well. Effectively, my question is how to better
> control for which dummies and interactions to include in the model and which
> not.
> The following code shows a workaround. It works here reasonably well since x
> has only two levels, but if x has more levels, constructing the dummies
> manually for each level and keeping track of each of them becomes very
> difficult.
> A weird thing is that if onle replace line 4 with

You should go to the R-help Archive to see what the vast majority of readers of this mailing list are seeing.


> the problem reappears. Any idea why? A numeric (0 or 1) variable produces
> different interactions than a logical variable (FALSE or TRUE).
> --
> View this message in context: http://r.789695.n4.nabble.com/coxph-how-to-define-interaction-terms-tp4679162p4679249.html
> Sent from the R help mailing list archive at Nabble.com.
"R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html"

And you should read both the fine posting guide and the messages that Nabble suppresses in its effort to masquerade as Rhelp.

"and provide commented, minimal, self-contained, reproducible code."


David Winsemius
Alameda, CA, USA

More information about the R-help mailing list