Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to make an adjusted survival curve based on a weighted cox regression performed on a case cohort data set in R, but unfortunately, I can't make it work. I was therefore hoping that some of you may be able to figure it out why it isn't working.

In order to illustrate the problem, I have used (and adjusted a bit) the example from the "Package 'survival'" document, which means im working with:

data("nwtco")

subcoh <- nwtco$in.subcohort
selccoh <- with(nwtco, rel==1|subcoh==1)
ccoh.data <- nwtco[selccoh,]
ccoh.data$subcohort <- subcoh[selccoh]
ccoh.data$age <- ccoh.data$age/12 # Age in years

fit.ccSP <- cch(Surv(edrel, rel) ~ stage + histol + age, 
                data =ccoh.data,subcoh = ~subcohort, id=~seqno, cohort.size=4028, method="LinYing")

The data set is looking like this:

   seqno instit histol stage study rel edrel      age in.subcohort subcohort
4      4      2      1     4     3   0  6200 2.333333         TRUE      TRUE
7      7      1      1     4     3   1   324 3.750000        FALSE     FALSE
11    11      1      2     2     3   0  5570 2.000000         TRUE      TRUE
14    14      1      1     2     3   0  5942 1.583333         TRUE      TRUE
17    17      1      1     2     3   1   960 7.166667        FALSE     FALSE
22    22      1      1     2     3   1    93 2.666667        FALSE     FALSE

Then, I'm trying to illustrate the effect of stage in an adjusted survival curve, using the ggadjustedcurves-function from the survminer package:

library(suvminer)
ggadjustedcurves(fit.ccSP, variable = ccoh.data$stage, data = ccoh.data)
#Error in survexp(as.formula(paste("~", variable)), data = ndata, ratetable = fit) : 
#  Invalid rate table

But unfortunately, this is not working. Can anyone figure out why? And can this somehow be fixed or done in another way?

Essentially, I'm looking for a way to graphically illustrate the effect of a continuous variable in a weighted cox regression performed on a case cohort data set, so I would, generally, also be interested in hearing if there are other alternatives than the adjusted survival curves?

question from:https://stackoverflow.com/questions/65937322/adjusted-survival-curve-based-on-weigthed-cox-regression

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
546 views
Welcome To Ask or Share your Answers For Others

1 Answer

Two reasons it is throwing errors.

  1. The ggadjcurves function is not being given a coxph.object`, which it's halp page indicated was the designed first object.
  2. The specification of the variable argument is incorrect. The correct method of specifying a column is with a length-1 character vector that matches one of the names in the formula. You gave it a vector whose value was a vector of length 1154.

This code succeeds:

 fit.ccSP <- coxph(Surv(edrel, rel) ~ stage + histol + age, 
                 data =ccoh.data)
 ggadjustedcurves(fit.ccSP, variable = 'stage', data = ccoh.data)

enter image description here

It might not answer your desires, but it does answer the "why-error" part of your question. You might want to review the methods used by Therneau, Cynthia S Crowson, and Elizabeth J Atkinson in their paper on adjusted curves:
https://cran.r-project.org/web/packages/survival/vignettes/adjcurve.pdf


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...