问题标签 [cox-regression]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
490 浏览

r - R 每组的风险时间

我一直在准备 R 中的生存分析和 cox 回归。但是,我的直线经理是 Stata 用户,并且希望以与 Stata 显示它的方式类似的方式显示输出,例如

stsum将为每个组输出一个风险时间和一个发生率,我不知道如何用 R 来实现这一点。


数据大致如下(我无法获取它,因为它处于安全环境中):

到目前为止,我一直在使用相当混乱的标准代码:

0 投票
1 回答
1108 浏览

r - 使用 rcorr.cens() 和 val.surv 对 Cox 模型进行外部验证

我有两个独立的数据集,一个包含 5421 个主题,另一个包含 1000 个主题。我想做的是使用外部数据集(test_dat,n=1000)验证从主数据集(main_dat,n=5421)获得的 Cox 模型。但是,我同时使用 Hmisc 包中的 rcorr.cens() 和 rms 中的 val.surv 收到错误消息。这是我一直在做的事情:

rcorr.cens 中的错误(x = 估计,S = surv.obj):y 必须与 x 具有相同的长度

val.surv 中的错误(phmodel,newdata = test_dat,u = 10):dims [product 1000] 与对象 [5421] 的长度不匹配此外:警告消息:In est.surv + S[, 1]:更长对象长度不是较短对象长度的倍数

我做错了什么还是两个数据集必须有相同数量的观察?

任何帮助将不胜感激。

0 投票
1 回答
9511 浏览

r - 如何使用样条曲线绘制 Cox 危险模型

我有以下模型:

其中 fulength 是随访的持续时间(包括死亡率),predictor 是死亡率的预测因子。

上面命令的输出是这样的:

如何绘制此模型,以便在 y 轴上获得具有 95% 置信带和风险比的漂亮曲线?我的目标与此类似:

在此处输入图像描述

0 投票
2 回答
10866 浏览

r - 如何在R中的Cox回归模型中预测生存时间?

我有一个使用 Cox 回归建模的问题,现在想预测一个人的估计生存时间。该模型具有生存时间所依赖的协变量列表。告诉我们如何计算 P(T>t),它基本上是给定个体的生存函数 (1-CDF)。

我想预测一些略有不同的东西。给定已使用的协变量的值,我想预测此人的估计生存天数。据我说,这类似于从 pdf 中采样。如何使用 R 中的生存包做到这一点?以下是使用 Cox 回归模型的拟合摘要。

0 投票
1 回答
406 浏览

r - Segmentation faults in R's Cox regression with "exact" ties

I'm trying to fit a large discrete proportional-hazards model (~100k rows, ~10k events). To do this I used coxph(..., method = "exact") as recommended by the survival package documentation documentation, which states:

The “exact partial likelihood” is equivalent to a conditional logistic model, and is appropriate when the times are a small set of discrete values. If there are a large number of ties and (start, stop) style survival data the computational time will be excessive.

There were some warnings about computational difficulty with coxph and large numbers of ties, but according to the documentation for clogit in the same package:

The computation of the exact partial likelihood can be very slow, however. If a particular strata had, say 10 events out of 20 subjects we have to add up a denominator that involves all possible ways of choosing 10 out of 20, which is 20!/(10! 10!) = 184756 terms. Gail et al describe a fast recursion method which largely ameleorates this; it was incorporated into version 2.36-11 of the survival package.

So I didn't expect the computational issues to be too bad. Nevertheless, I've run into many segmentation faults when trying to fit variants of a trivial (one-predictor) Cox model on my dataset. One is a "C stack overflow," resulting in the short and sweet (and uninformative) message:

The other is a "memory not mapped" error, which occurred when I accidentally flipped the "event" boolean so that I had ~90k events instead of ~10k:

For reference, the code I'm running is simply coxph(Surv(t, d) ~ x, data = data, method = 'exact'). t is an integer column, d is Boolean and x is a float.

Are these known issues? Are there workarounds?

EDIT: Here's some code reproducing the problem on the rats dataset (replicated 1000 times):

And here's version:

0 投票
0 回答
681 浏览

sas - 使用 SAS PHREG 进行分段线性回归

如何在 SAS 的 PHREG 程序中实现分段线性回归模型?

例如,在 X=T 处有一个结:

Y = β_10 + β_11 。X 如果 X ≤ T

Y = β_20 + β_21 。X 如果 X >T

给定具有连续性约束的模型:

IE :

在哪里

最后,我想将它包含在 Cox 模型中:

但问题是 S_1 中有未知的 beta 系数。

谢谢你的帮助!

0 投票
0 回答
123 浏览

r - R: "caught segfault" when running cox proportional hazards model

I am running several Cox models, each time adding one new variable.

The primary model I ran was

This worked fine, but then I wanted to add a week fixed effect to take into account the time (or week) in which a trade was opened. So I ran the following:

When I run this model on my laptop, R crashes. When I run it on the cluster, I get the following error:

For model1 I used 8GB of RAM and it worked fine, for model2 I tried increasing it to 128 GB on the cluster but it did not work.

I am guessing it doesn't have to do with memory but instead with me adding the week variable. Is this error occurring because the week variable is correlated in some way to time1sec and time2sec, which are the open and close dates of the trade?

UPDATE I plotted week against the time1sec as shown in the graph. I know that these two variables are perfectly correlated, but my question is since the duration is also based on time2sec, can't I include week as a fixed effect? Or is this taken into account by the model via the time1sec variable?

plot-openWeek-vs-time1sec

0 投票
2 回答
1786 浏览

r - 了解 Cox 模型中缺失的原因

我运行了以下 Cox 模型,得到了 1526679 个已删除的观察结果,这是我数据的很大一部分。

我不知道为什么这些意见被删除。我确信这些值是存在的,并且不是空的。当我将 ID 添加为一个脆弱的术语时,这种情况就开始发生了。

有什么想法可能会在这里发生吗?

0 投票
0 回答
374 浏览

sas - 危险比曲线 - SAS

有人可以告诉我,使用哪个 SAS 程序或 SAS 中的任何其他方法来绘制危险比曲线,如下面的链接所示:

http://figshare.com/articles/_Hazard_ratio_curves_for_the_association_between_NT_proBNP_levels_and_the_risk_of_heart_failure_in_non_obese_n_8202_8202_1_095_and_obese_n_8202_8202_265_participants_/1251609

因为,我还不知道如何保留输出中出现的危险比值..

谢谢..

0 投票
1 回答
77 浏览

survival-analysis - 如何将 CoxPH 模型的 PPER 格式转换为 SPELL 格式

CoxPH 生存分析

我有一个 PPER(人期)格式的数据集,例如:

Machine_id,Timestamp,Event,TDV1,TDV2,TDV3,TDV4 TDV1/2 是因素(品牌、位置) TDV3/4 是连续的(温度、湿度)

需要转换为 SPELL 格式,例如:Machine_id,start.time,stop.time,event,TDV1,TDV2,TDV3,TDV4

我能够通过在 TraMineRextras 中使用 seqdef() 和 toPersonPeriod() 从 SPELL 转换为 PPER

需要帮助来做相反的事情。从 PPER 转换为 SPELL 格式时如何处理连续变量?