DenFVar {frechet}R Documentation

Fréchet Variance for Densities

Description

Obtain Fréchet variance for densities with respect to L^2-Wasserstein distance.

Usage

DenFVar(
  yin = NULL,
  hin = NULL,
  din = NULL,
  qin = NULL,
  supin = NULL,
  optns = list()
)

Arguments

yin

A matrix or data frame or list holding the sample of measurements for the observed distributions. If yin is a matrix or data frame, each row holds the measurements for one distribution.

hin

A list holding the histograms for the observed distributions.

din

A matrix or data frame or list holding the density functions. If din is a matrix or data frame, each row of din holds the density function for one distribution.

qin

A matrix or data frame or list holding the quantile functions. If qin is a matrix or data frame, each row of qin holds the quantile function for one distribution. Note that the input can be only one of the four yin, hin, din, and qin. If more than one of them are specified, yin overwrites hin, hin overwrites din, and din overwrites qin.

supin

A matrix or data frame or list holding the support grids of the density functions in din or the quantile functions in qin. If supin is a matrix or data frame, each row of supin holds the support grid of the corresponding density function or quantile function. Ignored if the input is yin or hin. It can also be a vector if all density functions in din or all quantile functions in qin have the same support grid.

optns

A list of control parameters specified by list(name = value). See 'Details'.

Details

Available control options are

nqSup

A scalar giving the number of the support points for quantile functions based on which the L^2 Wasserstein distance (i.e., the L^2 distance between the quantile functions) is computed. Default is 201.

qSup

A numeric vector holding the support grid on [0, 1] based on which the L^2 Wasserstein distance (i.e., the L^2 distance between the quantile functions) is computed. It overrides nqSup.

bwDen

The bandwidth value used in CreateDensity() for density estimation; positive numeric - default: determine automatically based on the data-driven bandwidth selector proposed by Sheather and Jones (1991).

ndSup

A scalar giving the number of support points the kernel density estimation used in CreateDensity(); numeric - default: 101.

dSup

User defined output grid for the support of kernel density estimation used in CreateDensity(), it overrides ndSup.

delta

A scalar giving the size of the bin to be used used in CreateDensity(); numeric - default: diff(range(y))/1000. It only works when the raw sample is available.

kernelDen

A character holding the type of kernel functions used in CreateDensity() for density estimation; "rect", "gauss", "epan", "gausvar", "quar" - default: "gauss".

infSupport

logical if we expect the distribution to have infinite support or not, used in CreateDensity() for density estimation; logical - default: FALSE

denLowerThreshold

FALSE or a positive value giving the lower threshold of the densities used in CreateDensity(); default: 0.001 * mean(qin[,ncol(qin)] - qin[,1]).

Value

A list containing the following fields:

DenFVar

A scalar holding the Fréchet variance.

optns

A list of control options used.

Examples

set.seed(1)
n <- 100
mu <- rnorm(n, mean = 0, sd = 0.5)
qSup <- seq(0.01, 0.99, (0.99 - 0.01) / 50)
Ly <- lapply(1:n, function(i) qnorm(qSup, mu[i], sd = 1))
Lx <- qSup
res <- DenFVar(qin = Ly, supin = Lx)
res$DenFVar

[Package frechet version 0.3.0 Index]