# R adds unexpected variable to interaction model

Not sure if this is more of a programming question (in which case please move to stack overflow) or a statistical model question (in which case, please read on!)

I'm exploring a data set and doing cox proportional hazards regression.

One of my variables did not satisfy the proportional hazards assumption so I decided to stratify by that variable.

Stratifying by the variable will assume that the effect of all covariates is the same in each stratum but each stratum has different baseline hazards.

To check this I test for an interaction between the stratifying variable and each covariate. When I run any model with interactions R does something that is unexpected to me:

Call:
coxph(formula = Surv(NRM_time, NRM_status) ~ strata(chemosens) +
remission + chemosens * (high.LDH + working) + eversmoke +
etoh.current + married - chemosens, data = data)

coef exp(coef) se(coef)      z       p
remission1           -0.6206     0.538    0.192 -3.225 1.3e-03
high.LDH1             0.8181     2.266    0.177  4.635 3.6e-06
working1             -0.4329     0.649    0.204 -2.121 3.4e-02
eversmoke1            0.1698     1.185    0.125  1.358 1.7e-01
etoh.current1        -0.1633     0.849    0.124 -1.322 1.9e-01
married1             -0.0607     0.941    0.133 -0.455 6.5e-01
high.LDH0:chemosens1  0.8353     2.305    0.255  3.270 1.1e-03
high.LDH1:chemosens1      NA        NA    0.000     NA      NA
working1:chemosens1   0.7644     2.148    0.299  2.553 1.1e-02

Likelihood ratio test=40  on 8 df, p=3.19e-06  n= 738, number of events= 267
(38 observations deleted due to missingness)


As you can see, all my covariates are dichotomous. When I fit the model with interaction between chemosens and both high.LDH and working why does R have an interaction term for chemosens with high.LDH0 AND high.LDH1 (as opposed to just high.LDH1 like it did for working).

• Yes, it seems to be because I take out the main effect of chemosens (since the data is stratified by chemosens). – bdeonovic Nov 26 '14 at 17:06
• Than you have your answer. – Tim Nov 26 '14 at 17:09
• Indeed, that wasn't too complicated. You can write a quick blurb as an answer and I can select it if you want. – bdeonovic Nov 26 '14 at 17:10

My guess is that the chemosens * (high.LDH + working) part of the formula got translated into: working1:chemosens1, high.LDH0:chemosens1, and high.LDH1:chemosens1, while working0:chemosens1 seems to be baseline for the comparison. So you got what you asked for: interaction of chemosens with two variables. This kind of things happen if you remove intercept from the model.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7199241518974304, "perplexity": 2791.6922669848864}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-16/segments/1585370499280.44/warc/CC-MAIN-20200331003537-20200331033537-00165.warc.gz"}