vis_kernel: Visualise kernel weights

View source: R/epa.R

vis_kernelR Documentation

Visualise kernel weights

Description

Visualise kernel weights surrounding a specific grid point using Epanechnikov kernel function and the given bandwidth.

Usage

vis_kernel(data, x = NULL, hx = NULL, tau = NULL, ht = NULL, ...)

Arguments

data

Bond data. If x and hx are not NULL, data needs to include one time index column qdate. If tau and ht are not NULL, data needs to include one column of time to maturity in days tupq.

x

Time grids at which the discount curve is evaluated. Should be specified using the same class of object as the quotation date (qdate) column in data.

hx

Numeric vector of the bandwidth parameter corresponds to each time point x.

tau

Numeric vector that represents time-to-maturities in years where discount function and yield curve will be found for each time point x. See Details.

ht

Numeric vector of the bandwidth parameter corresponding to each time-to-maturities tau. See Details.

...

Specification of an additional covariate, taking the form of var = list(grid, bandwidth), where var is the name of the covariate in data, grid is the values at which the yield curve is estimated, similar to x, and bandwidth is the bandwidth parameter corresponding to each of the grid values, similar to hx.

Details

If x and hx are provided, the kernel weights surrounding time points x will be plotted.

If tau and ht are provided, the kernel weights surrounding time points tau will be plotted.

If the grid and bandwidth of a covariate are provided in ..., the kernel weights of that covariate will be plotted.

The kernel weights can only be plotted in one dimension (time, time-to-maturity, or covariate) at a time.

Value

A ggplot2::ggplot() object.

See Also

ycevo_data(), ycevo()

Examples

bonds <- ycevo_data()
vis_kernel(bonds, x = lubridate::ymd("2023-06-01"), hx = 0.2)


FinYang/ycevo documentation built on April 10, 2024, 8:17 a.m.