Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analysis of Survival results of R language Cox and KM

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this "R language Cox and KM survival result analysis" article, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "R language Cox and KM survival result analysis" article.

Survival analysis of Cox and KM and interpretation of results to find biomarker related to prognosis

Survival analysis: for chronic diseases (cancer), because it is unable to judge the prognosis in a short period of time, it is not suitable to use indicators such as cure rate and mortality, but need to follow up the patients and analyze the survival or death of the patients after a certain period of time, so the statistical method of combining the results of the event with the time experienced by the results is called survival analysis.

Introduction of similarities and differences between KM method and Cox method in Survival Analysis

The KM method, or Kaplan-Meier survival estimate, is a non-parametric method (non-parametric) to estimate the survival probability from the observed survival time. KM survival analysis model is univariate analysis (univariable analysis). In univariate analysis, the model only describes the relationship between univariate and survival and ignores the influence of other variables. (why consider multi-variables? For example, comparing the effects of having or not having a certain genotype on survival between the two groups, but patients in one group are older, so survival may be affected by genotype or / and age. At the same time, Kaplan-Meier method can only focus on classified variables (treatment A vs treatment B, male vs female), but can not analyze the impact of continuous variables on survival. In order to solve the above two problems, Cox proportional hazard regression model (Cox proportional hazards regression model) is proposed. Therefore, the Cox proportional hazard regression model can not only analyze the impact of continuous variables on survival, but also can analyze the impact of multivariate analysis on survival.

Introduction of Survival Analysis R package in R language

R is one of the commonly used software for data analysis, through a variety of powerful R packets, can be simple and convenient to achieve a variety of analysis. In R language, there are many R packets that can carry out survival analysis, of which survival and survminer are the most basic, survival is responsible for analysis, survimner is responsible for visualization, the combination of the two can easily achieve survival analysis.

Analysis of KM model in R language 1. Prepare survival data

For each individual, there are two situations in their survival data, the first is the observation of survival time, which is usually expressed as 1, and the second is deletion. It is usually denoted by 0. Survival comes with a test data lung.

Each line represents a sample, time indicates time to live, and status indicates deletion. Here, there are only 1 and 2 values. The first level after the default sorting is censored, and here 1 indicates censorship. Other basic information such as sex, age and so on are listed as samples.

two。 Conduct survival analysis

Here, according to the gender as a binary variable, the KM algorithm is used to estimate the survival curve. The code is as follows (only part of the summary results are shown)

> library ("survival") > library ("survminer") > kmfit summary (kmfit) Call: survfit (formula = Surv (time, status) ~ sex Data = lung) sex=1 time n.risk n.event survival std.err lower 95% CI upper 95% CI 11 138 3 0.9783 0.0124 0.9542 1.000 12 135 1 0.9710 0.0143 0.9434 0.999 13 0.9565 0.0174 0.9231 0.991 15132 1 0.9493 0.0187 0.9134 0.987 26 131 1 0.9420 0.0199 0.9038 0.982 30 130 1 0.9348 0.0210 0.8945 0.977

From the kmfit summary can see that each point in time has been included in the survival probability, deletion and other information, through this information, you can write your own code to draw. For convenience, we directly use the functions in survminer for visualization.

3. Visualization of analysis results

The most basic visualization methods are as follows

Library ("survminer") ggsurvplot (kmfit, pval = TRUE, conf.int = TRUE, risk.table = TRUE, risk.table.col = "strata", linetype = "strata", surv.median.line = "hv", ggtheme = theme_bw (), palette = c ("# E7B800") "# 2E9FDF") Cox model analysis in the language 1. Univariate Cox regression library ("survival") library ("survminer") res.cox

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report