简体   繁体   English

R中的轨道回归模型中的交互作用项和随机效应

[英]Interaction terms and random effects in tobit regression model in R

Can anyone tell me if it is possible to incorporate: 谁能告诉我是否可以合并:
a)an interaction term a)互动条件
b)a random effect in a Tobit regression model in R? b)R中Tobit回归模型的随机效应?

For the interaction term I have been working on the following script, but that doesn't work. 对于交互作用术语,我一直在研究以下脚本,但这不起作用。

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

I have also tried this with dummy variables, created in the following way: 我还尝试了通过以下方式创建的虚拟变量:

time.ch<- C(time, helmert,2)
print(attributes(time.ch))
condition.ch<-C(condition, helmert, 3)
print(attributes(condition.ch))

but I get the same error. 但我得到同样的错误。

Part of the dataset (GAG_p_DNA values of zero are left censored) (Warning: to those who may be copying this. The OP used tabs as separators.) 数据集的一部分(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

I most likely need to use a Tobit regression model, as it seems that a Cox model with left censored data is not supported by R... 我很可能需要使用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

Try this: 尝试这个:

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

(Recommended by 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 ) (由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

--- earlier effort; ---较早的努力;

With that tiny dataset (where I have corrected the use of tabs as separators) you won't get much. 有了这个很小的数据集(在这里我已经纠正了使用制表符作为分隔符的情况),您将不会有太多收获。 I corrected two errors (spelling of "Condition" and using 0 for left censoring where it should be 2 and it runs without error: 我更正了两个错误(拼写为“ Condition”,并使用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

The other aspect which I would call an error as well would be not using a data argument to regression functions. 我也将称为错误的另一方面是不使用data参数来回归函数。 Trying to use "attached" dataframes, with any regression function but especially with the 'survival' package, will often cause strange errors. 试图将“附加”数据帧与任何回归函数一起使用,尤其是与“生存”包一起使用时,通常会导致奇怪的错误。

I did find that putting in an interaction by way of hte formula method generated this error: 我确实发现通过hte公式方法进行交互会产生此错误:

Error in survfit.formula(Surv(GAG_p_DNA, cens_GAG_p_DNA, type = "left") ~  : 
  Interaction terms are not valid for this function

And I also found that coxme::coxme, which I had speculated might give you access to mixed effects, did not handle left censoring. 而且我还发现,我推测可能会给您带来混合效果的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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用R绘制预测值并比较随机效应plm模型中的相互作用项的最佳方法是什么? - What is the best way in R to plot predicted values and compare interaction terms in a random effects plm model? 回归 model 与 r 中所有可能的双向交互项 - Regression model with all possible two way interaction terms in r 如何在 R ggplot2 中拟合具有交互作用的混合效应模型回归? - How to fit a mixed effects model regression with interaction in R ggplot2? 在regsubsets()或其他函数中,具有较高交互作用项并包含主要影响的R中的详尽模型选择是否可行? - Is exhaustive model selection in R with high interaction terms and inclusion of main effects possible with regsubsets() or other functions? R误差中的随机效应模型 - Random effects model in R - error 具有二元接触和相互作用项的广义线性回归模型 - Generalized Linear Regression Model With Binary Exposure and Interaction Terms 如何在 R 中进行具有交互效应和滞后的固定效应回归? - How to do a fixed effects regression with interaction effect and lags in R? 如何创建具有交互作用的负二项式回归模型的交集? - How to create interplot of negative binomial regression model with interaction effects? 交互项中变量的绘图效果 - Plot Effects of Variables in Interaction Terms 多元线性回归中的交互项 - interaction terms in multiple linear regression
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM