R version 2.7.2 (2008-08-25) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > y <- c(151.3,151.2,150.8,149.9,148.9,148,146.8,145.3,144.1,143.1,142,140.8,138.9,136.2,133.4,130.7,128.5,126.9,125.8,124.6,122.7,120.9,119.3,118,117,115.9,115.1,114.7,114.1,113.3,112.7,112.3,112.1,112.1,111.9,111.6,111.3,110.9,110.7,110.8,110.6,110,109.1,108.9,108.9,108.2,107,106,105.2,104.4,103.9,103.4,103,102.6,101.8,100.7,99.9,99.9,100.6,101) > x <- c(132.7,132.7,132.8,132.4,131.5,131,130.7,130.1,129.1,128,127,126,125,123.7,122.1,120.2,118.5,117.2,116.2,115.1,113.8,112.7,111.8,111.2,110.6,109.7,108.6,107.8,107.5,107.5,107.4,107.2,107.1,107.2,107.5,107.9,108.4,108.8,109,109,109,108.8,108.4,108.1,107.8,107.3,106.6,105.9,105.4,105.4,105.6,105.6,105.6,105.7,105.6,105.4,105.4,105.5,105.7,105.8) > par7 = 'Y' > par6 = 'Y' > par5 = '0' > par4 = '0' > par3 = '0' > par2 = '50' > par1 = '50' > ylab = 'verv. mach. en app.' > xlab = 'verv. product van met.' > main = 'Bivariate Kernel Density' > par1 <- as(par1,'numeric') > par2 <- as(par2,'numeric') > par3 <- as(par3,'numeric') > par4 <- as(par4,'numeric') > par5 <- as(par5,'numeric') > library('GenKern') Loading required package: KernSmooth KernSmooth 2.22 installed Copyright M. P. Wand 1997 Loading GenKern version 1.1 Copyright Lucy and Aykroyd 2000 last update October 2004 requires KernSmooth Package GenKern installed > if (par3==0) par3 <- dpik(x) > if (par4==0) par4 <- dpik(y) > if (par5==0) par5 <- cor(x,y) > if (par1 > 500) par1 <- 500 > if (par2 > 500) par2 <- 500 > postscript(file="/var/www/html/freestat/rcomp/tmp/16pvo1226307697.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- KernSur(x,y, xgridsize=par1, ygridsize=par2, correlation=par5, xbandwidth=par3, ybandwidth=par4) > image(op$xords, op$yords, op$zden, col=terrain.colors(100), axes=TRUE,main=main,xlab=xlab,ylab=ylab) > if (par6=='Y') contour(op$xords, op$yords, op$zden, add=TRUE) > if (par7=='Y') points(x,y) > (r<-lm(y ~ x)) Call: lm(formula = y ~ x) Coefficients: (Intercept) x -72.047 1.685 > abline(r) > box() > dev.off() null device 1 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Bandwidth',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'x axis',header=TRUE) > a<-table.element(a,par3) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'y axis',header=TRUE) > a<-table.element(a,par4) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Correlation',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'correlation used in KDE',header=TRUE) > a<-table.element(a,par5) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'correlation(x,y)',header=TRUE) > a<-table.element(a,cor(x,y)) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/freestat/rcomp/tmp/25vvg1226307697.tab") > > system("convert tmp/16pvo1226307697.ps tmp/16pvo1226307697.png") > > > proc.time() user system elapsed 1.148 0.405 1.401