generate_yield: Generate a yield curve with cubic time evolution

View source: R/util.R

generate_yieldR Documentation

Generate a yield curve with cubic time evolution

Description

Generate a yield curve using the extended version of Nelson & Siegel model (Nelson, C. R., & Siegel, A. F., 1987). This has been used in the simulation setting (Equation (30)) of Koo, B., La Vecchia, D., & Linton, O. (2021). See Details and References.

Usage

generate_yield(
  n_qdate = 12,
  periods = 36,
  b0 = 0,
  b1 = 0.05,
  b2 = 2,
  t1 = 0.75,
  t2 = 125,
  linear = -0.55,
  quadratic = 0.55,
  cubic = -0.55
)

get_yield_at(
  time,
  maturity,
  b0 = 0,
  b1 = 0.05,
  b2 = 2,
  t1 = 0.75,
  t2 = 125,
  linear = -0.55,
  quadratic = 0.55,
  cubic = -0.55
)

get_yield_at_vec(
  time,
  maturity,
  b0 = 0,
  b1 = 0.05,
  b2 = 2,
  t1 = 0.75,
  t2 = 125,
  linear = -0.55,
  quadratic = 0.55,
  cubic = -0.55
)

Arguments

n_qdate

Integer giving the number of quotation dates to use in the data. Defaults to 12.

periods

Integer giving the maximum number of time-to-maturity periods in 10 years that the yield curve is estimated for each quotation date. Defaults to 36

b0

Level term in yield curve equation, Defaults to 0. See Details.

b1

Slope term in yield curve equation, Defaults to 0.05. See Details.

b2

Curvature term in yield curve equation, Defaults to 2. See Details.

t1

Scaling parameter in yield curve equation, Defaults to 0.75. See Details.

t2

Scaling parameter in yield curve equation, Defaults to 125. See Details.

linear

Linear term in yield curve evolution, Defaults to -0.55. See Details.

quadratic

Quadratic term in yield curve evolution. Defaults to 0.55. See Details.

cubic

Cubic term in yield curve evolution. Defaults to -0.55. See Details.

time

Numeric value between 0 and 1.

maturity

Numeric value. Maturity in years.

Details

The initial curve at time zero is generated from the following equation

Yield_{i, 0} = b_0 + b_1 * ((1 - \exp(-\tau_i / t_1)) / (\tau / t_1)) + b_2 * ((1 - \exp(-\tau_i / t_2)) / (\tau_i / t_2) - \exp(-\tau_i / t_2))

where \tau_i is the time to maturity, usually measured in years. This defines the yield curve for the quotation date = 0. The yield curve for quotation dates ⁠time = 1, 2, ...⁠ is obtained by multiplying this curve by the cubic equation,

Yield_{i, t} = Yield_{i, 0} * (1 + linear * time + quadratic * time^2 + cubic * time^3)

so the yield curve slowly changes over different quotation dates.

Value

generate_yield

Numeric matrix. Each column is a yield curve in a point in time (a quotation date). Each row is for a time-to-maturity. For example, the number in the second column third row is the yield for the yield curve at the second quotation date, for the third time-to-maturity ranking from shortest to longest. See Details for the equation to generate the yield curve. See Examples for a example with the code to visually inspect the yield curves.

'get_yield_at'

Numeric vector.

'get_yield_at_vec'

Numeric vector.

Functions

  • get_yield_at(): Return the yield at specific points in time of specific maturities.

  • get_yield_at_vec(): Deprecated. Vectorised version of 'get_yield_at'.

References

Nelson, C. R., & Siegel, A. F. (1987). Parsimonious Modeling of Yield Curves. The Journal of Business, 60(4), 473-489.

Koo, B., La Vecchia, D., & Linton, O. (2021). Estimation of a nonparametric model for bond prices from cross-section and time series information. Journal of Econometrics, 220(2), 562-588.

See Also

ycevo_data()

Examples

out <- generate_yield()

# plots
library(ggplot2)
out <- data.frame(out)
colnames(out) <- 1:12
out <- dplyr::mutate(out, time = 1:36)
out <- tidyr::pivot_longer(out, -time, names_to = "qdate", values_to = "yield")
ggplot(out) +
  geom_line(aes(x=time, y=yield, color = qdate))


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