[R] Random coefficients model with a covariate: coxme function

Terry Therneau therneau at mayo.edu
Mon Dec 29 16:18:28 CET 2008

> I'm new to R and am trying to fit a mixed model 
> Cox regression model with coxme function.
> I have one two-level factor (treat) and one 
> covariate (covar) and 32 different groups 
> (centers). I'd like to fit a random coefficients model, with treat and covar
> as fixed factors and a random intercept, random 
> treat effect and random covar slope per center.
> I haver a couple of doubts on how to use coxme function for this task:

 example deleted
> * What if the treatment factor has more than two 
> levels. Should I follow the same procedure, with just bigger block sizes?

> * Coxme returns a variance per each of the 
> variance matrices I defined, but no residual 
> variance estimate. Is there a way to get it?

   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 
  	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.

More information about the R-help mailing list