[R] 3D density estimation with library sm - no estimate returned
Gregory Jefferis
gsxej2 at cam.ac.uk
Fri May 27 16:05:56 CEST 2005
Dear List,
I have been trying to use library sm to do density estimation on a 3D
dataset. I am using the current MacOS X binary of sm from CRAN. If I do
this on a 2D dataset, sm.density returns a list including the component
"estimate" which contains the density estimate over a uniform grid. When
doing this with 3D data, although I get a nice plot (even when I don't ask
for one), the returned list only contains the original data (see below). It
would appear that the internal function sm.density.3d is returning NULL.
Have I misunderstood what should be returned? Is this a platform specific
problem? Can someone suggest a fix or an alternative library for my
application? Very many thanks for your help,
Greg Jefferis.
> R.version
_
platform powerpc-apple-darwin7.9.0
arch powerpc
os darwin7.9.0
system powerpc, darwin7.9.0
status Patched
major 2
minor 1.0
year 2005
month 05
day 12
language R
> library(sm)
> str(sm.density(matrix(rnorm(300),ncol=3),display="none"))
List of 2
$ data:List of 3
..$ x : num [1:100, 1:3] 0.9470 -1.5112 1.0589 -0.0884 -0.1900 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:3] "" "" ""
..$ nbins: num 0
..$ freq : num [1:100] 1 1 1 1 1 1 1 1 1 1 ...
$ call: language sm.density(x = matrix(rnorm(300), ncol = 3), display =
"none")
> str(sm.density(matrix(rnorm(200),ncol=2),display="none"))
List of 10
$ eval.points: num [1:50, 1:2] -2.67 -2.57 -2.47 -2.38 -2.28 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:2] "xnew" "ynew"
$ estimate : num [1:50, 1:50] 3.76e-05 5.10e-05 7.57e-05 1.22e-04
2.05e-04 ...
$ h : Named num [1:2] 0.414 0.512
..- attr(*, "names")= chr [1:2] "" ""
$ h.weights : num [1:100] 1 1 1 1 1 1 1 1 1 1 ...
$ weights : num [1:100] 1 1 1 1 1 1 1 1 1 1 ...
$ se : num [1:50, 1:50] 0.0306 0.0306 0.0306 0.0306 0.0306 ...
$ upper : num [1:50, 1:50] 0.00454 0.00468 0.00489 0.00523 0.00571 ...
$ lower : num [1:50, 1:50] 0 0 0 0 0 0 0 0 0 0 ...
$ data :List of 3
..$ x : num [1:100, 1:2] -0.694 -0.192 0.149 -0.718 -0.357 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:2] "" ""
..$ nbins: num 0
..$ freq : num [1:100] 1 1 1 1 1 1 1 1 1 1 ...
$ call : language sm.density(x = matrix(rnorm(200), ncol = 2),
display = "none")
>
--
Gregory Jefferis, PhD and:
Research Fellow
Department of Zoology St John's College
Downing Street Cambridge
Cambridge, CB2 3EJ CB2 1TP
Tel: +44 (0)1223 336683 +44 (0)1223 339899
Fax: +44 (0)1223 336676 +44 (0)1223 337720
gsxej2 at cam.ac.uk
More information about the R-help
mailing list