[R] problem concernig Survsplit, package survival

David Winsemius dwinsemius at comcast.net
Sun Aug 21 17:00:09 CEST 2016


> On Aug 20, 2016, at 1:31 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:
> 
> Your link did not take me to the code you reference... Google does not make entire books available online which may have something to do with my difficulty.  This is one reason the Posting Guide asks you to post a self-contained, reproducible example. Your use of HTML format in your posting to the list was also a making it hard to follow. 
> 
> I did find a ZIP file at [1], and the arguments do not conform to the survSplit documentation. Since I have not been a user of this package over time, I don't know whether this is due to changes in the argument list or a simple error on the part of the author... but I suspect the latter because the missing formula specification seems intrinsic to the intent of the function. 
> 
> Someone else may chime in with a more conclusive comment, but I would recommend finding a different tutorial on the topic, or corresponding with Mr.Wollschlaeger.
> 
> [1] http://www.dwoll.de/r/gddmr/wollschlaeger_r_all.zip

I'm not posing as having conclusive knowledge about the history of survSplit. (I did look at survival package's NEWS file and could not find an answer to when the syntax might have changed. I'm guessing its been that way for at least 9 years, since that seems to be how far back the NEWS file covers.)

The survival.Rdata file in that already has both a dfSurv and a dfSurvCP which explains the possibility of seeing the head of that second object despite an error during an effort at creation.

It is possible to construct a new dfSurvCP by fixing the error that Jeff points out (a non-formula argument):

dfSurvCP <- survSplit( Surv(obsT,status) ~ . , data=dfSurv, cut=seq(30, 90, by=30), end="obsT",
                      event="status", start="start", id="ID", zero=0)

You then get no error and the results agree with the provided dataset:

> head(dfSurvCP[idxOrd, ], n=7)
  sex          X IV Xcut ID start obsT status
1   f -1.3130607  A   lo  1     0   30      0
2   f -1.3130607  A   lo  1    30   60      0
3   f -1.3130607  A   lo  1    60   63      1
4   m -0.1384786  A   lo  2     0   25      1
5   m -0.3846335  A   lo  3     0   30      0
6   m -0.3846335  A   lo  3    30   60      0
7   m -0.3846335  A   lo  3    60   73      1

The cited text does not appear to be focussed on survival analysis but rather "data management" (my non-German speaker's guesswork translation of the title "Grundlagen der Datenanalyse mit R" since I read "Grundlagen" as "ground layer" , i.e "Foundations")

Hope this helps;
David.


> -- 
> Sent from my phone. Please excuse my brevity.
> 
> On August 19, 2016 4:21:31 AM PDT, "Vinzenz Völkel via R-help" <r-help at r-project.org> wrote:
>> Dear R-help-community,
>> 
>> 
>> 
>> I hope, that�s the appropiate channel to post a quastion?
>> 
>> 
>> 
>> For some days I have been struggling with a problem concerning the
>> �survSplit�-function of the package �survival�. Searching the internet
>> I
>> have found a pretty good -German- description of Daniel Wollschl�ger
>> describing how to use survSplit:
>> 
>> 
>> 
>> (https://books.google.de/books?id=9G4oBgAAQBAJ
>> <https://books.google.de/books?id=9G4oBgAAQBAJ&pg=PA345&lpg=PA345&dq=daniel+
>> wollschl%C3%A4ger+survsplit&source=bl&ots=ajPgInB83d&sig=noQIAXMWe6oQJ-LwsTC
>> kroWdwHQ&hl=de&sa=X&ved=0ahUKEwiqwoX8q83OAhVlM5oKHSMGDrEQ6AEIHjAA#v=onepage&
>> q=daniel%20wollschl%C3%A4ger%20survsplit&f=false>
>> &pg=PA345&lpg=PA345&dq=daniel+wollschl%C3%A4ger+survsplit&source=bl&ots=ajPg
>> InB83d&sig=noQIAXMWe6oQJ-LwsTCkroWdwHQ&hl=de&sa=X&ved=0ahUKEwiqwoX8q83OAhVlM
>> 5oKHSMGDrEQ6AEIHjAA#v=onepage&q=daniel%20wollschl%C3%A4ger%20survsplit&f=fal
>> se
>> 
>> 
>> 
>> Mr. Wollschl�ger also provides the dataset, all of the code he used and
>> an
>> excerpt of his output:
>> 
>> 
>> 
>> 
>> 
>>> library(survival) # f�r survSplit()
>> 
>>> dfSurvCP <- survSplit(dfSurv, cut=seq(30, 90, by=30), end="obsT",
>> 
>> + event="status", start="start", id="ID", zero=0)
>> 
>> # sortiere nach Beobachtungsobjekt und linken Intervallgrenzen
>> 
>>> idxOrd <- order(dfSurvCP$ID, dfSurvCP$start)
>> 
>>> head(dfSurvCP[idxOrd, ], n=7)
>> 
>> obsT    status sex      X                     IV        start     ID
>> 
>> 1          30        0          f           -1.3130607     A         0
>> 1
>> 
>> 181      60        0          f           -1.3130607     A         30
>> 1
>> 
>> 361      63        1          f           -1.3130607     A         60
>> 1
>> 
>> 10        11        1          f           -1.2282824     A         0
>> 10
>> 
>> 100      27        1          m         -0.1018403     B         0
>> 100
>> 
>> 101      30        0          m         -0.4079027     B         0
>> 101
>> 
>> 281      42        1          m         -0.4079027     B         30
>> 101
>> 
>> 
>> 
>> 
>> 
>> Unfortunaltely when I tried to copy Mr. Wollschl�gers operations using
>> his
>> very dataset, RStudio just returned the following error-message:
>> 
>> 
>> 
>>> dfSurvCP2 <-
>> survSplit(dfSurv,cut=seq(30,90,by=30),end="obsT",event="status",start="start
>> ",id="ID",zero=0)
>> 
>> Error in formula.default(eval(parse(text = x, keep.source =
>> FALSE)[[1L]])) :
>> 
>> 
>> invalid formula
>> 
>> 
>> 
>> I tried to figure out what�s wrong, but so far didn�t find any
>> solutions� I
>> would be very glad if anyone could help me out here.
>> 
>> 
>> 
>> vhfv
>> 
>> 
>> 
>> 
>> 	[[alternative HTML version deleted]]
>> 
>> 
>> 
>> ------------------------------------------------------------------------
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list