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 |
hin |
A list holding the histograms of the response corresponding to each predictor value in the corresponding row of |
qin |
A matrix or list holding the quantile functions of the response. If |
xout |
An m by p matrix or a vector of length m if p=1 holding the m output predictor values. Default is |
optns |
A list of control parameters specified by |
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 whenbwReg
equals"CV"
. Default isNULL
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 overridesnRegGrid
; 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 inCreateDensity()
; default:0.001 * mean(qin[,ncol(qin)] - qin[,1])
.
Value
A list containing the following components:
xout |
Input |
dout |
A matrix or list holding the output densities corresponding to |
dSup |
A numeric vector giving the domain grid of |
qout |
A matrix holding the quantile functions of the output densities. Each row corresponds to a value in |
qSup |
A numeric vector giving the domain grid of |
xin |
Input |
din |
Densities corresponding to the input |
qin |
Quantile functions corresponding to the input |
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)