Simulating Bond Yield Paths with Historical Resampling or a Lognormal Model
Summary
The document explains two ways to create forward scenarios for a bond yield series. One approach resamples historical yield changes: repeatedly draw changes from the observed series, accumulate them from the latest yield, and use the resulting paths to examine possible outcomes. The discussion describes plotting simulated paths and the distribution of terminal yields, and notes that such scenarios can support analyses such as risk estimates or derivative valuation.
A second answer proposes a parametric model in which log yield changes follow a process with drift and normally distributed shocks. Its parameters are estimated from historical log changes, then used to simulate independent increments. These methods rely on different assumptions: resampling reuses observed changes, while the parametric approach assumes a particular distribution and model form. Neither method establishes that historical behavior will persist, and the document does not provide a worked empirical comparison or calibration results.
Key ideas
- Historical yield changes can be sampled and cumulatively added to the latest yield to form simulated paths.
- Repeated resampling produces a distribution of possible terminal yields as well as full paths.
- A parametric alternative models log yield changes using drift and normally distributed shocks.
- Historical data can be used to estimate the parameters of the proposed lognormal model.
- The simulated scenarios depend on assumptions about how future yield changes relate to historical behavior.
Tags
Full text
# Simulating a path of bond yields by Monte Carlo (Python)
# Simulating a path of bond yields by Monte Carlo (Python)
I have a number of given time series for bond yields (given in a dataframe in pandas package in Python). I need to do the following task in Python:
"1. Simulate 1000 path 30 steps ahead for any yield series you chose:
a. Plot the paths for any one index you chose
b. Plot the density for each index at step 30
Using the yield-difference data randomly sample 30 different values from the series. Calculate the cumulative sum of the 30 values. This gives you a possible path of yields if we start at a value of zero, but since the latest yield is not zero, we have to add it to each member of the path. Repeat this 1000 times for each series. This is a type of Monte Carlo simulation. You can use a different bootstrapping scheme for your Monte Carlo if you wish."
As a total noob in finance and programming, I am struggling to understand what I am actually required to do and how to go about this. Does the question require me to: pick out at random 30 values of a given time series, and then essentially use these 30 values to "predict" what the future values will be? And then re-do this procedure 1000 times? Or something else?
I'd be grateful if someone could explain the meaning of this task and what I could do in Python for it. Thank you.
## Answer by AlRacoon (score 4)
https://quant.stackexchange.com/a/38196
I do not know Python but this is what I would do in Excel (I am assuming you are familiar with Excel and can then translate the steps into Python:
- Pick a time series of Bond Yields which has $n$ yields.
- Generate a series of Bond Yield changes from that time series resulting in $n-1$ yield changes in a column.
- Assign each of these yield changes an integer value from $1$ to $n-1$ in a column to the left of the yield changes.
- Use randbetween($1,n-1$) $30$ times to generate $30$ random integers between 1 and $n-1$. If $n >> 30$, then it should not matter if you sample with or without replacement.
- Use vlookup(random number you generated, range that includes random numbers and the yield changes, 2). This will generate a simulated path of yield changes.
- Add the t=0 yield of the index you chose to the first random yield change you chose from step 5. Take the result and add it to the second random yield change you generated in step 5. Repeat for each of the $30$ random yield changes. Now you have a single $30$ step path of yields. Note that this assumes that each step has the same tenor as the yield change differences.
- Repeat steps 4 - 6 $999$ times so you now have $1000$ $30$ step paths.
- Plot all $1000$ paths.
- Plot a histogram of all of the $1000$ terminal step $30$ values.
Monte Carlo simulation is a technique to generate a distribution of paths based on an assumed distribution (in this case historical values). You now have $1000$ possible $30$ step paths of this interest rate index, which you can then use to infer Value-At-Risk, derivative prices etc.
Hope this helps.
## Answer by David Addison (score 0)
https://quant.stackexchange.com/a/38223
To simulate a time-series with "x" random paths, there must first be a model which describes the process. The process you use may be dependent on your comfort level with stochastic processes, empirical observations about that data, and/or beliefs about the underlying process.
The Wiki entry on short rate models summarizes some of the major models which are commonly used for modeling interest rates. For simplicity, let’s choose the Kalotay–Williams–Fabozzi model, since it requires only two parameters. It is also the same thing as Geometric Brownian Motion which is commonly used to simulate stock prices (why does everyone insist on putting their names on models?).
Given the process: $$ {\displaystyle d\ln(r_{t})=\theta _{t}\,dt+\sigma \,dW_{t}}$$
The explicit solution to $r_t$ can be found through Ito's Lemma:
$$\mathbb{E}\left[r_{t+\Delta t } \right]=r_t \, e^{ (\theta _{t} - \frac{ \sigma^2}{2})\Delta t+\sigma \,Z \sqrt{\Delta t} }$$
Where Z is a normally distributed random variable with mean = 0 and variance = 1:
$Z \sim{N\left[0,1 \right]} $
To proceed with the Monte Carlo, the models needs to be calibrated. The simplest approach is to estimate the parameters for $\theta$ and $\sigma^2$ based on historical data. In the context of this model, $\theta$ is the expected logarithmic change in yield (i.e., $\mathbb{E}\left[ Ln[\frac{r_{t+ \Delta t}}{r_{t}}] \right]$) and $\sigma$ is expected standard deviation (i.e.,$\sqrt{ \mathbb{E}\left[ Ln[\frac{r_{t+ \Delta t}}{r_{t}}] -\theta\right]^2}$ ).
From there, it is simply a matter of simulating independent increments for each of the 1000 paths.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.