coxphfit+matlab,Cox Proportional Hazards Model for Censored Data

这篇博客介绍了如何使用Cox比例风险模型分析医疗数据中的患者再入院时间。首先,通过加载模拟数据,展示了如何考虑删失数据来拟合模型,并验证性别对再入院时间的影响显著。接着,将年龄和体重加入模型,发现它们在考虑性别后并不显著。最后,引入吸烟状态变量,结果显示性别和吸烟状态在模型中都具有统计学意义,表明吸烟和性别对再入院风险有显著影响。
摘要由CSDN通过智能技术生成

Step 1. Load sample data.

Load the sample data.

load readmissiontimes

The response variable is ReadmissionTime, which shows the readmission times for 100 patients. The predictor variables are Age, Sex, Weight, and the smoking status of each patient, Smoker. 1 indicates the patient is a smoker, and 0 indicates that the patient does not smoke. The column vector Censored has the censorship information for each patient, where 1 indicates censored data, and 0 indicates the exact readmission times are observed. This is simulated data.

Step 2. Fit Cox proportional hazards function.

Fit a Cox proportional hazard function with the variable Sex as the predictor variable, taking the censoring into account.

X = Sex;

[b,logl,H,stats] = coxphfit(X,ReadmissionTime,'censoring',Censored);

Assess the statistical significance of the term Sex.

stats

stats = struct with fields:

covb: 0.1016

beta: -1.7642

se: 0.3188

z: -5.5335

p: 3.1392e-08

csres: [100x1 double]

devres: [100x1 double]

martres: [100x1 double]

schres: [100x1 double]

sschres: [100x1 double]

scores: [100x1 double]

sscores: [100x1 double]

LikelihoodRatioTestP: 5.9825e-09

The p-value, p, indicates that the term Sex is statistically significant.

Save the loglikelihood value with a different name. You will use this to assess the significance of the extended models.

loglSex = logl

loglSex = -262.1365

Step 3. Add Age and Weight to the model.

Fit a Cox proportional hazards model with the variables Sex, Age, and Weight.

X = [Sex Age Weight];

[b,logl,H,stats] = coxphfit(X,ReadmissionTime,'censoring',Censored);

Assess the significance of the terms.

stats.beta

ans = 3×1

-0.5441

0.0143

0.0250

stats.p

ans = 3×1

0.4953

0.3842

0.0960

None of the terms, adjusted for others, is statistically significant.

Assess the significance of the terms using the log likelihood ratio. You can assess the significance of the new model using the likelihood ratio statistic. First find the difference between the log-likelihood statistic of the model without the terms Age and Weight and the log-likelihood of the model with Sex, Age, and Weight.

-2*[loglSex - logl]

ans = 3.6705

Now, compute the p-value for the likelihood ratio statistic. The likelihood ratio statistic has a Chi-square distribution with a degrees of freedom equal to the number of predictor variables being assessed. In this case, the degrees of freedom is 2.

p = 1 - cdf('chi2',3.6705,2)

p = 0.1596

The p-value of 0.1596 indicates that the terms Age and Weight are not statistically significant, given the term Sex in the model.

Step 4. Add Smoker to the model.

Fit a Cox proportional hazards model with the variables Sex and Smoker.

X = [Sex Smoker];

[b,logl,H,stats] = coxphfit(X,ReadmissionTime,...

'censoring',Censored);

Assess the significance of the terms in the model.

stats.p

ans = 2×1

0.0000

0.0148

Compare this model to the first model where Sex is the only term.

-2*[loglSex - logl]

ans = 5.5789

Compute the p-value for the likelihood ratio statistic. The likelihood ratio statistic has a Chi-square distribution with a degree of freedom of 1.

p = 1 - cdf('chi2',5.5789,1)

p = 0.0182

The p-value of 0.0182 indicates that Sex and Smoker are statistically significant given the other is in the model. The model with Sex and Smoker is a better fit compared to the model with only Sex.

Request the coefficient estimates.

stats.beta

ans = 2×1

-1.7165

0.6338

The default baseline is the mean of X, so the final model for the hazard ratio is

HR=hX(t)hX‾(t)=exp[βs(Xs-X‾s)+βα(Xα-X‾α)].

Fit a Cox proportional hazards model with a baseline of 0.

X = [Sex Smoker];

[b,logl,H,stats] = coxphfit(X,ReadmissionTime,...

'censoring',Censored,'baseline',0);

The model for the hazard ratio is

HR=hX(t)h0(t)=exp[βsXs+βαXα].

Request the coefficient estimates.

stats.beta

ans = 2×1

-1.7165

0.6338

The coefficients are not affected, but the hazard rate differs from when the baseline is the mean of X.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值