[R] Specifying interactions in coxme
Patrick Phillips
pphil at uoregon.edu
Thu Oct 29 05:28:24 CET 2015
I am trying to estimate variance components from a complex random effects survival model using coxme (Package version 2.2-5). I am having problems specifying interaction effects in the random terms. I wonder if this is simply not implemented in coxme yet.
For instance, using the model
coxme(Surv(DeathAge,Dead) ~ treatment + (1 | block/tank))
Works fine (tank nested within block), but
coxme(Surv(DeathAge,Dead) ~ treatment + (1 | block) + (1 | block:tank))
fails with "Error in getgroups(f2$group, m) : Invalid grouping factor block:tank”.
By my understanding of model specification in R, these should be equivalent statements (assuming that that the tank effects have been coded appropriately as unique within blocks). Any interaction specified using “:” appears to fail.
I am actually interested in much more complex models but can’t seem to be able to specify any interactions effects. For instance a factorial model like,
coxme(Surv(DeathAge,Dead) ~ treatment + (1 | room*block))
fails with "Error in getgroups(f2$group, m) : Invalid grouping factor room * block”.
Since I can’t directly specify the interaction effects and the factorial operator “*” does not seem to work, I appear to be SOL. It seems that only nested effects specified by the “/“ operator are allowed. Multiple nesting is also OK, which is great for a single hierarchical nesting design, but not sufficient for more complex random effects models.
Any thoughts would be most welcome.
Thanks, Patrick
More information about the R-help
mailing list