(Ted Harding) Ted.Harding at manchester.ac.uk
Wed Mar 25 22:20:31 CET 2009

On 25-Mar-09 21:01:49, Mandro Litt wrote:
> Hi,
> I'm bit confused about ecdf (read the help files but still not
> but want to get the empirical cdf. How do I use this analytical
> expression with ecdf?
>
> If this helps make it concrete, the pdf is:
>
> f(u) = \sum_{t = 1}^T 1/n_t \sum_{i = 1}^{n_t} 1/w K((u - u_{it})/w)
>
> where K = kernel density estimator, w = weights, and u_{it} = data.
>
> Thank you!
> ML

Possibly you first need to be clear about why you need the ECDF,
and at what values of t you need it.

The ECDF is defined for series of values of t. These might be
simply the values in your data, in which case it would be ecdf(u)
where u is the vector of data. It is intended as an estimate,
from the data, of the CDF of the distribution that the data
came from. It basically counts the number of data less than or
equal to a given value, and divides by the total number of data.

Using ecdf() on the values of your estimated density function
would not make a lot of sense.

However, you can base an estimate of the CDF on your kernel
estimate of the density by evaluating at a chosen (finely
distributed) set of u-values, say u1 = 0.01*(-500,500),
and then

ECDF <- cumsum(f(u1))/sum(f(u1))

where f(u) is an implementation, as an R function, of your
expression above.

Hoping this helps,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 25-Mar-09                                       Time: 21:20:26
------------------------------ XFMail ------------------------------