Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
你能在R中的cox回归中使用聚类函数两次吗?_R_Cox Regression - Fatal编程技术网

你能在R中的cox回归中使用聚类函数两次吗?

你能在R中的cox回归中使用聚类函数两次吗?,r,cox-regression,R,Cox Regression,所以我有一个cox查询-所以我尝试做一个cox回归,我想知道我是否可以将数据聚类两次: 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 cox1我不知道你关于

所以我有一个cox查询-所以我尝试做一个cox回归,我想知道我是否可以将数据聚类两次:

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

cox1我不知道你关于在
coxph
中聚类两个变量的问题的具体答案,但也许你可以在
id.location
New.id
之间创建一个交互因子,然后聚类该变量(并且只调用
cluster

比如说,

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)

all.data$newvar我不知道您关于在
coxph
中对两个变量进行聚类的问题的具体答案,但也许您可以在
id.location
New.id
之间创建一个交互因子,然后对该变量进行聚类(并且只调用
cluster

比如说,

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)
all.data$newvar