Porter, Aaron T
2009-Jun-24 17:13 UTC
[R] Coxph frailty model counting process error X matrix deemed singular
Hello, I am currently trying to simulate data and analyze it using the frailty option in the coxph function. I am working with recurrent event data, using counting process notation. Occasionally, (about 1 in every 100 simulations) I get the following warning: Error in coxph(Surv(start, end, censorind) ~ binary + uniform + frailty(subject, : X matrix deemed to be singular; variable 2 My data is structured as follows: I have a Bernoulli random variable (parameter=0.5) (labeled "binary") and a second variable which was generated as seq(0.02, 1, 0.02), which is labeled as "uniform". There are 50 individual subjects. Recurrent events are then generated as rexp(1, 0.2*frailparm[j]*exp(mydata[j,1]*alpha[1]+mydata[j,2]*alpha[2])) where mydata is the cbind of the data just mentioned, alpha are the parameters for the recurrent events (here I am using c(1,1)) and frailparm is the frailty term for subject {j}. I generate recurrent events until the sum of the times is greater than the terminal time or censoring time, and keep the previous highest time as my final recurrent time, with one additional time which is censored at the minimum of the terminal event time and the censoring time. I then repeat for each subject. I then try to analyze the data like this: coxph(Surv(start,end,censorind)~binary+uniform+frailty(subject,distribution="gauss", method="reml"), method="breslow", singular.ok=FALSE, data=fulldata) Where start is the previous recurrent time, end is the current recurrent time, censorind is the censoring indicator for the current recurrent time, and subject is the current observation. There does not appear to be an issue with the binary variable taking a particular value for every observed event time, nor does there appear to be perfect correlation between the variable "uniform" and the survival time. Any help would be much appreciated.
Terry Therneau
2009-Jun-25 12:29 UTC
[R] Coxph frailty model counting process error X matrix deemed singular
...> Occasionally, (about 1 in every 100 simulations) I get the following warning: > Error in coxph(Surv(start, end, censorind) ~ binary + uniform : > X matrix deemed to be singular; variable 2It is not uncommon for the X matrix in a Cox model to be close enough to singular that the program thinks it is singular, i.e., one of the pivot elements falls below the tolerance threshold while performing a Cholesky decomposition. To understand your case better you need to capture one of the offending data sets and look at the X matrix. I am not going to be able to guess. I normally ignore this (the indeterminate coefficient is set to NA) and go on. You however have chosen to override the default and set singular.ok=FALSE so that the program fails with an error message. You get what you asked for. Last, I am always surprised when people chose method='breslow' in coxph. Why substitute an inferior approximation for the better one? Of course with simulated data there are no ties, in which case all the methods are identical. Terry Therneau