Learn R Programming

CondCopulas (version 0.2.0)

computeKernelMatrix: Computing the kernel matrix

Description

This function computes a matrix of dimensions (length(observedX3), length(newX3)), whose element at coordinate (i,j) is \( K_{h}(\)observedX3\([i] - \)newX3\([j] )\), where \(K_h(x) := K(x/h) / h\) and \(K\) is the kernel.

Usage

computeKernelMatrix(observedX, newX, kernel, h)

Value

a numeric matrix of dimensions (length(observedX), length(newX))

Arguments

observedX

a numeric vector of observations of X3. on the interval \([0,1]\).

newX

a numeric vector of points of X3.

kernel

a character string describing the kernel to be used. Possible choices are Gaussian, Triangular and Epanechnikov.

h

the bandwidth

See Also

estimateCondCDF_matrix, estimateCondCDF_vec,

Examples

Run this code
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)

# To have an estimator of the conditional expectation of Y1 given Y2 = 0, 1, 2.5
Y[,1] * matrixK[,1] / sum(matrixK[,1])
Y[,1] * matrixK[,2] / sum(matrixK[,2])
Y[,1] * matrixK[,3] / sum(matrixK[,3])

Run the code above in your browser using DataLab