In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Most people do not understand the knowledge points of this article "how to use R language for KM survival analysis", 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 "how to use R language for KM survival analysis" article.
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. The specific process is as follows
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")) these are the contents of this article on "how to use R language for KM Survival Analysis" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.