# R-commands for non-parametric tests # =================================== # For illustration we will use the melanoma data # We first read the data: melanoma=read.table("http://www.uio.no/studier/emner/matnat/math/STK4080/h12/melanoma.txt",header=T) # We use the survival library, so this has to be loaded. # To illustrate the two-sample tests, we test the null hypothesis # that females and males have the same mortality (due to melanoma) # First we use the logrank test: survdiff(Surv(lifetime,status==1)~sex,data=melanoma) # Then we try the Harrington-Fleming test with rho=1: survdiff(Surv(lifetime,status==1)~sex,data=melanoma,rho=1) # To illustrate the tests for more than two samples, # we use the logrank test to test the null hypothesis that # the mortality is the same in all thickness groups: survdiff(Surv(lifetime,status==1)~grthick,data=melanoma) # To illustrate stratified tests, we use the logrank test to # test the null hypothesis that females and males have the # same the mortality within each stratum defined by thickness group: survdiff(Surv(lifetime,status==1)~sex+strata(grthick),data=melanoma)