Site icon R-bloggers

Smith-Wilson Extrapolation with R code

[This article was first published on K & L Fintech Modeling, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
This post explains how to implement the Smith-Wilson extrapolation by which deterministic DNS shock scenarios are generated.

< !--반응형 last AD....-->< !--horizontal001-->

Smith-Wilson Extrapolation



Deterministic DNS shock scenarios under ICS (K-ICS) are the term structure of annually compounding spot rates which spans from 1-month to 1440-month (120-year) or longer. This is used to discount the future cash flows of insuance policies. But the longest available maturity of market rates which is at most 50-year (but ICS use 20-year as the longest maturity) is too short to apply for pricing. For this end, some extrapolation is needed.

The extrapolation method ini ICS (K-ICS) is the Smith-Wilson approach. This method consists of some complicated equations ,which stems from correlations of stochasic process, but does not accompany any estimation process. This means that it is not difficult to implement it anyway. We suggest that practitioners have only to know the meaning of parameters and use it.

Smith-Wilson model generates a smoothed interpolated and extrapolated term structures which fit all market spot rates perfectly when the following parameters are given.


Among the above parameters, LLP is sometimes referred to as the CP. This post use the latter definition for convenience.
Since \(UFR\) is the asymptotic forward rate and \(\alpha\) is a convergence speed, the solution of Smith-Wilson is determined by finding the instantaneous forward rate which converges at LLP within the tiny range of 0.01%. \[ P(t) = e^{-UFR·t} + \sum_{j=1}^{N} \zeta_j · W(t,u_j), \quad\quad t \geq 0 \] \[ W(t,u_j) = e^{-URF · (t+u_j )} \left\{ \alpha · min(t,u_j)- \\ \frac{1}{2}e^{-\alpha · max(t,u_j)} \left( e^{\alpha · max(t,u_j)}-e^{-\alpha · min(t,u_j)} \right) \right\} \]

Smith-Wilson method fits all market spot rates exactly. This means that \( \zeta_j \) is determined by equating bond prices \( P(t) \) from Smith-Wilson discount function and market bond prices \( P(u_j) \) from market yield curve.

Smith-Wilson looks complicated and some papers interpret this equation as autocovariance of integrated Ornstein-Ullenback process. But we don’t think you need to know that too much in detail because Smith-Wilson extraplation is only technique for generating extended term structure.

Fortunately, this is solved easily by linear systems of equations’ solver because the number of variables is \(N\) and the number of equations is also \(N\). \( \zeta_j \) (\( j=1,…,N \)) are the solution of the following linear systems of equations. \[\begin{align} P(u_1) &= e^{-UFR · u_1} + \sum_{j=1}^{N} \zeta_j · W(u_1,u_j), \\ P(u_2) &= e^{-UFR · u_2} + \sum_{j=1}^{N} \zeta_j · W(u_2,u_j), \\ … \\ P(u_N) &= e^{-UFR · u_N} + \sum_{j=1}^{N} \zeta_j · W(u_N,u_j) \end{align}\] The above equations are expressed by the following compact matrix form.

\[ P = \mu + W \zeta \rightarrow \zeta = W^{-1}(P-\mu) \]
\[\begin{align} &P = \begin{bmatrix} P(u_1)\\ P(u_2)\\ ⋮\\ P(u_N) \end{bmatrix}, \mu = \begin{bmatrix} e^{-UFR · u_1}\\ e^{-UFR · u_2}\\ ⋮\\ e^{-UFR · u_N} \end{bmatrix}, \\ &\zeta = \begin{bmatrix} \zeta_1\\ \zeta_2\\ ⋮\\ \zeta_N \end{bmatrix}, W = \begin{bmatrix} W_{11}&W_{12}&⋯&W_{1N}\\ W_{21}&W_{22}&⋯&W_{2N}\\ ⋮&⋮&⋱&⋮\\ W_{N1}&W_{N2}&⋯&W_{NN} \end{bmatrix} \end{align}\] \[ W_{ij} = W(u_i, u_j), i=1,…,N, j=1,…,N \]
We can obtain \(zeta_j \) (\( j=1,…,N \)) vector by pre-multiplication of inverse matrix of \(W\). In this process, \(LLP\) and \(\alpha\) should be determined simultaneously. To be specific, as \(\alpha\) is gradually increased from the lower value, select \(\alpha\) at the point where the absolute difference between 1-month continuously compounded forward rate and \(UFR\) is started to be less than 0.01%.



Now, inserting whole maturities extended by Smith-Wilson extrapolation into the equation \( P = \mu + W \zeta \) results in the term structure of \(P(t)\). With this \(P(t)\), continuously compounded spot rates (\( R_t^{[c]} \)) and annually compounded spot rates (\( R_t^{[1]} \)) are easily calculated in the following way. \[ R_t^{[c]} = \frac{1}{t} \log \left( \frac{1}{P(t)} \right), \quad R_t^{[1]} = \frac{1}{t} \left( \frac{1}{P(t)} \right)^{\frac{1}{t}} -1 \]

< !--콘텐츠 내 자동 삽입 광고 배치하기-->

The following R code produces Smith-Wilson extrapolated term structure.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#=========================================================================#
# Financial Econometrics & Derivatives, ML/DL using R, Python, Tensorflow  
# by Sang-Heon Lee 
#————————————————————————-#
# Smith-Wilson Extrapolation
#=========================================================================#
 
# Wilson function
fWilson<function(t,m,a,ufr) {
 
    W < matrix(NA,length(t),length(m))
 
    for (i in 1:length(t)) {
        for (k in 1:length(m)) {
            W[i,k] < exp(ufr*(t[i]+m[k]))*(a*min(t[i],m[k])
                0.5*exp(a*max(t[i],m[k]))*(exp(a*min(t[i],m[k]))
                exp(a*min(t[i],m[k]))))
    }}
    return(W)
}
 
# Smith-Wilson extrapolation
fSmithWilson<function(t,m,ufr,spot,llp) {
 
    # t : the maturity in years 1/12 ~ 120
    # m : the observe maturity
    # p : the observed zero discount price
    
    p = exp(spot*m) 
    idx.llp < which(t==llp) # row number of llp maturity
    nt      < length(t)     # all maturity
    
    for (a in seq(0.01,0.2,0.001)) {
        
        muh  < exp(ufr*m)
        zeta < (pmuh)%*%solve(fWilson(m,m,a,ufr))
        P    < exp(ufr*t)+(fWilson(t,m,a,ufr)%*%t(zeta))
        
        # 1M forward rate
        fwd1m < log(P)/t
        fwd1m[2:nt] < log(P[2:nt]/P[1:(nt1)])/
                        (t[2:nt]t[1:(nt1)]) 
        
        print(paste(“forward rate = “,fwd1m[idx.llp], 
              “UFR = “,ufr, “Diff =”,abs(fwd1m[idx.llp]ufr)))
        
        # check if absolute difference is less than 1bp 
        if (abs(fwd1m[idx.llp]ufr)<=0.0001) { break }
    }
    
    spot.cc < (1/t)*log(1/P)
    spot.ac < (1/P)^(1/t)
    fwd.1m  < fwd1m
    
    return(list(v.tau=t, discount.factor = P, spot.cc=spot.cc, 
                spot.ac=spot.ac, fwd.1m=fwd.1m))
}
 
# market spot rates and maturities available at valuation date
v.tau  < c(0.250.50.7511.522.534571020)
v.spot < c(0.0152410.0163930.0179650.0188970.020274
            0.0210700.0217230.0218130.0238590.024832
            0.0251350.0249840.025005)
n.tau < length(v.tau)
 
ufr   < log( 1 + 0.042# ultimate forward rate
llp   < 60              # last liquid point
 
# Application of Smith-Wilson 
v.tau.sw < seq(1/12,120,1/12)
lt.sw < fSmithWilson(v.tau.sw,v.tau,ufr,v.spot,llp)
 
x11()
plot (x=lt.sw$v.tau, y=lt.sw$spot.cc,type=“l”,col=“black”,
      ylab=“Spot Curve with Smith-Wilson”,lwd=1,
      ylim=c(0.01,ufr+0.005), xlab=“Maturity”)
lines(x=lt.sw$v.tau,y=lt.sw$fwd.1m,type=“l”,col=“red”,lty=1,lwd=1)
lines(x=v.tau, y=v.spot,type=“b”,col=“blue”,lty=0,lwd=2,pch=16)
cs


The above R code draws the figure of extrapolated spot rates (black) and forward rate (red) with an extended X axis ranging from 1-month to 120-year.


This Smith-Wilson method is applied to DNS or AFNS shock scenarios. This is the very deterministic DNS or AFNS shock scenarios. These deterministic scenarios are also input, in other words, initial yield curve for Hull-White 1 factor model. Hull-White model generates stochastic DNS or AFNS shock scenarios. Therefore, it is natural to deal with Hull-White model which will be a topic of next post. \(\blacksquare\)

To leave a comment for the author, please follow the link and comment on their blog: K & L Fintech Modeling.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.