cox model doesn't suppport "mright" survival data

4.2k views Asked by At

Good morning,

I have been trying to do a stratified logistic regression in R after matching for a Case/Control study and encountered a in my opinion unexpected mistake. I have reproduced the error using the mtcars data set:

test=mtcars
test$am=as.factor(test$am)
test$cyl=as.factor(test$cyl)
test$vs=as.factor(test$vs)
library(survival)
clogit(am~vs+strata(cyl),data=test)

Error in coxph(formula = Surv(rep(1, 32L), am) ~ vs + strata(cyl), data = test, : Cox model doesn't support "mright" survival data

In my understanding the clogit-function creates the time parameter, which R seemingly has a problem with. The mistake disappears, when I don't use a am as a factor, but that is the whole, but don't I have to label it as a factor in order to do a logistic regression?

By the way, I am using R 3.2.2 and survival package 2.41-3, but since it seems both functions involved are from the survival package, this shouldn't be the root of the problem here, right? Or is this mistake not reproducable under a newer R-Version?

1

There are 1 answers

0
IRTFM On

I think either @MarcoSandri or Member0815 should have put in code that illustrated this solution so that the question could be seen as "answered".

> test=mtcars
> test$am=as.logical(test$am)
> test$cyl=as.factor(test$cyl)
> test$vs=as.factor(test$vs)
> library(survival)
> clogit(am~vs+strata(cyl),data=test)
Call:
clogit(am ~ vs + strata(cyl), data = test)

          coef  exp(coef)   se(coef)      z     p
vs1 -2.248e+01  1.733e-10  2.159e+04 -0.001 0.999

Likelihood ratio test=7.75  on 1 df, p=0.005378
n= 32, number of events= 13 
Warning message:
In coxexact.fit(X, Y, istrat, offset, init, control, weights = weights,  :
  Loglik converged before variable  1 ; beta may be infinite.