Skip to content

g-arruda/svensson_yield_curve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Svensson Yield Curve Model

Overview

This repository contains an implementation of the Svensson (1994) model for yield curve fitting and analysis in R. The Svensson model extends the Nelson-Siegel approach by adding a fourth term to better capture complex yield curve shapes, making it particularly useful for fixed income analysis and interest rate modeling.

Features

  • Spot Rate Calculation: Calculate spot interest rates for any maturity using calibrated Svensson model parameters
  • Parameter Estimation: Fit the Svensson model parameters to observed market rates using numerical optimization
  • Fixed Maturity Series Generation: Create time series of interest rates for standard fixed maturities from treasury bond data

Functions

svensson_rate()

Calculate spot interest rates using the Svensson model.

svensson_rate(t, beta0, beta1, beta2, beta3, tau1, tau2)

Parameters:

  • t: Time to maturity in years
  • beta0: Long-term interest rate level parameter
  • beta1: Short-term component parameter
  • beta2: Medium-term component parameter
  • beta3: Second medium-term component parameter
  • tau1: First decay parameter (must be positive)
  • tau2: Second decay parameter (must be positive)

fit_svensson()

Estimate Svensson model parameters from observed market rates.

fit_svensson(maturities, rates)

Parameters:

  • maturities: Numeric vector of times to maturity in years
  • rates: Numeric vector of observed interest rates corresponding to maturities

generate_fixed_maturity_series()

Generate a time series of interest rates for standard fixed maturities using treasury bond data.

generate_fixed_maturity_series(dados_tesouro)

Parameters:

  • dados_tesouro: Data frame with treasury bond data containing columns:
    • ref_date: Reference date
    • matur_date: Maturity date
    • yield_bid: Yield to maturity

Usage Examples

Basic Rate Calculation

# Calculate 5-year spot rate
rate <- svensson_rate(
  t = 5, beta0 = 0.04, beta1 = -0.02,
  beta2 = -0.01, beta3 = 0.005,
  tau1 = 1.5, tau2 = 4
)

Parameter Estimation

# Fit model to market data
maturities <- c(0.5, 1, 2, 5, 10)
rates <- c(0.02, 0.025, 0.03, 0.035, 0.04)
params <- fit_svensson(maturities, rates)

# Use the fitted parameters
params
# [1] beta0 beta1 beta2 beta3 tau1 tau2

Fixed Maturity Series Generation

# Assuming dados_tesouro is your treasury bond data
fixed_rates <- generate_fixed_maturity_series(dados_tesouro)

# View the first few rows
head(fixed_rates)

Installation

# Install directly from GitHub
devtools::install_github("yourusername/svensson-yield-curve")

References

Svensson, L. E. (1994). Estimating and Interpreting Forward Interest Rates: Sweden 1992-1994. NBER Working Paper Series, No. 4871.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages