LocDenReg {frechet}R Documentation

Local density regression.

Description

Local Fréchet regression for densities with respect to L^2-Wasserstein distance.

Usage

LocDenReg(
  xin = NULL,
  yin = NULL,
  hin = NULL,
  qin = NULL,
  xout = NULL,
  optns = list()
)

Arguments

xin

An n by p matrix or a vector of length n if p=1 holding the n observations of the predictor.

yin

A matrix or list holding the sample of observations of the response. If yin is a matrix, each row holds the observations of the response corresponding to a predictor value in the corresponding row of xin.

hin

A list holding the histograms of the response corresponding to each predictor value in the corresponding row of xin.

qin

A matrix or list holding the quantile functions of the response. If qin is a matrix, the support of the quantile functions should be the same (i.e., optns$qSup), and each row of qin holds the quantile function corresponding to a predictor value in the corresponding row of xin. If the quantile functions are evaluated on different grids, then qin should be a list, each element consisting of two components x and y holding the support grid and the corresponding values of the quantile functions, respectively. Note that only one of the three yin, hin, and qin needs to be input. If more than one of them are specified, yin overwrites hin, and hin overwrites qin.

xout

An m by p matrix or a vector of length m if p=1 holding the m output predictor values. Default is xin.

optns

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

Details

Available control options are

bwReg

A vector of length p used as the bandwidth for the Fréchet regression or "CV" (default), i.e., a data-adaptive selection done by cross-validation.

kernelReg

A character holding the type of kernel functions for local Fréchet regression for densities; "rect", "gauss", "epan", "gausvar", "quar" - default: "gauss".

qSup

A numeric vector holding the grid on [0,1] quantile functions take value on. Default is an equidistant grid.

nqSup

A scalar giving the length of qSup. Default is 201.

lower

A scalar with the lower bound of the support of the distribution. Default is NULL.

upper

A scalar with the upper bound of the support of the distribution. Default is NULL.

bwRange

A 2 by p matrix whose columns contain the bandwidth selection range for each corresponding dimension of the predictor xin for the case when bwReg equals "CV". Default is NULL and is automatically chosen by a data-adaptive method.

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

The number of support points the kernel density estimation uses in CreateDensity(); numeric - default: 101.

dSup

User defined output grid for the support of kernel density estimation used in CreateDensity(), it overrides nRegGrid; numeric - default: NULL

delta

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 components:

xout

Input xout.

dout

A matrix or list holding the output densities corresponding to xout. If dout is a matrix, each row gives a density and the domain grid is given in dSup. If dout is a list, each element is a list of two components, x and y, giving the domain grid and density function values, respectively.

dSup

A numeric vector giving the domain grid of dout when it is a matrix.

qout

A matrix holding the quantile functions of the output densities. Each row corresponds to a value in xout.

qSup

A numeric vector giving the domain grid of qout.

xin

Input xin.

din

Densities corresponding to the input yin, hin or qin.

qin

Quantile functions corresponding to the input yin, hin or qin.

optns

A list of control options used.

References

Petersen, A., & Müller, H.-G. (2019). "Fréchet regression for random objects with Euclidean predictors." The Annals of Statistics, 47(2), 691–719.

Examples


xin = seq(0,1,0.05)
yin = lapply(xin, function(x) {
  rnorm(100, rnorm(1,x + x^2,0.005), 0.05)
})
qSup = seq(0,1,0.02)
xout = seq(0,1,0.1)
res1 <- LocDenReg(xin=xin, yin=yin, xout=xout, optns = list(bwReg = 0.12, qSup = qSup))
plot(res1)
xout <- xin
hin = lapply(yin, function(y) hist(y, breaks = 50))
res2 <- LocDenReg(xin=xin, hin=hin, xout=xout, optns = list(qSup = qSup))
plot(res2)


[Package frechet version 0.3.0 Index]