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.
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
)
generate_yield()Numeric matrix. Each column contains the yield curve values at a point in time (a quotation date).
Each row contains the yield curve values for a time-to-maturity.
For example, the number in the second column third row is the yield at the second quotation date,
for the third time-to-maturity ranking from shortest to longest.
See Details for the equation to generate a 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.
Integer. Number of quotation dates to use in the data. Defaults to 12.
Integer. Maximum number of time-to-maturity periods in 10 years that the yield curve is estimated for each quotation date. Defaults to 36
Level term in yield curve equation, Defaults is 0. See
Details.
Slope term in yield curve equation, Defaults is 0.05. See
Details.
Curvature term in yield curve equation, Defaults is 2. See
Details.
Scaling parameter in yield curve equation, Defaults is 0.75. See
Details.
Scaling parameter in yield curve equation, Defaults is 125. See
Details.
Linear term in yield curve evolution, Defaults is -0.55. See
Details.
Quadratic term in yield curve evolution. Defaults is 0.55.
See Details.
Cubic term in yield curve evolution. Defaults is -0.55. See
Details.
Numeric value.
Numeric value. Maturity in years.
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(). Use get_yield_at() instead.
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_i / 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 is obtained by multiplying this curve
by the cubic equation,
$$Yield_{i, time} = Yield_{i, 0} * (1 + linear * time + quadratic *
time^2 + cubic * time^3)$$
so the yield curve slowly changes over different quotation dates.
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.
ycevo_data()
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))
Run the code above in your browser using DataLab