survival-analysis

How do I simulate a left truncated Weibull failure time data in R

*爱你&永不变心* 提交于 2020-06-29 04:08:27
问题 I want to simulate left truncated failure time data from Weibull distribution. My objective is to simulate data and retrieve the coefficients(of x1,x2,x3,x4, and x5 which I used for the simulation) by fitting a Weibull regression model. Here the xt=runif(N, 30, 80) denotes the start of the study, Tm <- qweibull(runif(N,pweibull(xt,shape = 7.5, scale = 82*exp(lp)),1), shape=7.5, scale=82*exp(lp)) variable denotes the failure time. But whenever I do the regression I am getting this warning

R neuralNet: “non-conformable arguments”

允我心安 提交于 2020-06-25 03:36:06
问题 Argh! I keep getting the following error when attempting to compute with my neural network: > net.compute <- compute(net, matrix.train2) Error in neurons[[i]] %*% weights[[i]] : non-conformable arguments I can't figure out what the problem is. Below I'll provide you with an example data and formatting from my matrices and then I'll show you the code I'm attempting to run. matrix.train1 is used for training the network > matrix.train1 (Intercept) survived pclass sexmale age sibsp parch fare

How to compute the mean survival time

情到浓时终转凉″ 提交于 2020-06-10 04:14:25
问题 I'm using the survival library. After computing the Kaplan-Meier estimator of a survival function: km = survfit(Surv(time, flag) ~ 1) I know how to compute percentiles: quantile(km, probs = c(0.05,0.25,0.5,0.75,0.95)) But, how do I compute the mean survival time? 回答1: Calculate Mean Survival Time The mean survival time will in general depend on what value is chosen for the maximum survival time. You can get the restricted mean survival time with print(km, print.rmean=TRUE) . By default, this

how to fix 'Error: variable lengths differ (found for 'input$s')' in R Shiny

邮差的信 提交于 2020-05-29 08:23:30
问题 I'm trying to make a simple shiny ap for creating kaplan-meier survival curves that are stratified by selection the user makes. When I code the KM calculation statically (with the column name thorTr) it works but the calculation and plot is static. When I replace with input$s I get ERROR:variable lengths differ (found for 'input$s') I've tried looking at other code which use as.formula and paste, but I don't understand and couldn't get to work. But I am a new R and Shiny user so maybe I didn

how to fix 'Error: variable lengths differ (found for 'input$s')' in R Shiny

旧街凉风 提交于 2020-05-29 08:23:18
问题 I'm trying to make a simple shiny ap for creating kaplan-meier survival curves that are stratified by selection the user makes. When I code the KM calculation statically (with the column name thorTr) it works but the calculation and plot is static. When I replace with input$s I get ERROR:variable lengths differ (found for 'input$s') I've tried looking at other code which use as.formula and paste, but I don't understand and couldn't get to work. But I am a new R and Shiny user so maybe I didn

How to extract summary() to a data frame applicable for data visualization in ggplot()?

徘徊边缘 提交于 2020-04-17 19:53:19
问题 I am doing survival-analysis with the presence of competing risks . I use the prodlim-package , which I find quite useful. However, I do not like the build-in graphics, and would like to apply ggplot instead. Question: how can I extract the prodlim summary() -output and load it into a data frame accessible to ggplot2? Perhaps a function can be written to do this? I have previously received help on StackOverflow in terms of loading a summary() -output into a dataframe , but with a different

How to extract summary() to a data frame applicable for data visualization in ggplot()?

烂漫一生 提交于 2020-04-17 19:49:46
问题 I am doing survival-analysis with the presence of competing risks . I use the prodlim-package , which I find quite useful. However, I do not like the build-in graphics, and would like to apply ggplot instead. Question: how can I extract the prodlim summary() -output and load it into a data frame accessible to ggplot2? Perhaps a function can be written to do this? I have previously received help on StackOverflow in terms of loading a summary() -output into a dataframe , but with a different

Why does Survival curve sum up to 100% when less than 50% experience event?

微笑、不失礼 提交于 2020-04-14 09:15:42
问题 This problem has confounded me for more hours than I care to admit. I have isolated the problem so I can replicate it. library(survival) library(survminer) set.seed(123) test <- data.frame(rnorm(10000)+5, sample(0:1, 10000, replace = TRUE)) colnames(test)<- c("time", "event") #sum(test$event) = 4975 survfitted <- survfit(Surv(time = time, event = event) ~ 1, data = test) plot(survfitted, fun = "event") Why does this curve sum up to 100% when only 49.75% experience an event? What would be the