Example: barber

A package for survival analysis in R

ApackageforsurvivalanalysisinRTerryThern eauJanuary9,2023 Contents1 Intro e,oneeventp ersub e,oneeventp ersub esandmultipleeventsp ersub o eganin1985inconnectionwiththeanalysisofm edicalresearchdata,withoutanyrealization atthetimethattheworkwouldb ,thesoftwarewasplacedontheStatlibrep 'thavealistofthedates version2wasthe rsttomakeuseoftheprintmetho dthatwasintro ducedin`NewS'in1988, orateddirectlyinS-Plus,andfromthereitb ectthatoneoftheprimaryreasonsforthepacka ge'ssuccessisthatallofthefunctionshaveb eenwrittentosolverealanalysisquestionsth atarosefromrealdatasets; jormedicalcenter,thecentralfo cusofmydepartmentistoadvancemedicine;sta tisticsisato ,therearemanyotherRpackagesthatbuildonor extendthesurvivalpackage,andanyoneworkin ginthe eld(theauthorincluded)canexp ecomeasp jorgoals. Makemulti-statecurvesandmo delsaseasytouseasanordinaryKaplan-Meiera ndCoxmo del.

Data set creation survSplit break a survival data set into disjoint portions of time tmerge create survival data sets with time-dependent covariates and/or multiple events survcheck sanity checks for survival data sets 1.4 Mathematical Notation We start with some mathematical background and notation, simply because it will be used later.

Tags:

  Survival

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of A package for survival analysis in R

1 ApackageforsurvivalanalysisinRTerryThern eauJanuary9,2023 Contents1 Intro e,oneeventp ersub e,oneeventp ersub esandmultipleeventsp ersub o eganin1985inconnectionwiththeanalysisofm edicalresearchdata,withoutanyrealization atthetimethattheworkwouldb ,thesoftwarewasplacedontheStatlibrep 'thavealistofthedates version2wasthe rsttomakeuseoftheprintmetho dthatwasintro ducedin`NewS'in1988, orateddirectlyinS-Plus,andfromthereitb ectthatoneoftheprimaryreasonsforthepacka ge'ssuccessisthatallofthefunctionshaveb eenwrittentosolverealanalysisquestionsth atarosefromrealdatasets; jormedicalcenter,thecentralfo cusofmydepartmentistoadvancemedicine;sta tisticsisato ,therearemanyotherRpackagesthatbuildonor extendthesurvivalpackage,andanyoneworkin ginthe eld(theauthorincluded)canexp ecomeasp jorgoals. Makemulti-statecurvesandmo delsaseasytouseasanordinaryKaplan-Meiera ndCoxmo del.

2 Deep ersupp ortforabsoluteriskestimates. Consistentuseofrobustvarianceestimates. endentpackagesin2019,notcountingBio conductor,otherguidinglightsofthechangea re Wecan'tdoeverything(sodon'ttry). cumentationofalloftheresultsthatarepro duced,theuseofsimpleS3ob jectsthatareeasytomanipulate, ,concordanceandconcordancefit;theformeri stheuserfrontendandthelatterdo ,whileacceptingthep enaltyoffewererrorchecks. Don'tmessitup!Thismeantpreservingthecurr entargumentnamesasmuchasp jorchangesaretocollapsemanyofvignettesin tothissinglelargeone,andtheparallelcreat ionofanactualb o cumentationisanongoingpro cess,andtherearestillthingsthepackagecan dowhicharenotwelldescrib ,we' o ok's(eventual)app earancethisvignettecanalsob emorebrief, earallatonce,however;itwilltakesometimet ogetallofthedo :timefromchemotherapytotumorrecurrence,t hedurabilityofajointreplacement,recurren tlunginfectionsinsub jectswithcystic brosis,theapp earanceofhyp ertension,hyp erlipidemiaandothercomorbiditiesofage,an dofcoursedeathitself,fromwhichtheoverall lab elof survival ittakestimetoobservetime , , :ifaparticularsub jectwasenrolledinastudy2yearsago,andhasn otyethadaneventatthetimeofanalysis,weonl yknowthattheirtimetoeventis> ort5yearsurvival,say,fromatreatment,pati entsneedtob eenrolledandthenfollowedfor5+ nished,analysisdone,therep ort nallypublishedthetreatmentinquestionmigh tb e8yearsoldandconsideredtob etweenearlyrep (ti, i)wheretisthetimeuntilendp ointorlastfollow-up,and isa0/1variablewith0= sub jectwascensoredatt and1= sub jecthadaneventatt ,orinRco deasSurv(time, status).

3 Thestatusvariablecanb elogical, ,vtype=='death' :Fourmultipleeventmo cessasisshownin erleftpanelissimplesurvivalwithtwostates ofaliveanddead, classic eatedeventsofthesametyp e(upp erright)comp etingrisksforsub jectsonalivertransplantwaitinglist(lower left)andtheillness-deathmo del(lowerright).Inthisapproachinterestno rmallycentersonthetransitionratesorhazar ds(arrows)fromstatetostate(b oxtob ox).Forsimplesurvivalthetwomultistate/ha zardandthetime-to-eventviewp ointsareequivalent,andwewillmovefreelyb etweenthem, ,usewhicheverviewp gurealsodisplaysa2by2divisionofsurvivald atasets,onethatwillb eusedtoorganizeothersubsectionsofthisdo ersub jectp ersub jectOneeventtyp e12 Multipleeventtyp elowispurp delingfunctionsitwillprovideago o ,justskimthesectiontogetanoverviewofthet yp eofcomputationsavailablefromthispackage, ()Apackagingfunction;likeI()itdo esn' Surv(time, status) rightcensoreddata Surv(time, endpoint=='death') rightcensoreddata,wherethestatusvariable isacharacterorfactor Surv(t1, t2, status) countingpro cessdata Surv(t1, ind, type='left') leftcensoring Surv(time, fstat multiplestatedata,fstatisafactoraaregAal en'sadditiveregressionmo del.)

4 Thetimeregpackageisamuchmorecomprehensiv eimplementationoftheAalenmo del,sothisdo cumentwillsaylittleab outaaregcoxph()Cox'sprop ortionalhazardsmo del. coxph(Surv(time, status) x, data=aml) standardCoxmo del coxph(Surv(t1, t2, stat) (age + surgery)* transplant) timedep endentcovariates. y <- Surv(t1, t2, stat)coxph(y strata(inst) * sex + age + treat) Strati edmo del,withasepa-ratebaselinep erinstitution,andinstitutionsp eci ce coxph(y offset(x1) + x2) forceinaknownterm,withoutestimatingaco ef- ortionalhazardsforthe ttedCoxmo del. zfit <- (coxfit); plot(zfit)pyearsPerson-yearsanalysissurv di Oneandk-sampleversionsoftheFleming-Harri ngtonG ecialcases.

5 Survdiff(Surv(time, status) sex + treat) Comparethe4sub-groupsformedbysexandtreat mentcombinations. survdiff(Surv(time, status) offset(pred))-One-sampletestsurvexpPredi ctedsurvivalforanageandsexmatchedcohorto fsub jects,givenabaselinematrixofknownhazardr atesforthep ,butwehavealsousedlo caltablesforstrokerates. survexp( , , sex) DefaultstoUSwhite,averagecohortsurvival pred <- survexp(entry, birth, sex, futime, type='individual')Datatoen-terintoaonesa mpletestforcomparingthegivengrouptoaknow np tFitasurvivalcurve. survfit(Surv(time, status)) SimpleKaplan-Meier survfit(Surv(time, status) rx + sex) Fourgroups fit <- coxph(Surv(time, stat) rx + sex)survfit(fit, list(rx=1, sex=2)) PredictcurvsurvregParametricsurvivalmo dels.

6 Survreg(Surv(time, stat) x, dist='loglogistic') survSplitbreakasurvivaldatasetintodisjoi ntp ortionsoftime tmergecreatesurvivaldatasetswithtime-dep endentcovariatesand/ormultipleevents ,simplyb ecauseitwillb ,intimetoeventanalysisagivensub jectwillonlyb eunderobservationforasp eci erienceafteracertaintreatment,thenapatie ntrecruitedon7 March101990andfolloweduntilananalysisdat eofJune2000willhave10yearsofp otentialfollow-up, (t), i= 1,..,nb etheindicatorthatsub (t)b ethestepfunctionfortheithsub ject,whichcountsthenumb erof events forthatsub enmultipletimessuchasrehospitalization,o rsomethingthatonlyhapp erofeventsthathaveo ccurreduptotimetwillb eN(t) = Ni(t),andthenumb erofsub jectsatriskattimetwillb eY(t) = Yi(t).Time-dep endentcovariatesforasub jectarethevectorXi(t).Itwillalsob eusefultode ned(t)asthenumb erofdeathsthato 2 survival e,oneeventp ersub jectThemostcommondepictionofsurvivaldata istheKaplan-Meiercurve,whichisapro ductofsurvivalprobabilities: SKM(t) = s<tY(ts) d(s)Y(s).

7 ( )Graphically,theKaplan-Meiersurvivalcurv eapp + symb eaSurvob 1astherighthandside.> fit1 <- survfit(Surv(futime, fustat) ~ , data=ovarian)> print(fit1, rmean= 730)Call: survfit(formula = Surv(futime, fustat) ~ , data = ovarian)n events rmean* se(rmean) median 11 3 666 NA 638 15 9 463 464 329 NA* restricted

8 Mean with upper limit = 730> summary(fit1, times= (0:4)* , scale=365)Call: survfit(formula = Surv(futime, fustat) ~ , data = ovarian) survival lower 95% CI upper 95% 11 0 11 0

9 10 1 8 0 6 2 survival lower 95% CI upper 95%

10 15 0 12 3 10 3 4 3


Related search queries