Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ewcdf

Weighted Empirical Cumulative Distribution Function


Description

Compute a weighted version of the empirical cumulative distribution function.

Usage

ewcdf(x, weights = NULL, normalise=TRUE, adjust=1)

Arguments

x

Numeric vector of observations.

weights

Optional. Numeric vector of non-negative weights for x. Defaults to equal weight 1 for each entry of x.

normalise

Logical value indicating whether the weights should be rescaled so that they sum to 1.

adjust

Numeric value. Adjustment factor. The weights will be multiplied by adjust.

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" (if normalise=TRUE) and "stepfun". The class ewcdf has methods for print and quantile. The inherited classes ecdf and stepfun have methods for plot and summary.

Value

A function, of class "ewcdf", inheriting from "ecdf" (if normalise=TRUE) and "stepfun".

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk.

See Also

Examples

x <- rnorm(100)
   w <- runif(100)
   plot(e <- ewcdf(x,w))
   e

spatstat.geom

Geometrical Functionality of the 'spatstat' Family

v2.1-0
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Tilman Davies [ctb], Ute Hahn [ctb], Abdollah Jalilian [ctb], Sebastian Meyer [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Waagepetersen [ctb]
Initial release
2021-04-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.