Reputation: 11
So I have a cox query - so I am trying to do a cox regression and I wonder if I can cluster the data twice:
cox1<-coxph(formula = Surv(time.to.arrive..trap, Arrived.1.or.0) ~
Is.feeder.control.or.stimulus + cluster(id.location) + cluster(New.ID),
data = all.data)
cox1
I am trying to work out if there is a difference of time to arrive at the control or stimulus feeder - however I want to take into account that birds can appear multiple times in my data - (at control and stimulus, either or both at each of the five locations). Does it make sense to use the cluster function twice? In the above formula I clustered it by ID of the bird and by location.Id.
This may seem like an obvious question - but has been causing me no end of trouble! Thank you very much indeed in advance for any light you can shed on the matter!!
Kind regards
Upvotes: 1
Views: 546
Reputation: 6203
I don't know the specific answer to your question regarding clustering two variables within coxph
, but perhaps you can create an interaction factor between id.location
and New.ID
and then cluster that variable (and calling cluster
only once)
For example,
all.data$newvar <- interaction(all.data$id.location, all.data$New.ID)
cox1<-coxph(formula = Surv(time.to.arrive..trap, Arrived.1.or.0) ~
Is.feeder.control.or.stimulus + cluster(newvar), data = all.data)
Upvotes: 0