I missed this question.
1. For survreg.
help("predict.survreg") shows an example of drawing a survival curve
Adding a survfit method has been on my list for a long time, since it would make this
information easier to find.
2. intcox. I had not been familiar with this function. Even though the authors have
decided to label the result with a "coxph" class, presumably so the coxph print function
will work, almost none of the coxph methods will work on the result.
However, reading their manual page it seems that the hazard and its time points are
returned as a part of the result. I tried running an example to see if the result is a
hazard or a cumulative hazard but the run failed and it's time to run to a meeting.
Assume it is cumulative hazard. Then exp(-fit$lambda0) will give the baseline survival curve.
Terry T
On 08/27/2014 02:47 PM, David Winsemius wrote:
On Aug 26, 2014, at 3:34 PM, Silong Liao wrote:
>Hello,
>
>My data is interval censoring, and I use intcox package which deals with this
situation.
>
>I guess survest is only for survfit, and I would like to plot parametric model
"survreg".....Since I use dist="weibull", I tried curve function but plot seems
unreasonable.
>
>>mod.reg1=survreg(s_new~type+sex+eye+age+preopiop+preopva,dist="weibull")
>>intercept=-19.155
>>scale=8.12
>>curve(pweibull(x,scale=exp(coef(mod.reg1)),shape=1/mod.reg1$scale,lower.tail=FALSE),from=0,to=40)
>
You are asked to reply to the list. ( I am taking the liberty of forwarding to
Terry Therneau since I don't want to misquote him.)
I remember Terry Therneau saying that plotting survival curves from
interval-censored data seemed difficult at best and nonsensical at worst. (If
it's difficult for him it's likely to be impossible for me.) I don't know if
the assumption of a parametric form might aid in that effort.
I also remember warnings (in both the documentation and repeated many times by
Therneau on rhelp) that the parameters of the weibull distribution used in the
survival package were different than those used in the stats package weibull
function.
-- David.
>----------------------------------------
>>Subject: Re: [R] plot for "survreg" and "intcox" (rewritten)
>>From:dwinsem...@comcast.net
>>Date: Tue, 26 Aug 2014 14:57:16 -0700
>>CC:r-help@r-project.org
>>To:silong.l...@hotmail.com
>>
>>
>>On Aug 26, 2014, at 2:33 PM, Silong Liao wrote:
>>
>>>Dear R users,
>>>
>>>I'm trying to plot survival probability against time(in years) using "survreg" and
"intcox". Please can you help me with this problem? (I have rewritten using plain text.) I tried to use
"curve" function but have no clue.
>>>
>>
>>I suspect you want survfit (in the survial package which is where I suspect
survreg is coming from. It returns an object that has a plot method. You could also
scroll through help(pack=survival) to see other plotting functions.
>>
>>You could also use survest in the rms package.
>>
>>>For survreg,
>>>>mod.reg1=survreg(s_new~type+sex+eye+preopiop+preopva,dist="weibull")
>>>>summary(mod.reg1)
>>>Call:
>>>survreg(formula = s_new ~ type + sex + eye + preopiop + preopva, dist =
"weibull")
>>>Value Std. Error z p
>>>(Intercept) 40.539 20.582 1.970 4.89e-02
>>>typeTrab -6.606 4.279 -1.544 1.23e-01
>>>sexM -1.055 3.765 -0.280 7.79e-01
>>>eyeR -2.112 3.587 -0.589 5.56e-01
>>>preopiop -0.308 0.269 -1.147 2.52e-01
>>>preopva -0.461 1.771 -0.260 7.95e-01
>>>Log(scale) 2.058 0.285 7.222 5.12e-13
>>>
>>>Scale= 7.83
>>>Weibull distribution
>>>Loglik(model)= -78.7 Loglik(intercept only)= -81.4
>>>Chisq= 5.37 on 5 degrees of freedom, p= 0.37
>>>Number of Newton-Raphson Iterations: 10
>>>n= 339
>>>
>>>For intcox,
>>
>>You are asked to provide the package name for functions that are not in the
base or default packages. I have quite a few packages loaded including
survival_2.37-7 , coxme_2.2-3, and rms_4.2-0 but I get:
>>
>>>?intcox
>>No documentation for ‘intcox’ in specified packages and libraries:
>>you could try ‘??intcox’
>>>
>>
>>--
>>David.
>>
>>
>>
>>>>cox.fit=intcox(s_new~type+eye+sex+age+preopiop+preopva,data=glaucoma_new)
>>>>summary(cox.fit)
>>>Call:
>>>intcox(formula = s_new ~ type + eye + sex + age + preopiop +preopva, data =
glaucoma_new)
>>>
>>>n= 339
>>>
>>>coef exp(coef) se(coef) z Pr(>|z|)
>>>typeTrab 0.59391 1.81106 NA NA NA
>>>eyeR 0.28419 1.32868 NA NA NA
>>>sexM -0.11597 0.89050 NA NA NA
>>>age -0.06556 0.93655 NA NA NA
>>>preopiop 0.03903 1.03980 NA NA NA
>>>preopva -0.05517 0.94632 NA NA NA
>>>
>>>exp(coef) exp(-coef) lower .95 upper .95
>>>typeTrab 1.8111 0.5522 NA NA
>>>eyeR 1.3287 0.7526 NA NA
>>>sexM 0.8905 1.1230 NA NA
>>>age 0.9365 1.0678 NA NA
>>>preopiop 1.0398 0.9617 NA NA
>>>preopva 0.9463 1.0567 NA NA
>>>
>>>Rsquare= NA (max possible= 0.327 )
>>>Likelihood ratio test= NA on 6 df, p=NA
>>>Wald test = NA on 6 df, p=NA
>>>Score (logrank) test = NA on 6 df, p=NA
>>>
>>>______________________________________________
>>>R-help@r-project.org mailing list
>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>>PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>>>and provide commented, minimal, self-contained, reproducible code.
>>
>>David Winsemius
>>Alameda, CA, USA
>>
> <Rplot.jpeg>
David Winsemius
Alameda, CA, USA
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.