[R-sig-Geo] 5-D Kernel density estimation in R using "kde" function

Frede Aakmann Tøgersen frtog at vestas.com
Fri Sep 12 07:12:52 CEST 2014


Doesn't ?kde tell you all about specifying the grid at which you want your kernel density evaluated?

>From the man page for kde:


     For d=1, if 'h' is missing, the default bandwidth is 'hpi'.  For
     d>1, if 'H' is missing, the default is 'Hpi'.

     For d=1, 2, 3, 4, and if 'eval.points' is not specified, then the
     density estimate is computed over a grid defined by 'gridsize' (if
     'binned=FALSE') or by 'bgridsize' (if 'binned=TRUE').  If
     'eval.points' is specified, then the density estimate is computed
     exactly at 'eval.points'.  For d>4, the kernel density estimate is
     computed exactly and 'eval.points' must be specified.

     For d=1, if 'positive=TRUE' then 'x<-log(x+adj.positive)' where
     the default 'adj.positive' is the minimum of 'x'.

     The effective support for a normal kernel is 'supp', i.e.  all
     values outside '[-supp,supp]^d' are set to zero.

     The default 'xmin' is 'min(x)-Hmax*supp' and 'xmax' is
     'max(x)+Hmax*supp' where 'Hmax' is the maximum of the diagonal
     elements of 'H'. The grid produced is the outer product of
     '[xmin[1], xmax[1]]', ..., '[xmin[d], xmax[d]]'.

     The default 'bgridsize, gridsize' are d=1: 401; d=2: rep(151, 2);
     d=3: rep(31, 3); d=4: rep(21,4).

Yours sincerely / Med venlig hilsen

Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
frtog at vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender. 

> -----Original Message-----
> From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-
> project.org] On Behalf Of Ferra Xu
> Sent: 11. september 2014 22:00
> To: r-sig-geo at r-project.org
> Subject: [R-sig-Geo] 5-D Kernel density estimation in R using "kde" function
>  I want to perform Kernel density estimate for a 5-dimensional data
> (x,y,z,time,size) by using "kde" function in "ks" library of R. In it's manual it
> says it can do Kernel density estimate for 1- to
> 6-dimensional data (Page 24 of manual: http://cran.r-
> project.org/web/packages/ks/ks.pdf).
> My problem is that it says for more than 3 dimensions I need to
> specify eval.points. I don't know how can I specify the evaluation
> points because there is no example for more than 3 dimensions. For
> example if I want to generate equal boxes in the 3-D rectangular space
> of the problem and specify the center of each box as the eval-point,
> what should I do?
> Here is my data:
> 422.697323164.198862.4574198.0837966360.83367586423.008236163.324340.5
> 55132637.584774550.893893903204.733908218.363651.939787437.883243120.9
> 12809449203.963056218.48080.372379143.217759030.926406005100.72758146.
> 608761.402234149.415105190.782807523453.335182244.255211.629251751.737
> 791750.903910803134.909462210.963332.238911953.134335210.896529401135.
> 300562212.020550.673954167.550737450.748783521258.237117134.297352.120
> 529176.340325870.735699304341.305271149.269533.71895894.339754830.8495
> 09216307.13892559.605710.6311074106.96367150.987923188307.7687558.9145
> 32.6496741113.85153070.802115718415.025535217.173981.7155688115.746460
> 30.875580325414.977687216.733271.7107369115.97769480.767143582311.0061
> 35173.243782.7819572120.80795660.925380118310.116929174.281224.3318722
> 129.26484010.776528535347.26091137.349463.5155427136.78512910.85178711
> 5351.31762433.657030.5806926138.73492840.9097230174.47189259.420681.40
> 62959139.05437830.9672709765.48022359.728572.7326106139.2
> 1142770.987787428199.51302321.533022.5163259143.58956250.864164659198.
> 71803123.501630.4801849147.22804660.74158733326.65051735.20190.8246514
> 150.48765060.74478820225.08937990.478250.8700944152.19440460.777252476
> 26.30743988.415522.4422487155.90900260.952215177234.282901236.114221.8
> 115261155.96581440.776284654235.052948236.774371.9644963156.69002970.9
> 4428544823.04820298.62613.4573048159.77009120.77305749121.51669598.054
> 312.5029284160.82029970.978779087213.936324151.870133.1042192161.06124
> 890.80499513277.887935197.257531.3659279163.6731420.758978575277.23974
> 6197.540012.2109361166.26298680.775325157
> And this is the code that I am using:
> library(ks)library(rgl)kern <-read.table(file.choose(),sep=",")hat <-kde(kern)
> It works for up to 3 dimensions but for 4 and 5 dimensions it says:  need to
> specify eval.points for more than 3 dimensions.
> 	[[alternative HTML version deleted]]
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

More information about the R-sig-Geo mailing list