survival-analysis

R - cox hazard model not including levels of a factor

浪子不回头ぞ 提交于 2021-02-19 23:59:13
问题 I am fitting a cox model to some data that is structured as such: str(test) 'data.frame': 147 obs. of 8 variables: $ AGE : int 71 69 90 78 61 74 78 78 81 45 ... $ Gender : Factor w/ 2 levels "F","M": 2 1 2 1 2 1 2 1 2 1 ... $ RACE : Factor w/ 5 levels "","BLACK","HISPANIC",..: 5 2 5 5 5 5 5 5 5 1 ... $ SIDE : Factor w/ 2 levels "L","R": 1 1 2 1 2 1 1 1 2 1 ... $ LESION.INDICATION: Factor w/ 12 levels "CLAUDICATION",..: 1 11 4 11 9 1 1 11 11 11 ... $ RUTH.CLASS : int 3 5 4 5 4 3 3 5 5 5 ... $

Getting P-Values of Zero in Cox Regression: R

﹥>﹥吖頭↗ 提交于 2021-02-11 13:35:45
问题 I am a student conducting a gene expression survival analysis in R. I have the expression data for 249 patients, and I am using 6,000 genes as well as their event-free survival times and vital state as response variables. When I tried to run the Cox regression on my dataset, I got extremely strange results (p-values of 0.00 and strange hazard ratios). I have checked over my code multiple times, but I am not able to catch my mistake (when I tried earlier with just one gene, it worked fine, but

ggforest function returns error message when used with coxph

强颜欢笑 提交于 2021-02-10 18:31:17
问题 when applying ggforest() to a coxph object I get the follwoing error message error in ggforest(res.cox3, data = Selection_cox) : class(model) == "coxph" are not all TRUE res.cox3 is the output of coxph() which includes a tt term, strata and is of class: > class(res.cox3) [1] "coxph.penal" "coxph" I get the same message for the following dummy data: set.seed(132456) 'dummy survival data' df<-data.frame(id=seq(1,1000,1), event=rep(0,1000),time=floor(runif(1000,7,10)),group=floor(runif(1000,0,2)

ggforest function returns error message when used with coxph

前提是你 提交于 2021-02-10 18:29:25
问题 when applying ggforest() to a coxph object I get the follwoing error message error in ggforest(res.cox3, data = Selection_cox) : class(model) == "coxph" are not all TRUE res.cox3 is the output of coxph() which includes a tt term, strata and is of class: > class(res.cox3) [1] "coxph.penal" "coxph" I get the same message for the following dummy data: set.seed(132456) 'dummy survival data' df<-data.frame(id=seq(1,1000,1), event=rep(0,1000),time=floor(runif(1000,7,10)),group=floor(runif(1000,0,2)

Find the maximum of the function in R

时光总嘲笑我的痴心妄想 提交于 2021-01-27 17:09:44
问题 I have the following function. Let F(.) is the cumulative distribution function of the gamma distribution with shape = 1 and rate =1 . The denominator is the survival function S(X) = 1 - F(X) . The g(x) is the mean residual life function. I wrote the following function in r. x = 5 denominator = 1 -pgamma(x, 1, 1) numerator = function(t) (1 - pgamma(t, 1, 1)) intnum = integrate(numerator , x, Inf) frac = intnum$value/denominator frac How can I find the maximum of the function g(x) for all

How to do survival analysis in R with time-varying exposure to an intervention, using Surv and coxph?

有些话、适合烂在心里 提交于 2021-01-07 03:52:29
问题 I have survival data in this format, with a time-varying exposure to Intervention: ID start stop status Intervention 1 2 14 0 0 2 2 5 0 0 3 2 3 0 0 3 3 10 1 1 4 5 8 0 0 5 6 10 0 0 For example, for patient ID #3: from day 2 to day 3, the patient has not yet received the intervention (Intervention = 0), but starting on day 3 and lasting until day 10 (when the patient dies), the patient has received the intervention (Intervention = 1). I thought that I could then estimate the time-varying effect

Add at risk table and 95% confidence intervals to adjusted survival curves using survminer package in r

孤人 提交于 2020-12-15 04:37:45
问题 I want to add at-risk table and 95% confidence intervals to adjusted survival curves. Something like survival curves below (Link). I saw some relevant code here but it doesn't mention what I need. Another question, would it be correct if I used the obtained weight variable (from iptw package) in the adjustment (as I have a column named weight in my actual dataset. Here is my code: library(survival);library(survminer) data(lung);names(lung) #fit <- coxph( Surv(time, status==2) ~ ph.karno +

Add at risk table and 95% confidence intervals to adjusted survival curves using survminer package in r

↘锁芯ラ 提交于 2020-12-15 04:37:35
问题 I want to add at-risk table and 95% confidence intervals to adjusted survival curves. Something like survival curves below (Link). I saw some relevant code here but it doesn't mention what I need. Another question, would it be correct if I used the obtained weight variable (from iptw package) in the adjustment (as I have a column named weight in my actual dataset. Here is my code: library(survival);library(survminer) data(lung);names(lung) #fit <- coxph( Surv(time, status==2) ~ ph.karno +

Customising line type in adjusted survival curves ggadjustedcurves (survminer, ggplot2)

╄→гoц情女王★ 提交于 2020-12-12 09:45:08
问题 I'm trying to plot an adjusted survival curve, but struggling with changing the line types by group. I'm able to customise other aspects of the plot using typical ggplot2 language, but I've hit a wall with changing line type. Example: library(survival) library(survminer) fit2 <- coxph( Surv(stop, event) ~ size + strata(rx), data = bladder ) ggadjustedcurves(fit2, variable = "rx", data = bladder, method = "average", palette = c("#E69F00", "#56B4E9"), size = 1.3, legend = "right", legend.title

Customising line type in adjusted survival curves ggadjustedcurves (survminer, ggplot2)

北慕城南 提交于 2020-12-12 09:44:36
问题 I'm trying to plot an adjusted survival curve, but struggling with changing the line types by group. I'm able to customise other aspects of the plot using typical ggplot2 language, but I've hit a wall with changing line type. Example: library(survival) library(survminer) fit2 <- coxph( Surv(stop, event) ~ size + strata(rx), data = bladder ) ggadjustedcurves(fit2, variable = "rx", data = bladder, method = "average", palette = c("#E69F00", "#56B4E9"), size = 1.3, legend = "right", legend.title