# R-commands for additve regression # ================================= # 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. # We first estimate the marginal effect sex: fit.sex=aareg(Surv(lifetime,status==1)~factor(sex),data=melanoma) par(mfrow=c(1,2)) plot(fit.sex) # Here the estimated cumulative baseline equals the Nelson-Aalen estimate for females # while the estimated cumulative regression function for sex equals the difference # between the Nelson-Aalen estimates for males and females (exercise 4.4) # We will also look at the marginal effect tumor thickness. # First we center the thickness values by subtracting their means # (since that will make the cumulative baseline more meaningful) melanoma$cthick=melanoma$thickn-mean(melanoma$thickn) fit.thick=aareg(Surv(lifetime,status==1)~cthick,data=melanoma) par(mfrow=c(1,2)) plot(fit.thick) # Here the cumulative baseline corresponds to the hazard for an individual with mean tumor thickness (=2.92 mm), # while the cumulative regression function shows the effect of 1 med mer increase in tumor thickness. # We see that there is a clear effect of thickness the first 5 years or so, but not later on. # Finally we fit a model with sex, ulceration anf thickness (centered) fit.all=aareg(Surv(lifetime,status==1)~factor(sex)+factor(ulcer)+cthick,data=melanoma) par(mfrow=c(2,2)) plot(fit.all) # Here the cumulative baseline corresponds to the cumulative hazard of a female with ulceration and mean tumor thickness (=2.92 mm). # The other cumulative regression functions show # - the effect of being a male (compared to a female), # - of not having ulcetation (compared to having it) # - of 1 mm increase of tumor thickness # To test the if the covariates have an effect, we give the command: print(fit.all) # The TST test statistic (cf top of page 165 in the ABG-book) is given in the second last column # of the out put, with the corresponding p-value in the last column # (we only consider the last two columns of the output) # We see that ulcetarion is higly significant, that thickness is significant (p-value 2.9%), # and that sex is not significant (p-value 12.1%)