【问题标题】:Interaction terms and random effects in tobit regression model in RR中tobit回归模型中的交互项和随机效应
【发布时间】:2014-10-08 15:13:35
【问题描述】:

谁能告诉我是否可以合并:
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&lt;- 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

【问题讨论】:

  • 我会写成这样:GAG_p_DNA~factor(condition)*factor(time)
  • 同名包中的coxme函数实现了删失数据的混合效应估计。如果您提供数据(可能是模拟的),则可能会编写一些代码。
  • 另外,我需要使用 Tobit 回归模型,因为我留下了 cenosred 数据。不幸的是,使用左删失无法在 R 中执行 cox 模型。
  • 关于在 R 中不可能进行左审查的说法是错误的。请阅读 pkg:survivaL 中的 ?Surv 页面 请编辑您的问题以包含生成示例的代码,而不是在 cmets 中发布格式不正确的数据。 (以上材料中没有审查变量。)
  • 仍然没有数据。无法提供进一步的建议。

标签: r regression


【解决方案1】:

试试这个:

survreg(Surv( GAG_p_DNA, cens_GAG_p_DNA, type='left') ~ 
                factor(Time)*factor(Condition), data=sdat, dist='gaussian')

(Therneau 推荐:http://markmail.org/search/?q=list%3Aorg.r-project.r-help+therneau+left+censor+tobit#query:list%3Aorg.r-project.r-help%20therneau%20left%20censor%20tobit+page:1+mid:fnczjvrnjlx5jsp5+state:results

--- 早期的努力;

使用那个小数据集(我已经更正了使用制表符作为分隔符的地方),你不会得到太多。我纠正了两个错误(“条件”的拼写并使用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 参数。尝试使用带有任何回归函数的“附加”数据框,尤其是使用“生存”包,通常会导致奇怪的错误。

我确实发现通过 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

【讨论】:

  • 感谢您提供有关“数据”参数的提示。不过,现在您可能明白了我为什么对执行 Tobit 回归感兴趣,以及为什么我首先问了一个关于该模型的问题。
猜你喜欢
  • 2022-10-06
  • 2022-11-11
  • 2020-02-14
  • 2015-04-23
  • 2016-02-12
  • 2013-07-23
  • 2021-06-29
  • 2021-06-16
  • 1970-01-01
相关资源
最近更新 更多