有人能告诉我是否可以加入:
a)互动术语
b)随机效应
在R的Tobit回归模型中?
对于交互术语,我一直在处理以下脚本,但这不起作用。
fit <- vglm(GAG_p_DNA~factor(condition)+factor(time)+factor(condition):factor(time),
tobit(Lower = 0))
Error in if ((temp <- sum(wz[, 1:M, drop = FALSE] < wzepsilon))) warning(paste(temp, :
argument is not interpretable as logical
我还尝试使用虚拟变量,按以下方式创建:
time.ch<- C(time, helmert,2)
print(attributes(time.ch))
condition.ch<-C(condition, helmert, 3)
print(attributes(condition.ch))
但是我得到了同样的错误。
部分数据集(GAG_p_DNA值为零被删除)(警告:对于那些可能正在复制此内容的人.OP使用制表符作为分隔符。)
Donor Time Condition GAG_p_DNA cens_GAG_p_DNA
1 1 6 0.97 1
1 1 10 0.93 1
1 7 2 16.65 1
1 7 6 0.94 1
1 7 10 1.86 1
1 28 2 21.66 1
1 28 6 0.07 1
1 28 10 3.48 1
2 1 1 1.16 1
2 1 2 2.25 1
2 1 6 2.41 1
2 1 10 1.88 1
2 7 2 13.19 1
2 7 10 2.54 1
2 28 2 23.93 1
2 28 6 0 0
2 28 10 15.17 1
我很可能需要使用Tobit回归模型,因为似乎R不支持具有左删失数据的Cox模型...
fit<- survfit(Surv(GAG_p_DNA, cens_GAG_p_DNA, type="left")~factor(condition)+factor(Time))] [Error in coxph(Surv(GAG_p_DNA, cens_GAG_p_DNA, type = "left") ~ factor(condition) + : Cox model doesn't support "left" survival data
答案 0 :(得分:0)
试试这个:
survreg(Surv( GAG_p_DNA, cens_GAG_p_DNA, type='left') ~
factor(Time)*factor(Condition), data=sdat, dist='gaussian')
---早先的努力;
使用这个微小的数据集(我已经更正了使用制表符作为分隔符),你不会得到太多。我纠正了两个错误(&#34;条件&#34的拼写;并使用0
进行左删失,它应该是2
并且运行时没有错误:
sdat$cens_GAG_p_DNA[sdat$cens_GAG_p_DNA==0] <- 2
fit <- survfit(Surv(GAG_p_DNA, cens_GAG_p_DNA, type="left") ~
factor(Condition) + factor(Time), data=sdat)
Warning messages:
1: In min(jtimes) : no non-missing arguments to min; returning Inf
2: In min(jtimes) : no non-missing arguments to min; returning Inf
3: In min(jtimes) : no non-missing arguments to min; returning Inf
4: In min(jtimes) : no non-missing arguments to min; returning Inf
5: In min(jtimes) : no non-missing arguments to min; returning Inf
6: In min(jtimes) : no non-missing arguments to min; returning Inf
7: In min(jtimes) : no non-missing arguments to min; returning Inf
8: In min(jtimes) : no non-missing arguments to min; returning Inf
9: In min(jtimes) : no non-missing arguments to min; returning Inf
> fit
Call: survfit(formula = Surv(GAG_p_DNA, cens_GAG_p_DNA, type = "left") ~
factor(Condition) + factor(Time), data = sdat)
records n.max n.start events median
factor(Condition)=1, factor(Time)=1 1 2 2 0 1.16
factor(Condition)=2, factor(Time)=1 1 2 2 0 2.25
factor(Condition)=2, factor(Time)=7 2 3 3 0 14.92
factor(Condition)=2, factor(Time)=28 2 3 3 0 22.80
factor(Condition)=6, factor(Time)=1 2 3 3 0 1.69
factor(Condition)=6, factor(Time)=7 1 2 2 0 0.94
factor(Condition)=6, factor(Time)=28 2 2 2 2 0.00
factor(Condition)=10, factor(Time)=1 2 3 3 0 1.41
factor(Condition)=10, factor(Time)=7 2 3 3 0 2.20
factor(Condition)=10, factor(Time)=28 2 3 3 0 9.32
0.95LCL 0.95UCL
factor(Condition)=1, factor(Time)=1 NA NA
factor(Condition)=2, factor(Time)=1 NA NA
factor(Condition)=2, factor(Time)=7 13.19 NA
factor(Condition)=2, factor(Time)=28 21.66 NA
factor(Condition)=6, factor(Time)=1 0.97 NA
factor(Condition)=6, factor(Time)=7 NA NA
factor(Condition)=6, factor(Time)=28 0.00 NA
factor(Condition)=10, factor(Time)=1 0.93 NA
factor(Condition)=10, factor(Time)=7 1.86 NA
factor(Condition)=10, factor(Time)=28 3.48 NA
我称之为错误的另一个方面是不使用回归函数的data
参数。试图使用&#34;附加&#34;数据框,具有任何回归功能,尤其是“生存”功能。包,往往会导致奇怪的错误。
我确实发现通过hte公式方法进行交互产生了这个错误:
Error in survfit.formula(Surv(GAG_p_DNA, cens_GAG_p_DNA, type = "left") ~ :
Interaction terms are not valid for this function
我还发现coxme :: coxme,我推测可能会让你访问混合效果,但没有处理左删失。
fit <- coxme(Surv(GAG_p_DNA, cens_GAG_p_DNA, type="left")~factor(Condition)*factor(Time), data=sdat)
Error in coxme(Surv(GAG_p_DNA, cens_GAG_p_DNA, type = "left") ~ factor(Condition) * :
Cox model doesn't support 'left' survival data