Learn R Programming

actuar (version 2.0-0)

ogive: Ogive for Grouped Data

Description

Compute a smoothed empirical distribution function for grouped data.

Usage

ogive(x, ...)
"ogive"(x, y = NULL, breaks = "Sturges", nclass = NULL, ...)
"ogive"(x, ...)
"print"(x, digits = getOption("digits") - 2, ...)
"summary"(object, ...)
"knots"(Fn, ...)
"plot"(x, main = NULL, xlab = "x", ylab = "F(x)", ...)

Arguments

x
for the generic and all but the default method, an object of class "grouped.data"; for the default method, a vector of individual data if y is NULL, a vector of group boundaries otherwise.
y
a vector of group frequencies.
breaks, nclass
arguments passed to grouped.data; used only for individual data (when y is NULL).
digits
number of significant digits to use, see print.
Fn, object
an R object inheriting from "ogive".
main
main title.
xlab, ylab
labels of x and y axis.
...
arguments to be passed to subsequent methods.

Value

For ogive, a function of class "ogive", inheriting from the "function" class.

Details

The ogive is a linear interpolation of the empirical cumulative distribution function.

The equation of the ogive is $$G_n(x) = \frac{(c_j - x) F_n(c_{j - 1}) + (x - c_{j - 1}) F_n(c_j)}{c_j - c_{j - 1}}$$ for $c[j-1] < x

References

Klugman, S. A., Panjer, H. H. and Willmot, G. E. (1998), Loss Models, From Data to Decisions, Wiley.

See Also

grouped.data to create grouped data objects; quantile.grouped.data for the inverse function; approxfun, which is used to compute the ogive; stepfun for related documentation (even though the ogive is not a step function).

Examples

Run this code
## Most common usage: create ogive from grouped data object.
Fn <- ogive(gdental)
Fn
summary(Fn)
knots(Fn)                      # the group boundaries

Fn(knots(Fn))                  # true values of the empirical cdf
Fn(c(80, 200, 2000))           # linear interpolations

plot(Fn)                       # graphical representation

## Alternative 1: create ogive directly from individual data
## without first creating a grouped data object.
ogive(dental)                  # automatic class boundaries
ogive(dental, breaks = c(0, 50, 200, 500, 1500, 2000))

## Alternative 2: create ogive from set of group boundaries and
## group frequencies.
cj <- c(0, 25, 50, 100, 250, 500, 1000)
nj <- c(30, 31, 57, 42, 45, 10)
ogive(cj, nj)

Run the code above in your browser using DataLab