R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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. > x <- c(9700,9081,9084,9743,8587,9731,9563,9998,9437,10038,9918,9252,9737,9035,9133,9487,8700,9627,8947,9283,8829,9947,9628,9318,9605,8640,9214,9567,8547,9185,9470,9123,9278,10170,9434,9655,9429,8739,9552,9687,9019,9672,9206,9069,9788,10312,10105,9863,9656,9295,9946,9701,9049,10190,9706,9765,9893,9994,10433,10073,10112,9266,9820,10097,9115,10411,9678,10408,10153,10368,10581,10597,10680,9738,9556) > par3 = '512' > par2 = 'no' > par1 = '0' > ylab = 'Density' > xlab = 'Value' > par3 <- '512' > par2 <- 'no' > par1 <- '0' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa, P. (2012), Kernel Density Estimation (v1.0.11) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_density.wasp/ > #Source of accompanying publication: http://www.xycoon.com/density_trace.htm > # > if (par1 == '0') bw <- 'nrd0' > if (par1 != '0') bw <- as.numeric(par1) > par3 <- as.numeric(par3) > mydensity <- array(NA, dim=c(par3,8)) > postscript(file="/var/fisher/rcomp/tmp/118tk1354369262.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > mydensity1<-density(x,bw=bw,kernel='gaussian',na.rm=TRUE) > mydensity[,8] = signif(mydensity1$x,3) > mydensity[,1] = signif(mydensity1$y,3) > plot(mydensity1,main='Gaussian Kernel',xlab=xlab,ylab=ylab) > grid() > dev.off() null device 1 > mydensity1 Call: density.default(x = x, bw = bw, kernel = "gaussian", na.rm = TRUE) Data: x (75 obs.); Bandwidth 'bw' = 190.9 x y Min. : 7974 Min. :4.556e-07 1st Qu.: 8794 1st Qu.:5.602e-05 Median : 9614 Median :2.490e-04 Mean : 9614 Mean :3.047e-04 3rd Qu.:10433 3rd Qu.:5.470e-04 Max. :11253 Max. :7.622e-04 > postscript(file="/var/fisher/rcomp/tmp/2vo7q1354369262.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > mydensity2<-density(x,bw=bw,kernel='epanechnikov',na.rm=TRUE) > mydensity[,2] = signif(mydensity2$y,3) > plot(mydensity2,main='Epanechnikov Kernel',xlab=xlab,ylab=ylab) > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/3hx8z1354369262.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > mydensity3<-density(x,bw=bw,kernel='rectangular',na.rm=TRUE) > mydensity[,3] = signif(mydensity3$y,3) > plot(mydensity3,main='Rectangular Kernel',xlab=xlab,ylab=ylab) > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/4hrvw1354369262.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > mydensity4<-density(x,bw=bw,kernel='triangular',na.rm=TRUE) > mydensity[,4] = signif(mydensity4$y,3) > plot(mydensity4,main='Triangular Kernel',xlab=xlab,ylab=ylab) > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/5u4hg1354369262.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > mydensity5<-density(x,bw=bw,kernel='biweight',na.rm=TRUE) > mydensity[,5] = signif(mydensity5$y,3) > plot(mydensity5,main='Biweight Kernel',xlab=xlab,ylab=ylab) > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/6vuef1354369262.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > mydensity6<-density(x,bw=bw,kernel='cosine',na.rm=TRUE) > mydensity[,6] = signif(mydensity6$y,3) > plot(mydensity6,main='Cosine Kernel',xlab=xlab,ylab=ylab) > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/7do4a1354369262.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > mydensity7<-density(x,bw=bw,kernel='optcosine',na.rm=TRUE) > mydensity[,7] = signif(mydensity7$y,3) > plot(mydensity7,main='Optcosine Kernel',xlab=xlab,ylab=ylab) > grid() > dev.off() null device 1 > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Properties of Density Trace',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Bandwidth',header=TRUE) > a<-table.element(a,mydensity1$bw) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'#Observations',header=TRUE) > a<-table.element(a,mydensity1$n) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/fisher/rcomp/tmp/8lm3b1354369263.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Maximum Density Values',3,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Kernel',1,TRUE) > a<-table.element(a,'x-value',1,TRUE) > a<-table.element(a,'max. density',1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Gaussian',1,TRUE) > a<-table.element(a,mydensity1$x[mydensity1$y==max(mydensity1$y)],1) > a<-table.element(a,mydensity1$y[mydensity1$y==max(mydensity1$y)],1) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Epanechnikov',1,TRUE) > a<-table.element(a,mydensity2$x[mydensity2$y==max(mydensity2$y)],1) > a<-table.element(a,mydensity2$y[mydensity2$y==max(mydensity2$y)],1) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Rectangular',1,TRUE) > a<-table.element(a,mydensity3$x[mydensity3$y==max(mydensity3$y)],1) > a<-table.element(a,mydensity3$y[mydensity3$y==max(mydensity3$y)],1) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Triangular',1,TRUE) > a<-table.element(a,mydensity4$x[mydensity4$y==max(mydensity4$y)],1) > a<-table.element(a,mydensity4$y[mydensity4$y==max(mydensity4$y)],1) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Biweight',1,TRUE) > a<-table.element(a,mydensity5$x[mydensity5$y==max(mydensity5$y)],1) > a<-table.element(a,mydensity5$y[mydensity5$y==max(mydensity5$y)],1) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Cosine',1,TRUE) > a<-table.element(a,mydensity6$x[mydensity6$y==max(mydensity6$y)],1) > a<-table.element(a,mydensity6$y[mydensity6$y==max(mydensity6$y)],1) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Optcosine',1,TRUE) > a<-table.element(a,mydensity7$x[mydensity7$y==max(mydensity7$y)],1) > a<-table.element(a,mydensity7$y[mydensity7$y==max(mydensity7$y)],1) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/fisher/rcomp/tmp/9zel21354369263.tab") > if (par2=='yes') { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Kernel Density Values',8,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'x-value',1,TRUE) + a<-table.element(a,'Gaussian',1,TRUE) + a<-table.element(a,'Epanechnikov',1,TRUE) + a<-table.element(a,'Rectangular',1,TRUE) + a<-table.element(a,'Triangular',1,TRUE) + a<-table.element(a,'Biweight',1,TRUE) + a<-table.element(a,'Cosine',1,TRUE) + a<-table.element(a,'Optcosine',1,TRUE) + a<-table.row.end(a) + for(i in 1:par3) { + a<-table.row.start(a) + a<-table.element(a,mydensity[i,8],1,TRUE) + for(j in 1:7) { + a<-table.element(a,mydensity[i,j],1) + } + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/fisher/rcomp/tmp/10llbx1354369263.tab") + } > > try(system("convert tmp/118tk1354369262.ps tmp/118tk1354369262.png",intern=TRUE)) character(0) > try(system("convert tmp/2vo7q1354369262.ps tmp/2vo7q1354369262.png",intern=TRUE)) character(0) > try(system("convert tmp/3hx8z1354369262.ps tmp/3hx8z1354369262.png",intern=TRUE)) character(0) > try(system("convert tmp/4hrvw1354369262.ps tmp/4hrvw1354369262.png",intern=TRUE)) character(0) > try(system("convert tmp/5u4hg1354369262.ps tmp/5u4hg1354369262.png",intern=TRUE)) character(0) > try(system("convert tmp/6vuef1354369262.ps tmp/6vuef1354369262.png",intern=TRUE)) character(0) > try(system("convert tmp/7do4a1354369262.ps tmp/7do4a1354369262.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.720 0.965 4.681