欢迎来到天天文库
浏览记录
ID:38924212
大小:59.64 KB
页数:18页
时间:2019-06-21
《Statistics with R Survival Analysis》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、StatisticswithRSurvivalAnalysisScottHetzelUniversityofWisconsin–MadisonSummerInstituteforTraininginBiostatistics(2008)Derivedfrom:“IntroductoryStatisticswithR”by:PeterDalgaardandfrompreviousnotesbyDeepayanSarkar,Ph.DSurvivialAnalysisinR•Toolsareavailableinthepackagesurvival•Thisisarecommendedpackage
2、,whichmeansitshouldalreadybeinstalled•Ithastobeloadedusing>library(survival)•SurvivalAnalysisiscoveredinChapter12ofthetext1FunctionsofInterest•Createasurvivalobject:Surv•Kaplan-MeierEstimates:survfit•Thelog-ranktest:survdiff•TheCoxproportionalhazardsmodel:coxph(wewon’tbediscussingthis)2SurvivalObjec
3、ts•CreatedbytheSurvfunction•Needstwoarguments:–time:follow-uptime–event:statusindicator•event=TRUEmeanseventoccured•event=FALSEindicatescensoring•Othervaluespossible(seehelp(Surv))3Example:melanomWewillusetheexamplefromthetext:>library(ISwR)>str(melanom)'data.frame':205obs.of6variables:$no:int789139
4、716214696857932944...$status:int3323111131...$days:int10303599185204210232232279...$ulc:int1222111111...$thick:int6766513429012084845161288322741...$sex:int2221222211...Weareinterestedin:•days:timeonstudyafteroperationformalignantmelanoma•status:thepatient’sstatusattheendofstudy4CensoringIndicator•T
5、hepossiblevaluesofstatusare–1:deadfrommalignantmelanoma–2:aliveattheendofthestudy–3:deadfromothercauses•Survneedsalogicalstatusindicator(TRUEifeventoccurred,FALSEifcensored)•Let’sconsider”deadfromothercauses”ascensored•Thus,statusvectorshouldbestatus==15CreatingtheSurvivalObject>msurv<-with(melanom,
6、Surv(days,status==1))>msurv[1]10+30+35+99+185204210232232+279295[12]355+386426469493+529621629659667718[23]752779793817826+833858869872967977[34]9821041105510621075115612281252127113121427+[45]14351499+15061508+1510+1512+15161525+1542+15481557+[56]15601563+15841605+16211627+1634+1641+1641+1648+1652+
7、[67]1654+1654+16671678+1685+16901710+1710+17261745+1762+[78]1779+1787+1787+1793+1804+1812+1836+1839+1839+1854+1856+[89]1860+1864+1899+1914+1919+1920+1927+19331942+1955+1956+[100]1958+1963+1970+2005+20
此文档下载收益归作者所有