[R] Fitting problem for Cox model with Strata as interaction term

wong jane j@ne@wong083 @ending from gm@il@com
Tue May 8 10:40:02 CEST 2018


Dear All,


I got a warning message "X matrix deemed to be singular" in Cox model with
a time dependent coefficient. In my analysis, the variable "SEX" is a
categorical variable which violate the PH assumption in Cox. I first used
the survSplit() function to break the data set into different time
intervals, and then fit the model. The procedures can be described as
follows:

> data <- survSplit(Surv(time, status)~., data=data, cut=c(5, 10), episode=
"tgroup", id="id")    #data split
> data$SEX <- as.factor(data$SEX)
> data$SEX <- relevel(data$SEX, ref="1")
> str(data$SEX)
 Factor w/ 2 levels "1","2": 1 1 1 2 2 2 2 2 2 2 ...
> xtabs(~status+SEX, data)
      SEX
status    1    2
     0 6764 5537
     1 1643 1468
> xtabs(~status+tgroup+SEX, data)
, , SEX = 1

      tgroup
status    1    2    3
     0 3035 2403 1326
     1  759  458  426

, , SEX = 2

      tgroup
status    1    2    3
     0 2596 1940 1001
     1  701  476  291


> fit1 <- coxph(Surv(tstart, time, status) ~ *SEX:strata(tgroup)*,
data=data)
Warning message:
In coxph(Surv(tstart, time, status) ~ SEX:strata(tgroup), data = data) :
  X matrix deemed to be singular; variable 2 4 6
> fit1
Call:
coxph(formula = Surv(tstart, time, status) ~ SEX:strata(tgroup),
    data = data)

                               coef exp(coef) se(coef)     z       p
SEX1:strata(tgroup)tgroup=1 -0.0715    0.9310   0.0524 -1.36    0.17
SEX2:strata(tgroup)tgroup=1      NA        NA   0.0000    NA      NA
SEX1:strata(tgroup)tgroup=2 -0.2624    0.7692   0.0655 -4.01 6.1e-05
SEX2:strata(tgroup)tgroup=2      NA        NA   0.0000    NA      NA
SEX1:strata(tgroup)tgroup=3 -0.0309    0.9696   0.0761 -0.41    0.68
SEX2:strata(tgroup)tgroup=3      NA        NA   0.0000    NA      NA

Likelihood ratio test=18.1  on 3 df, p=0.000425
n= 15412, number of events= 3111
>

#It works well if the main effect was included
> fit2 <- coxph(Surv(tstart, time, status) ~* SEX*strata(tgroup)*,
data=data)
> fit2
Call:
coxph(formula = Surv(tstart, time, status) ~ SEX * strata(tgroup),
    data = data)

                               coef exp(coef) se(coef)     z     p
SEX2                         0.0715    1.0741   0.0524  1.36 0.172
SEX2:strata(tgroup)tgroup=2  0.1909    1.2104   0.0838  2.28 0.023
SEX2:strata(tgroup)tgroup=3 -0.0406    0.9602   0.0924 -0.44 0.660

Likelihood ratio test=18.1  on 3 df, p=0.000425
n= 15412, number of events= 3111
>

Much appreciated for any suggestions. Many thanks in advance.

	[[alternative HTML version deleted]]



More information about the R-help mailing list