[R] Does psm::Surv handle interval2 data?

Frank Harrell f.harrell at vanderbilt.edu
Mon Jan 14 15:00:04 CET 2013


Chris,

Thanks for sending the specifics.  It appears that I've let Surv in rms fall
behind recent versions of Surv in survival.  It will take me a few days to
get this fixed.  I'll send a follow-up note then.
Frank

Andrews, Chris wrote
> Does Surv in psm handle interval2 data?  The argument list seems to
> indicate it does but I get an error.
> 
> Thanks,
> Chris
> 
> # code
> library('survival')
> left <- c(1, 3, 5, NA)
> right <-c(2, 3, NA, 4)
> Surv(left, right, type='interval2')
> survreg(Surv(left, right, type='interval2') ~ 1)
> 
> library('rms')
> Surv(left, right, type='interval2') # error
> args(Surv)
> psm(Surv(left, right, type='interval2') ~ 1) # same error (of course)
> psm(survival::Surv(left, right, type='interval2') ~ 1) # runs
> 
> 
> # output
> 
> R version 2.15.2 (2012-10-26) -- "Trick or Treat"
> 
> Copyright (C) 2012 The R Foundation for Statistical Computing
> 
> ISBN 3-900051-07-0
> 
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> 
> 
> 
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> 
> You are welcome to redistribute it under certain conditions.
> 
> Type 'license()' or 'licence()' for distribution details.
> 
> 
> 
>   Natural language support but running in an English locale
> 
> 
> 
> R is a collaborative project with many contributors.
> 
> Type 'contributors()' for more information and
> 
> 'citation()' on how to cite R or R packages in publications.
> 
> 
> 
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 
> 'help.start()' for an HTML browser interface to help.
> 
> Type 'q()' to quit R.
> 
> 
> 
>> library('survival')
> 
> Loading required package: splines
> 
>> left <- c(1, 3, 5, NA)
> 
>> right <-c(2, 3, NA, 4)
> 
>> Surv(left, right, type='interval2')
> 
> [1] [1, 2] 3      5+     4-
> 
>> survreg(Surv(left, right, type='interval2') ~ 1)
> 
> Call:
> 
> survreg(formula = Surv(left, right, type = "interval2") ~ 1)
> 
> 
> 
> Coefficients:
> 
> (Intercept)
> 
>    1.317943
> 
> 
> 
> Scale= 0.6098782
> 
> 
> 
> Loglik(model)= -5.3   Loglik(intercept only)= -5.3
> 
> n= 4
> 
>> library('rms')
> 
> Loading required package: Hmisc
> 
> Hmisc library by Frank E Harrell Jr
> 
> 
> 
> Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')
> 
> to see overall documentation.
> 
> 
> 
> NOTE:Hmisc no longer redefines [.factor to drop unused levels when
> 
> subsetting.  To get the old behavior of Hmisc type dropUnusedLevels().
> 
> 
> 
> 
> 
> Attaching package: 'Hmisc'
> 
> 
> 
> The following object(s) are masked from 'package:survival':
> 
> 
> 
>     untangle.specials
> 
> 
> 
> The following object(s) are masked from 'package:base':
> 
> 
> 
>     format.pval, round.POSIXt, trunc.POSIXt, units
> 
> 
> 
> 
> 
> Attaching package: 'rms'
> 
> 
> 
> The following object(s) are masked from 'package:survival':
> 
> 
> 
>     Surv
> 
> 
> 
>> Surv(left, right, type='interval2') # error
> 
> Error in Surv(left, right, type = "interval2") :
> 
>   argument "event" is missing, with no default
> 
>> args(Surv)
> 
> function (time, time2, event, type = c("right", "left", "interval",
> 
>     "counting", "interval2"), origin = 0)
> 
> NULL
> 
>> psm(Surv(left, right, type='interval2') ~ 1) # same error (of course)
> 
> Error in Surv(left, right, type = "interval2") :
> 
>   argument "event" is missing, with no default
> 
>> psm(survival::Surv(left, right, type='interval2') ~ 1) # runs
> 
> 
> 
> Parametric Survival Model: Weibull Distribution
> 
> 
> 
> psm(formula = survival::Surv(left, right, type = "interval2") ~
> 
>     1)
> 
> 
> 
>                 Model Likelihood    Discrimination
> 
>                    Ratio Test          Indexes
> 
> Obs        4    LR chi2     0.00    R2       0.000
> 
> Events     6    d.f.           0    g        0.000
> 
> sigma 0.6099                        gr       1.000
> 
> 
> 
>             Coef    S.E.   Wald Z Pr(>|Z|)
> 
> (Intercept)  1.3179 0.3598  3.66  0.0002
> 
> Log(scale)  -0.4945 0.5977 -0.83  0.4081
> 
> 
> 
> **********************************************************
> Electronic Mail is not secure, may not be read every day, and should not
> be used for urgent or sensitive issues 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________

> R-help@

>  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.





-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/Does-psm-Surv-handle-interval2-data-tp4655472p4655475.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list