Skip to content

Random coefficients model with a covariate: coxme function

1 message · Terry Therneau

#
example deleted
The coxme function does not support random slopes.  It's been on my "to do" 
list for a long time.  I am supposed to teach an American Stat Assoc course at 
the end of March, however, which has escalated the urgency.

  If the covariate has only 2 levels, such as a random treatment effect when 
there are only 2 treatments, then by coding the treatment as 0/1 and creating 
just the right covariates you could "trick" coxme into fitting the model.  This 
is what is described in the report.  You essentially make treatment a nested 
effect.
  	fit1 <-  coxme(Surv(y, uncens) ~ treat + covar, data1,
  		    random= ~1 | centers)
        fit2 <-  coxme(Surv(y, uncens) ~ treat + covar, data1,
        	    random= ~1 | centers/treat)
  
  There is no residual variance for a Cox model.  
  
  Your example was very hard to read.  Consider using spaces, indentation, etc 
to make it easier for old eyes.
  
  	Terry T.