R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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(198,153,150,148,147,138,137,136,136,135,130,129,127,126,126,122,121,121,121,120,118,118,116,116,115,112,112,112,111,111,110,108,107,107,107,106,106,104,104,104,103,103,103,102,102,101,101,100,99,99,97,97,96,95,95,94,94,91,91,90,90,90,89,89,89,87,87,87,87,86,86,86,86,86,85,85,84,84,84,83,82,82,82,80,79,79,79,79,79,78,77,76,75,74,74,73,72,72,72,72,71,71,71,70,69,69,69,68,67,66,66,65,65,65,65,64,63,63,63,61,60,60,60,58,58,56,56,55,55,54,51,50,50,42,41,40,38,36,28,25,22,20,20,18,17,13,12,11,9,9,7,7,6,6,5,2,0,0,0,0,0,0,0,0) > x <- c(182,110,162,155,141,165,101,152,127,128,121,112,142,164,156,161,176,152,155,85,164,155,88,145,122,161,150,132,171,118,96,114,140,139,184,121,139,140,146,148,112,146,126,169,75,83,163,180,181,168,94,114,107,152,186,118,133,90,127,87,121,103,50,134,89,84,163,50,98,96,123,104,122,124,128,123,76,85,121,88,116,137,66,136,159,102,110,104,107,158,126,83,48,97,63,131,93,97,105,88,89,95,70,81,107,84,129,77,134,84,58,69,93,166,40,102,97,75,67,81,146,103,48,63,147,70,64,77,146,103,63,126,41,65,30,35,56,37,30,20,49,8,22,21,23,12,13,16,18,1,12,8,4,4,0,7,0,0,0,0,0,0,0,0) > par8 = 'terrain.colors' > par7 = 'Y' > par6 = 'Y' > par5 = '0' > par4 = '0' > par3 = '0' > par2 = '50' > par1 = '50' > ylab = 'H' > xlab = 'B' > main = 'Bivariate Kernel Density' > par8 <- 'terrain.colors' > par7 <- 'Y' > par6 <- 'Y' > par5 <- '0' > par4 <- '0' > par3 <- '0' > par2 <- '50' > par1 <- '50' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P. (2012), Bivariate Kernel Density Estimation (v1.0.9) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/Ian.Holliday/rwasp_bidensity.wasp/ > #Source of accompanying publication: > # > 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.23 loaded Copyright M. P. Wand 1997-2009 > x <- x[!is.na(y)] > y <- y[!is.na(y)] > y <- y[!is.na(x)] > x <- x[!is.na(x)] > 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 > if (par8 == 'terrain.colors') mycol <- terrain.colors(100) > if (par8 == 'rainbow') mycol <- rainbow(100) > if (par8 == 'heat.colors') mycol <- heat.colors(100) > if (par8 == 'topo.colors') mycol <- topo.colors(100) > if (par8 == 'cm.colors') mycol <- cm.colors(100) > postscript(file="/var/wessaorg/rcomp/tmp/15s2y1340193844.ps",horizontal=F,onefile=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=mycol, 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 16.3254 0.6251 > abline(r) > box() > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/2958x1340193844.tab") > > try(system("convert tmp/15s2y1340193844.ps tmp/15s2y1340193844.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 10.417 0.424 10.869