资源描述:
《the r book changing the look of graphics》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、27SurvivalAnalysisAgreatmanystudiesinstatisticsdealwithdeathsorwithfailuresofcomponents:theyinvolvethenumbersofdeaths,thetimingofdeath,ortherisksofdeathtowhichdifferentclassesofindividualsareexposed.Theanalysisofsurvivaldataisamajorfocusofthestatisticsbusiness(seeKalb
2、fleischandPrentice,1980;Miller,1981;FlemingandHarrington1991),forwhichRsupportsawiderangeoftools.Themainthemeofthischapteristheanalysisofdatathattaketheformofmeasurementsofthetimetodeath,orthetimetofailureofacomponent.Uptonow,wehavedealtwithmortalitydatabyconsideringth
3、eproportionofindividualsthatweredeadatagiventime.Inthischaptereachindividualisfolloweduntilitdies,thenthetimeofdeathisrecorded(thiswillbetheresponsevariable).Individualsthatsurvivetotheendoftheexperimentwilldieatanunknowntimeinthefuture;theyaresaidtobecensored(asexpla
4、inedbelow).27.1AMonteCarloexperimentWithdataontimetodeath,themostimportantdecisiontobemadeconcernstheerrordistribution.Thekeypointtounderstandisthatthevarianceinageatdeathisalmostcertaintoincreasewiththemean,andhencestandardmodels(assumingconstantvarianceandnormalerro
5、rs)willbeinappropriate.YoucanseethisatoncewithasimpleMonteCarloexperiment.Supposethattheper-weekprobabilityoffailureofacomponentis0.1fromonefactorybut0.2fromanother.Wecansimulatethefateofanindividualcomponentinagivenweekbygeneratingauniformlydistributedrandomnumberbet
6、ween0and1.Ifthevalueoftherandomnumberislessthanorequalto0.1(or0.2forthesecondfactory),thenthecomponentfailsduringthatweekanditslifetimecanbecalculated.Iftherandomnumberislargerthan0.1(or0.2,respectively),thenthecomponentsurvivestothenextweek.Thelifetimeofthecomponenti
7、ssimplythenumberoftheweekinwhichitfinallyfailed.Thus,acomponentthatfailedinthefirstweekhasanageatfailureof1(thisconventionmeansthattherearenozerosinthedataframe).Thesimulationisverysimple.Wecreateavectorofrandomnumbers,rnos,thatislongenoughtobecertaintocontainavaluethat
8、islessthanourfailureprobabilitiesof0.1and0.2.Rememberthatthemeanlifeexpectancyisthereciprocalofthefailurerate,soourmeanlifet