ewcdf: Weighted Empirical Cumulative Distribution Function

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/ewcdf.R

Description

Compute a weighted version of the empirical cumulative distribution function.

Usage

1
ewcdf(x, weights = rep(1/length(x), length(x)))

Arguments

x

Numeric vector of observations.

weights

Numeric vector of non-negative weights for x.

Details

This is a modification of the standard function ecdf allowing the observations x to have weights.

The weighted e.c.d.f. (empirical cumulative distribution function) Fn is defined so that, for any real number y, the value of Fn(y) is equal to the total weight of all entries of x that are less than or equal to y. That is Fn(y) = sum(weights[x <= y]).

Thus Fn is a step function which jumps at the values of x. The height of the jump at a point y is the total weight of all entries in x number of tied observations at that value. Missing values are ignored.

If weights is omitted, the default is equivalent to ecdf(x) except for the class membership.

The result of ewcdf is a function, of class "ewcdf", inheriting from the classes "ecdf" and "stepfun". The class ewcdf has methods for print and quantile. The inherited class ecdf has methods for plot and summary.

Value

A function, of class "ewcdf", inheriting from "ecdf" and "stepfun".

Author(s)

\spatstatAuthors

.

See Also

ecdf.

quantile.ewcdf

Examples

1
2
3
   x <- rnorm(100)
   w <- runif(100)
   plot(ewcdf(x,w))

Example output

Loading required package: nlme
Loading required package: rpart

spatstat 1.51-0       (nickname: 'Poetic Licence') 
For an introduction to spatstat, type 'beginner' 

spatstat documentation built on Aug. 4, 2018, 1:04 a.m.