[R] help--kernel distribution dynamics

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Aug 23 21:45:44 CEST 2003


As a possible enhancement, I would think about using the same bandwidth at 
all the time points --- indeed I would probably start by looking at a few 
time points, playing with the bandwidth and then using e.g. persp on 
density estimates at all 50 time points with that bandwidth.

> As a first step, you could create a matrix (with 50 rows, one for each time 
> point) where each row holds the kernel density estimate for that time point. 
> e.g. (with a grid of size 100 for each estimated density),
> 
> foo <- matrix(0, 50, 100)
> for (i in 1:50) 
>     foo[i, ] <- density(rnorm(5000), from = -4, to = 4, n = 100)$y
>                         ^^^^^^^^^^^        ^^^^^^^^^^^
>                          put your        put appropriate 
>                        variable here          ranges

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list