Dear all - I have followed the thread the reply to which was lead by Thomas Lumley about using pweibull to generate fitted survival curves for survreg models. http://tolstoy.newcastle.edu.au/R/help/04/11/7766.html Using the lung data set, data(lung) lung.wbs <- survreg( Surv(time, status)~ 1, data=lung, dist='weibull') curve(pweibull(x, scale=exp(coef(lung.wbs)), shape=1/lung.wbs $scale,lower.tail=FALSE),from=0, to=max(lung$time)) lines(survfit(Surv(time,status)~1, data=lung), col="red") Assuming this is correct, why does the inflection point of this curve not match up to the exp(scale parameter)? Am I wrong in assuming that the scale represents the inflection, and the shape adjusts the shape around this point? I think I am.... perhaps confusing the scale and the median with the inflection point calcuation? One can visualise the mismatch with: abline(v=exp(coef(lung.wbs)),lty=2) abline(h=0.5,lty=2) Many thanks for the clarification.... R version 2.8.0 (2008-10-20) i386-apple-darwin8.11.1 locale: en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] splines datasets utils stats graphics grDevices methods base other attached packages: [1] survival_2.34-1 Hmisc_3.4-3 lattice_0.17-15 MASS_7.2-44 loaded via a namespace (and not attached): [1] cluster_1.11.11 grid_2.8.0 tools_2.8.0 Andrew --------------------------------------------------------------------------------- Dr. Andrew Beckerman Department of Animal and Plant Sciences, University of Sheffield, Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK ph +44 (0)114 222 0026; fx +44 (0)114 222 0002 http://www.beckslab.staff.shef.ac.uk/ http://www.flickr.com/photos/apbeckerman/ http://www.warblefly.co.uk
Andrew Beckerman
2008-Nov-27 09:59 UTC
[R] survreg and pweibull solved for any distribution
Dear all - Following up my own post, having found a Terry Therneau post about the value of predict(model,type="quantile"), http://tolstoy.newcastle.edu.au/R/e4/help/08/03/5335.html the following code ammendment produces what I was intending to see. It clear that the 0.5 quantile is the inflection point. And predict() has the value of being distribution independent, and producing valid SE estimates. data(lung) lung.wbs <- survreg( Surv(time, status)~ 1, data=lung, dist='weibull') curve(pweibull(x, scale=exp(coef(lung.wbs)), shape=1/lung.wbs $scale,lower.tail=FALSE),from=0, to=max(lung$time)) lines(survfit(Surv(time,status)~1, data=lung), col="red") abline(h=0.5,lty=2) abline(v=unique(predict(lung.wbs,type="quantile",p=0.5)),lty=2,col=4) However, one last technical question. In an intercept only model, how do you specify newdata to get just a single estimate? In the above example I used unique against the model predictions evaluated at every datapoint. But with no terms on the RHS of the model, how do you (can you) specify new data? Best wishes, Andrew On 26 Nov 2008, at 16:27, Andrew Beckerman wrote:> Dear all - > > I have followed the thread the reply to which was lead by Thomas > Lumley about using pweibull to generate fitted survival curves for > survreg models. > > http://tolstoy.newcastle.edu.au/R/help/04/11/7766.html > > Using the lung data set, > > data(lung) > lung.wbs <- survreg( Surv(time, status)~ 1, data=lung, dist='weibull') > curve(pweibull(x, scale=exp(coef(lung.wbs)), shape=1/lung.wbs > $scale,lower.tail=FALSE),from=0, to=max(lung$time)) > lines(survfit(Surv(time,status)~1, data=lung), col="red") > > Assuming this is correct, why does the inflection point of this > curve not match up to the exp(scale parameter)? Am I wrong in > assuming that the scale represents the inflection, and the shape > adjusts the shape around this point? I think I am.... perhaps > confusing the scale and the median with the inflection point > calcuation? > > One can visualise the mismatch with: > > abline(v=exp(coef(lung.wbs)),lty=2) > abline(h=0.5,lty=2) > > Many thanks for the clarification.... > > R version 2.8.0 (2008-10-20) > i386-apple-darwin8.11.1 > locale: > en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 > attached base packages: > [1] splines datasets utils stats graphics grDevices > methods base > other attached packages: > [1] survival_2.34-1 Hmisc_3.4-3 lattice_0.17-15 MASS_7.2-44 > loaded via a namespace (and not attached): > [1] cluster_1.11.11 grid_2.8.0 tools_2.8.0 > > Andrew > > --------------------------------------------------------------------------------- > Dr. Andrew Beckerman > Department of Animal and Plant Sciences, University of Sheffield, > Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK > ph +44 (0)114 222 0026; fx +44 (0)114 222 0002 > http://www.beckslab.staff.shef.ac.uk/ > > http://www.flickr.com/photos/apbeckerman/ > http://www.warblefly.co.uk > > ______________________________________________ > R-help at 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.