Hi:
y <- rnorm(50)
kd <- sm.density(y, model = "Normal")
str(kd)
List of 10
$ eval.points: num [1:100] -3.79 -3.72 -3.64 -3.57 -3.5 ...
$ estimate : num [1:100] 0.00124 0.00169 0.00225 0.00295 0.00381 ...
$ h : num 0.53
$ h.weights : num [1:50] 1 1 1 1 1 1 1 1 1 1 ...
$ weights : num [1:50] 1 1 1 1 1 1 1 1 1 1 ...
$ se : num [1:100] 0.0516 0.0516 0.0516 0.0516 0.0516 ...
$ upper : num [1:100] 0.0192 0.0208 0.0227 0.0248 0.0272 ...
$ lower : num [1:100] 0 0 0 0 0 ...
$ data :List of 3
..$ x : num [1:50] -1.2577 -0.3801 -0.0751 0.9384 1.5378 ...
..$ nbins: num 0
..$ freq : num [1:50] 1 1 1 1 1 1 1 1 1 1 ...
$ call : language sm.density(x = y, model = "Normal")
Note that the first component of the list that is returned when you save the
results of sm.density() is the set of (ordered) points at which the kernel
density is evaluated and the second component, estimates, contains the
values of the estimated density at each evaluation point. Thus, to get the
density estimates, save the result of sm.density() and extract the estimate
component - in the example above, kd$estimate.
HTH,
Dennis
On Mon, Feb 7, 2011 at 2:48 PM, garciap <garciap@usal.es> wrote:
>
> Hi all (again),
>
> many thanks for the answer to the optimization problem. All is fine now.
> The
> problem now is with kernel estimators in sm. package. I do all the work and
> the graphics good, but I need the density function data for each point, and
> I don't know how to get it. The only thing I get is the table at the
end of
> the following sequence:
>
> > Kernel<-sm.density(Kernel,model="Normal")
> Loading required package: rpanel
> Loading required package: tcltk
> Loading Tcl/Tk interface ... done
> Package `rpanel', version 1.0-6
> type help(rpanel) for summary information
> Loading required package: rgl
> Loading required package: misc3d
> > summary(Kernel)
> Length Class Mode
> eval.points 60 -none- numeric
> h 3 -none- numeric
> h.weights 38 -none- numeric
> weights 38 -none- numeric
> scaling 1 -none- function
> estimate 8000 -none- numeric
> surf.ids 3 -none- numeric
> data 3 -none- list
> call 3 -none- call
> >
>
> Please can anyone help me again? Thanks
>
> Pablo
> --
> View this message in context:
> http://r.789695.n4.nabble.com/kernel-density-tp3265332p3265332.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]