library(Hmisc) load('~/Analyses/SUPPORT/combined.sav') combined <- subset(combined, dzclass=='ARF/MOSF', select=c(id,hospdead)) load('~/Analyses/SUPPORT/combphys.sav') combphys <- subset(combphys, !is.na(crea1+crea14), select=c(id,crea1,crea14)) w <- merge(combined, combphys, by='id') w <- upData(w, labels=c(crea1='Serum Creatinine, Day 1', crea14='Serum Creatinine Day 14'), units=c(crea1='mg/dl', crea14='mg/dl')) #ecdf(w$crea1) library(lattice) trellis.device(png, file='creatinine1.png', color=FALSE, bg='white') xYplot(crea14 ~ crea1, method='quantile', data=w, nx=100, xlim=c(0,12), ylim=c(0,12), main='Quartiles of Serum Creatinine in 2476 Patients with ARF/MOSF') dev.off() set.seed(1) a <- areg.boot(crea14 ~ crea1, data=w) png('creatinineOptimum.png') par(mfrow=c(2,2), oma=c(0,0,2,0)) plot(a, boot=FALSE) mtitle('Optimum Transformations of Serum Creatinine', cex.m=1.5) g <- Function(a)$crea14 s <- seq(.3,13,length=150) plot(log(s), g(s), xlab='log(creatinine)', ylab='Optimum Transformation', type='l') scat1d(log(w$crea14)) dev.off() f <- g s <- c(.3,.5,.8,1,1.5,2,3,4,5,6,8,12) trellis.device(png, file='creatinine2.png', color=FALSE, bg='white') xYplot(f(crea14) ~ f(crea1), method='quantile', data=w, nx=100, xlim=f(c(.3,12)), ylim=f(c(.3,12)), main='Quartiles of Serum Creatinine in 2476 Patients with ARF/MOSF', xlab='Serum Creatinine, Day 1', ylab='Serum Creatinine, Day 14', scales=list(x=list(at=f(s), labels=format(s)), y=list(at=f(s), labels=format(s)))) dev.off() png('creatinine3.png') with(w, { par(mfrow=c(1,2)) plot(.5*(crea1+crea14), crea14-crea1) plot(.5*(log(crea1)+log(crea14)), log(crea14)-log(crea1)) }) dev.off() # Not used: load('~/data/teaching/support2.sav') with(subset(support,dzclass='ARF/MOSF'), plsmo(crea, hospdead, fun=qlogis))