Geom_line(data = df, aes(lower, p), linetype = 2, size = 1)Ĭreated on by the reprex package (v0.3. Geom_line(data = df, aes(upper, p), linetype = 2, size = 1) + Geom_line(data = df, aes(time, p), linetype = 2, size = 1) + Ggsurvplot(fKM, ggtheme = theme_bw())$plot + If you want both in the same plot you can do something like: df <- ame(p = 1 - probs, Which we can see looks like a pretty good fit. Geom_ribbon(aes(p, ymin = lower, ymax = upper, fill = "All"), alpha = 0.2) + Geom_step(aes(p, time, colour = "All"), size = 1) + Lower = time$fit - 1.96 * time$se.fit)) + Both have the same number of rows as lung, but all rows are identical, so we just take one from each and calculate the confidence interval in a data frame which we can then use to create a ggplot: ggplot(data = ame(p = 1 - probs, The only problem is that time is now a named list of two matrices: fit and se.fit. Time <- predict(sWei, type = "quantile", se = TRUE, p = probs) sWei <- survreg(s ~ 1, dist = 'weibull', data = lung) However, if you want to fit a Weibull model with no predictors, then your formula is fine. If you just want to plot the overall empirical survival curve, you might do something like this: library(survival)įKM <- survfit(s ~ 1, data = survival::lung) I tried replacing as.factor(sex) by 1 and then the rest of the code just does not make sense, can someone help me with this? P$plot = p$plot + geom_line(data=df_long, aes(x=time, y=y, group=sex)) P = ggsurvplot(fKM, data = lung, risk.table = T) ![]() x1 = predict(sWei, newdata=list(sex=1),type="quantile",p=seq(.01.99,by=.01)) #Since I don't want to stratify, what do I do with these 2 lines of code? ![]() Stratascale brings a consultancy-first approach to helping Fortune 1000 organizations embrace the cloud, adopt automation, improve cybersecurity, implement digital experiences and leverage data intelligence. SWei <- survreg(s ~ as.factor(sex),dist='weibull',data=lung) # in my case here I would replace as.factor(sex) by 1 Stratascale is an SHI Company, one of the world’s most successful technology resellers and solutions providers. So when I copy the code from the other question, here is where I get stuck: library(survminer) Large enterprises need scalability and sustainability from their production initiatives before the initiatives reliably deliver value at the magnitude of the world’s premier corporations. I just want the progression free survival for the whole group of treated patients. How to plot the survival curve generated by survreg (package survival of R)?Įxcept for the fact that I don't want the data to be stratified by a variable (in the question above it was stratified by sex). I want to achieve the exact same thing asked in this question:
0 Comments
Leave a Reply. |