a_matrix(scan("diabetes.dat"),43,3,byrow=T) age_a[,1] basedef_a[,2] cpep_a[,3] lncpep_log(cpep) par(mfrow=c(1,2)) hist(cpep,xlim=c(2,7),ylim=c(0,0.8),probability=T) title("Histogram Density Estimate of C-peptide") dencpep_ksmooth(cpep,kernel="normal",bandwidth=1) plot(dencpep,type="l",xlim=c(2,7),ylim=c(0,0.8),lty=1,xlab="C-peptide", ylab="density") title("Kernel Density Estimate of C-peptide") par(mfrow=c(1,1)) hist(cpep,xlim=c(2,7),ylim=c(0,0.8),probability=T, xlab="C-peptide",ylab="density") par(new=T) dencpep_ksmooth(cpep,kernel="normal",bandwidth=1) plot(dencpep,type="l",xlim=c(2,7),ylim=c(0,0.8),lty=1, xlab=" ",ylab=" ") par(new=T) dencpep_ksmooth(cpep,kernel="normal",bandwidth=1.5) plot(dencpep,type="l",xlim=c(2,7),ylim=c(0,0.8),lty=2, xlab=" ",ylab=" ") par(new=T) dencpep_ksmooth(cpep,kernel="normal",bandwidth=0.5) plot(dencpep,type="l",xlim=c(2,7),ylim=c(0,0.8),lty=4, xlab=" ",ylab=" ") legend(2.5,0.7,lty=c(1,2,4),legend=c("bandwidth=1", "bandwidth=1.5","bandwidth=0.5")) title("Comparison of Histogram and Kernel Density Estimates of C-peptide") par(mfrow=c(1,1)) hist(cpep,xlim=c(2,7),ylim=c(0,0.8),probability=T, xlab="C-peptide",ylab="density") par(new=T) dencpep_ksmooth(cpep,kernel="normal",bandwidth=1) plot(dencpep,type="l",xlim=c(2,7),ylim=c(0,0.8),lty=1, xlab=" ",ylab=" ") par(new=T) dencpep_ksmooth(cpep,kernel="box",bandwidth=1) plot(dencpep,type="l",xlim=c(2,7),ylim=c(0,0.8),lty=2, xlab=" ",ylab=" ") par(new=T) dencpep_ksmooth(cpep,kernel="parzen",bandwidth=1) plot(dencpep,type="l",xlim=c(2,7),ylim=c(0,0.8),lty=4, xlab=" ",ylab=" ") legend(2.5,0.7,lty=c(1,2,4),legend=c("K(.)=normal", "K(.)=box","K(.)=parzen")) title("Comparison of Kernel Density Estimates of C-peptide with Different Kernel Functions")