U.S. Treasury Yield Curve Construction with R

Bryan Cardillo
10/31/2024

Introduction

In finance, the yield curve is the curve representing how interest rates vary over time. It can be constructed by looking up the rates for various maturity financial products.

For example, this project uses the current interest rates for 2-year, 3-year, and 5-year US treasuries provide three of the data points for building the U.S. Treasury curve.

Fitting a curve to the data points with known values is useful for interpolating between maturities and the shape of the curve over time is interesting from an economic perspective. For this the splinefun function is used to create a function based on the known rates.

Usage

Visit https://dillo.shinyapps.io/yieldcurve/ . Select the date for which you would like to view the curve. Rates are posted for most weekdays, with a one day lag, back as far as 2010.

From the selected date, the appropriate rates for each maturity is retrieved from https://fred.stlouisfed.org. The rates and a fitted spline are plotted and the rates are shown in a table below.

Rates are retrieved each time a new date is selected, and the curve is fit from that date forward. Please be patient as the rates are loaded.

Details

Table of maturities, symbols, and rates for October 1st, 2024.

date symbol description rate
2024-10-01 EFFR Federal funds effective rate – rate for overnight borrowing 4.83
2024-11-01 DGS1MO Yield on 1-month constant maturity U.S. Treasury 4.96
2025-01-01 DGS3MO Yield on 3-month constant maturity U.S. Treasury 4.71
2025-04-01 DGS6MO Yield on 6-month constant maturity U.S. Treasury 4.36
2025-10-01 DGS1 Yield on 1-year constant maturity U.S. Treasury 3.96
2026-10-01 DGS2 Yield on 2-year constant maturity U.S. Treasury 3.61
2027-10-01 DGS3 Yield on 3-year constant maturity U.S. Treasury 3.52
2029-10-01 DGS5 Yield on 5-year constant maturity U.S. Treasury 3.51
2031-10-01 DGS7 Yield on 7-year constant maturity U.S. Treasury 3.60
2034-10-01 DGS10 Yield on 10-year constant maturity U.S. Treasury 3.74
2044-10-01 DGS20 Yield on 20-year constant maturity U.S. Treasury 4.14
2054-10-01 DGS30 Yield on 30-year constant maturity U.S. Treasury 4.08

Sample graph with spline generated by splinefun. plot of chunk graphics

References