I'm studying all-cause cancer incidence in a large population.
Since it is an important confounding factor for many cancers, I'd like to adjust for hormonal contraception and hormone replacement therapy, but in women only.
Of course, this effect itself depends on the menopausal status of women.
In a Cox PH model on cancer events, I tried to add interaction terms like this:
m1 = coxph(Surv(age_origin, age_surv, event_surv) ~ X + Y + Z +
sex*menopause*pill +
sex*menopause*HRT,
data=db)
Of course, this model did not fit, and I guess it was because (hopefully) no men had menopause nor was on the pill, so the effect was monotonous in the men sub-group.
For R enthusiasts, the error was:
Error in
contrasts<-
(*tmp*
, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
Is it possible (and does it make sense) to account for such an effect?