a_matrix(scan("diabetes.dat"),43,3,byrow=T) a_a[sort.list(a[,1]),] age_a[,1] basedef_a[,2] cpep_a[,3] lncpep_log(cpep) #Construct average kernel, loess and Supsmu curve estiamtors of #lncpep on age. par(mfrow=c(1,1)) plot(age,lncpep,ylab="ln(C_peptide)") lines(ksmooth(age,lncpep,kernel="normal",bandwidth=5),lty=1) lines(loess.smooth(age,lncpep,span=0.70,degree=1),lty=2) lines(supsmu(age,lncpep,span="cv"),lty=4) legend(7,1.3,lty=c(1,2,4),legend=c("Average Kernel (bandwidth=5)","Loess (span=0.7)", "Supsmu Loess (CV)")) title("Kernel Regerssion of ln(C_peptide) on age") #Construct Loess fit and its 95% CI par(mfrow=c(1,1)) plot(age,lncpep,ylab="ln(C_peptide)",xlab="Age",xlim=c(0,16),ylim=c(1.1,1.9)) fit_loess(lncpep~age,span=0.70,degree=1) est_preplot(fit,confidence=20,coverage=0.95) par(new=T) plot(est,ylab=" ",xlab=" ",xlim=c(0,16),ylim=c(1.1,1.9)) title("Loess fit and its 95% CI")