# PRACTICAL EXERCISE 9 # ==================== # Read the ami data: ami=read.table("http://www.uio.no/studier/emner/matnat/math/STK4080/h14/ami.txt",header=T)# We convert time to years and introduce a binary covariate for ascites # We use the survival library: library(survival) # Question a # ---------- # We fit additive regression models for one covariate at a time. # Period fit.per=aareg(Surv(days,status)~factor(per),data=ami) par(mfrow=c(1,3)) print(fit.per) plot(fit.per) # Sex fit.sex=aareg(Surv(days,status)~factor(sex), data=ami) par(mfrow=c(1,2)) print(fit.sex) plot(fit.sex) # Previous AMI fit.prev=aareg(Surv(days,status)~factor(prev), data=ami) par(mfrow=c(1,2)) print(fit.prev) plot(fit.prev) # Age (centered at the mean age of 67.5 years) ami$cage=ami$age-mean(ami$age) fit.cage=aareg(Surv(days,status)~cage, data=ami) par(mfrow=c(1,2)) print(fit.cage) plot(fit.cage) # Log10-transformed heart enzym (centered at the mean value of 2.72) ami$logenzym=log10(ami$enzym) ami$clogenzym=ami$logenzym-mean(ami$logenzym) fit.clogenzym=aareg(Surv(days,status)~clogenzym, data=ami) par(mfrow=c(1,2)) print(fit.clogenzym) plot(fit.clogenzym) # Question b # ----------- # We then fit a model with all covariates: fit.all=aareg(Surv(days,status)~factor(per)+factor(sex)+factor(prev)+cage+clogenzym, data=ami) par(mfrow=c(2,4)) print(fit.all) plot(fit.all) # First we remove sex: fit.all=aareg(Surv(days,status)~factor(per)+factor(prev)+cage+clogenzym, data=ami) par(mfrow=c(2,3)) print(fit.all) plot(fit.all) # Then we remove period: fit.all=aareg(Surv(days,status)~factor(prev)+cage+clogenzym, data=ami) par(mfrow=c(2,2)) print(fit.all) plot(fit.all) # All remaining covariates are significant, so this is our "final model"