Learn R Programming

spatstat.geom (version 3.2-5)

quantilefun: Quantile Function

Description

Return the inverse function of a cumulative distribution function.

Usage

quantilefun(x, ...)

# S3 method for im quantilefun(x, ..., type=1) # S3 method for ecdf quantilefun(x, ..., type=1)

# S3 method for ewcdf quantilefun(x, ..., type=1)

Value

A function in the R language.

Arguments

x

Data for which the quantile function should be calculated. Either an object containing data (of class "im" or other classes) or an object representing a cumulative distribution function (of class "ecdf" or "ewcdf").

...

Other arguments passed to methods.

type

Integer specifying the type of quantiles, as explained in quantile.default. Only types 1 and 2 are currently implemented.

Author

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

Details

Whereas the command quantile calculates the quantiles of a dataset corresponding to desired probabilities \(p\), the command quantilefun returns a function which can be used to compute any quantiles of the dataset.

If f <- quantilefun(x) then f is a function such that f(p) is the quantile associated with any given probability p. For example f(0.5) is the median of the original data, and f(0.99) is the 99th percentile of the original data.

If x is a pixel image (object of class "im") then the pixel values of x will be extracted and the quantile function of the pixel values is constructed.

If x is an object representing a cumulative distribution function (object of class "ecdf" or "ewcdf") then the quantile function of the original data is constructed.

See Also

ewcdf, quantile.ewcdf, ecdf, quantile

Examples

Run this code
  ## numeric data
  z <- rnorm(50)
  FZ <- ecdf(z)
  QZ <- quantilefun(FZ)
  QZ(0.5) # median value of z
  if(interactive()) plot(QZ, xlim=c(0,1), xlab="probability",
                     ylab="quantile of z")
  ## image data
  Z <- bei.extra$elev
  if(require(spatstat.explore)) {
    FE <- spatialcdf(Z, normalise=TRUE)
  } else {
    FE <- ecdf(Z[])
  }
  QE <- quantilefun(FE)
  QE(0.5) # median elevation
  if(interactive()) plot(QE, xlim=c(0,1),
     xlab="probability", ylab="quantile of elevation")

Run the code above in your browser using DataLab