Main Content

Cox Proportional Hazards Model with Time-Dependent Covariates

此示例显示如何将生存数据转换为计数过程形式,然后用时间依赖的协变量构建Cox比例危险模型。

Step 1. Compare standard layout and counting process form.

A Cox model with time-dependent covariates requires survival data to be in counting process form and not in standard layout. To see the difference between survival data in standard layout and in counting process form, load the following sample data.

加载SimpleSurvivalData.

此示例数据包含两个表:复发andrelapseCP。These two tables represent the same simple survival data in standard layout and in counting process form, respectively.

以标准布局显示数据。

复发
复发=2×5 tableID Time Censoring Age StopTreatment __ ____ _________ ___ _____________ 1 5 0 20 NaN 2 20 1 30 12

该数据代表两个治疗状态随时间变化的患者。患者1未对周期0到5的间隔进行处理并在间隔结束时复发。患者2正在从第0周的间隔进行处理,但不适用于从12至20周的间隔。患者2在第20周之后没有复发并离开这项研究。

Now display the same data in counting process form.

relapseCP
relapseCP=3×6表ID TSTART TSTOP审查年龄治疗ASTATUS _______ ________________________________ 0 5 0 20 0 2 0 12 1 30 1 2 12 20 1 30 0

In counting process form, each row represents the risk interval (Tstart.Tstop.]而不是一个事件时间的单个值。审查is 0 if the event is observed at the end of the risk interval, and 1 if it is not.TreatmentStatuscorresponds to a time-dependent covariate, which represents the same information withStopTreatment在标准布局中。注意,COX模型假设时间相关的协变量在每个风险间隔中是常量的。

步骤2.加载样本数据。

接下来,将样本数据加载以转换。

加载survivaldatacp.

This sample data contains a table实验室,这是模拟存活数据,包括每个患者的标准布局的重复测量。

在标准布局中显示模拟的生存数据。

实验室
实验室=6×7表ID Time Censoring Sex Lab_0 Lab_50 Lab_100 __ ____ _________ ___ _____ ______ _______ 1 46 0 1 0.3 NaN NaN 2 138 1 0 0.2 0.23 0.39 3 94 0 1 0.18 0.22 NaN 4 50 0 0 0.21 0.2 NaN 5 106 0 0 0.25 0.21 0.42 6 98 0 0 0.21 0.22 NaN

在标准布局中,表的每一行都显示了一个患者的信息。

  • ID表示患者的ID。你不包括IDas an input of a Cox model. IncludeIDin a data set to confirm that the data set is correctly converted to counting process form.

  • 时间represents time to event in days, which corresponds to a response variable.

  • 审查has the censorship information for each patient, where 1 indicates censored data and 0 indicates that the exact time to event is observed at the end of the observation period.

  • 性别是一个独立于一个时间的预测指标,其中1表示雌性,0表示男性。

  • Lab_0Lab_50那andLab_100represent three consecutive laboratory results measured at day 0, 50, and 100, which correspond to a time-dependent predictor.

步骤3.将生存数据转换为计数过程表格。

转换生存数据实验室要计算流程表单,请执行下面的代码。此代码转换时间风险间隔(Tstart.Tstop.]并结合了三个时间依赖预测因素,Lab_0Lab_50那andLab_100那into one vector,Lab

mTime = [0 50 100];%测量时间threelabs = [Labs.Lab_0 Labs.Lab_50 Labs.Lab_100];nlabmeasure = sum(sum(〜isnan(threelabs)));%实验室测量数量data = zeros(nLabMeasure,6);每次观察%一行oID = 0;% Observation ID为了i = 1 : size(labS,1) idx = find(mTime <= labS.Time(i));为了j = 1 : length(idx)-1 oID = oID + 1; data(oID,:) = [labS.ID(i) mTime(j:j+1) 1 labS.Sex(i) threeLabs(i,j)];结尾oID = oID + 1; data(oID,:) = [labS.ID(i) mTime(length(idx)) labS.Time(i)......Labs.Censing(i)Labs.sex(i)Threelabs(i,Length(IDX))];结尾Labcp.= table(data(:,1),data(:,2),data(:,3),data(:,4),data(:,5),data(:,6),......'variablenames'那{'ID''tstart''tstop''Censoring'“性”'Lab'});

Display the survival data in counting process form.

Labcp.
Labcp.=13×6 tableID tStart tStop Censoring Sex Lab __ ______ _____ _________ ___ ____ 1 0 46 0 1 0.3 2 0 50 1 0 0.2 2 50 100 1 0 0.23 2 100 138 1 0 0.39 3 0 50 1 1 0.18 3 50 94 0 1 0.22 4 0 50 1 0 0.21 4 50 50 0 0 0.2 5 0 50 1 0 0.25 5 50 100 1 0 0.21 5 100 106 0 0 0.42 6 0 50 1 0 0.21 6 50 98 0 0 0.22

在计数过程表单中,每行表Labcp.显示对应于一个风险间隔的一个观察的信息。请注意,COX模型假定Lab在风险间隔中持续(Tstart.Tstop.]。价值审查如果在风险间隔结束时观察到事件,则为0,如果未观察到事件,则为1。

例如,患者3在第0天和50天具有两个实验室测量,因此患者3的数量有两排计数过程形式。COX模型假定实验室结果0.18和0.22分别在间隔(0,50]和(50,94)中恒定。审查(50,94]中是1(50,94],因为在第94天观察到患者3的确切事件时间。

步骤4.调整零长度风险间隔。

找到具有零长度风险间隔的患者。

idxInvalid = labCP.ID(find(labCP.tStart == labCP.tStop))
Idxinvalid = 4.

查看患者4的数据。

Labcp(find(labcp.id == idxinvalid),:)
ans=2×6 tableID TSTART TSTOP截尾性别实验室__ ______ _____ _________ ___ ____ 4 0 50 1 0 0.21 4 50 50 0 0 0.2

患者4事件的时间与测量第50天一致。然而,(50,50]是COX模型的无效风险间隔,因为模型不接受零长度间隔。调整风险间隔有效。您可以选择小于时间单位作为调整金额的任何值。调整量的选择是任意的,它不会改变结果。

idxadjust = find(labcp.id == idxinvalid);labcp.tstop(IDxadjust(1))= labcp.tstop(IDxadjust(1)) -  0.5;labcp.tstart(idxadjust(2))= labcp.tstart(idxadjust(2)) -  0.5;labcp(idxadjust,:)
ans=2×6 tableID tStart tStop Censoring Sex Lab __ ______ _____ _________ ___ ____ 4 0 49.5 1 0 0.21 4 49.5 50 0 0 0.2

Step 5. Construct a Cox proportional hazards model.

用时间无关的变量拟合Cox比例危险模型性别和时间相关的变量Lab

X = [labCP.Sex labCP.Lab]; T = [labCP.tStart labCP.tStop]; b = coxphfit(X,T,'Censoring'那Labcp.。审查那'Baseline'那0)
b =2×12.0054 29.7530

有关如何评估COX比例危险模型的详细信息,请参阅CONX比例危害审查数据的模型

也可以看看

相关例子

更多关于