View source: R/kernelEstimation.R
| estimateCondQuantiles | R Documentation |
This function is supposed to be used with computeKernelMatrix.
Assume that we observe a sample (X_{i,1}, X_{i,3}), i=1, \dots, n.
We want to estimate the conditional quantiles of X_1 given X_3 = x_3
at point u_1 using the following kernel-based estimator
\hat Q(u_1 | X_3 = x_3) := \hat P^{(-1)}(u_1 \leq x_1 | X_3 = x_3),
where
\hat P(X_1 \leq x_1 | X_3 = x_3)
:= \frac{\sum_{l=1}^n 1 \{X_(l,1) \leq x_1 \} K_h(X_(l,3) - x_3)}
{\sum_{l=1}^n K_h(X_(l,3) - x_3)},
for every u_1 in probsX1 and every x_3 in newX3.
The matrixK3 should be a matrix of the values K_h(X_(l,3) - x_3)
such as the one produced by
computeKernelMatrix(observedX3, newX3, kernel, h).
estimateCondQuantiles(observedX1, probsX1, matrixK3)
observedX1 |
a sample of observations of X1 of size n |
probsX1 |
a sample of probabilities at which we want to compute the quantiles for the variable X1, of size p1 |
matrixK3 |
a matrix of kernel values of dimension (p2 , n)
|
A matrix of dimensions (p1,p2) whose (i,j) entry is \hat Q(u_1 | X_3 = x_3)
with u_1 = probsX1[i] and x_3 = newX3[j],
where newX3[j] is the vector that was used to construct matrixK3.
Y = MASS::mvrnorm(n = 100, mu = c(0,0), Sigma = cbind(c(1, 0.9), c(0.9, 1)))
matrixK = computeKernelMatrix(observedX = Y[,2] , newX = c(0, 1, 2.5),
kernel = "Gaussian", h = 0.8)
matrixnp = estimateCondQuantiles(observedX1 = Y[,2],
probsX1 = c(0.3, 0.5) , matrixK3 = matrixK)
matrixnp
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.