use of r in actuarial works

36
Use of R in Actuarial Work November 6, 2012 R Subcommittee, ASTIN Related Study Group Motoharu Dei, Milliman, Inc. FY2012 Annual Meeting of the Institute of Actuaries of Japan VAR Model Interest Rate

Upload: -

Post on 29-May-2015

712 views

Category:

Documents


1 download

DESCRIPTION

Presented in IAJ annual meeting at November 6th, 2012

TRANSCRIPT

Page 1: Use of R in Actuarial Works

Use of R in Actuarial Work

November 6, 2012R Subcommittee, ASTIN Related Study Group

Motoharu Dei, Milliman, Inc.

FY2012 Annual Meeting of the Institute of Actuaries of Japan

VAR ModelInterest Rate

Page 2: Use of R in Actuarial Works

Table of Contents

VAR model Development of VAR model for stress testing of macro

economy

Interest rate Interest rate model PCA of interest rate changes Vasicek model

1

Page 3: Use of R in Actuarial Works

Development of VAR Model for Stress Testing of Macro Economy

2

Page 4: Use of R in Actuarial Works

VAR ModelFlow of Stress Test of Macro Economy

3

1. Trigger event(shock on an economic

index)

2. Sequential event(impact on other economic

indices)

3. Change in risk factors(impact on detailed indices, which

impact on value of a company)

4. Fluctuation of value of a company

Managerial decision

•Study the past events•Opinion of professionals•Subjective view of management

•Estimation using macro economy model (VAR model, etc.)

•Projection using linear regression model, etc.

•Sensitivity of corporate value to a risk factor ×Width of change in a risk factor

•Analysis of results•Consideration of countermeasures•Development of a report

Start of stress testing(recognize needs, define

purpose)• Typical flow of the stress test of macro economy is shown.

• Flexibility and rationality are retained by splitting trigger event and spreading effect model.

• Economic model is converted to a risk factor to cope with risk characteristics of the own company.

• Time-series model is used to allow estimating amount of loss and its timing of occurrence simultaneously.

Page 5: Use of R in Actuarial Works

B is coefficient matrix when inversely presenting VAR model to VMA model

VAR ModelVAR(Vector AutoRegression) model and impulse response function 1/2

4

• Definition of VAR model

• Definition of impulse response function (= function showing reminder of the shock)

tptpttt XAXAXACX 2211

Macro index at time t(Equity index, GDP, foreign

exchange rate, etc.)

Impact from past X

Noise

Impact of shock Δ after n periods

Expected value of index after n periods with the shock

Expected value of index after n periods without the shock

nB 111 ,:,, tntttntt XEXEnI

Page 6: Use of R in Actuarial Works

VARモデルVAR(Vector AutoRegression) model and impulse response function 2/2

5

• Orthogonal impulse response function

• Generalized impulse response function

jnOj PeBnI

jnjjGj eBnI 2

1

The jth factor of orthogonal impulse response function

The jth factor of generalized impulse response function

Page 7: Use of R in Actuarial Works

VAR ModelGVAR(Global Vector AutoRegression) model

6

• VARX(VAR with eXogenous variables) model(Model by region with exogenous variable (Y: X with

weighted average of region other than i)

• GVAR model (VAR model consolidating VARX model)

tki

qkikiii

piiiiii

qtttpttttYGYGYGXAXAXACX

121 1021

Index at time t Impact of itself in the past (endogenous variable)

NoiseExternal impact (exogenous variable)

2

1

22

12

22

12

21

11

21

11

2

1

20

10

2

1

00

00

00

t

t

t

t

t

t

t

t

t

t

XX

AA

XX

AA

XX

GG

XX

(Case with number of locations: i=1,2, lag of endogenous variable: p=2, lag of exogenous variable: q=0)

Page 8: Use of R in Actuarial Works

VAR modelImplementation using R – Condition for Implementation

7

• Model applied• Both VAR and GVAR are modeled.• Lags assumed are 2 for endogenous and 0 for exogenous.

• Region and indices applied• Region: Japan, US, Europe• Index: Equity price (NKY225, S&P500, FTSE100),

Interest rate (10-year LIBOR swap)• Data source

• Monthly data for the period of 10 years (with 120 data points) between March 2002 and February 2012 of Bloomberg and MSN Finance is logged and used.

Page 9: Use of R in Actuarial Works

VAR ModelPast Data Used

8

【Equity Price Index】 【10-year LIBOR Swap Rate】

0

2,000

4,000

6,000

8,000

10,000

12,000

14,000

16,000

18,000

20,000

NKY225

SP500

FTSE100

0.000

1.000

2.000

3.000

4.000

5.000

6.000

7.000

JPY

USD

EUR

Page 10: Use of R in Actuarial Works

VAR ModelOutput of Results ①

9

• Package used• “vars”: A package

corresponding to VAR model• Coding with R

• Reading data• Calibration using function

“VAR”• Calculation of impulse

response function using function “irf” and others

• Pasting on Excel sheet upon outputting future estimation, impulse response function, etc.

#Specify VAR packagelibrary(vars)

#Obtain dataeconomic_data <- read.csv("data.csv")

#Calibrate VAR model (lag is up to 2 periods)lag<-2result_var <-VAR(economic_data,p=lag,type="both",season=NULL,exogen=NULL)

#Calculate orthogonalized impulse response function (output for the coming 48 periods)project_term <- 48result_var_irf <-irf(result_var,impulse=NULL,response=NULL,n.ahead=project_term,ortho=TRUE,cumulative=FALSE,boot=FALSE,ci=0.95,runs=1000,seed=1)

#Output VAR coefficientresult_var_Bcoef<-Bcoef(result_var)write.table(result_var_Bcoef,file="var_Bcoef.csv",sep=",",row.names=FALSE)

#Output orthogonalized impulse response functionwrite.table(result_var_irf$irf,file="var_irf.csv",sep=",",row.names=FALSE)

Page 11: Use of R in Actuarial Works

VAR ModelOutput of Results ②

10

• Set up Excel so that desired results can be output under the following controllable portion.

• Sample result using the above setup【Equity Price Index】 【10-year LIBOR Swap Rate (Japan)】

Macro Economic Stress Test

○Selection of IRF2 1:orthogonalized IRF 2:generalized IRF

○Amount of impactEquity (variance % from current) Interest Rate (Absolute value of impact in %)JPY US EU JPY US EU

-30% 0% 0% 0.00 0.00 0.00

○Results to output1 1:JPY 2:US 3:EU

Page 12: Use of R in Actuarial Works

Interest Rate Model

11

Page 13: Use of R in Actuarial Works

• Change in the external environment (convergence to the international accounting standards)

⇒Market value of liabilities (insurance & annuity)

• Estimate of yield curve using Nelson-Siegel model

• Measure of the interest rate risks Risk measure by PCA and measurement of interest rate risks in line with

product characteristics

Risk measure using Vasicek Mode

12

Interest Rate Model

Page 14: Use of R in Actuarial Works

1. Time-series interest rate data

2. Estimation of spot rate

4. Estimation of parameter (yield curve)

13

Interest Rate ModelEstimation of Yield Curve

3. Selection of model

Develop interest rate data based on the information on public & corporate bonds of Ministry of Finance, Japan Securities Dealers Association, etc.

Interpolation of spline function and others,Estimate of spot rate from final yield

Selection of model for yield curveSpline polynomialNelson-Siegel model

Estimate each of the model parameters using spot rate values

Page 15: Use of R in Actuarial Works

Interest Rate ModelEstimation of Yield Curve

Obtaining interest rate data

Estimation of spot rate from final yield

Estimation of spot rate

Maximum term available for measure (spline interpolation)

0 5 10 15 20 25 300

0.5

1

1.5

2

2.5redemption/zero yield(2011.12.30)

観測値

zero yieldredemption yield

年限

利率

n

Sn

rs

r rR

rC

0 )1()1(

n

Sn

zs

z nrR

srC

0 ))(1())(1(

C:coupon R:redemption payment rz:spot rate rr:redemption yieldData: Excerpt fro MOF HP (JGB interest rate information)

actual data

Rat

e

Term

Page 16: Use of R in Actuarial Works

Interest Rate ModelEstimation of an Yield Curve

Estimation of parameter (yield curve)

Estimation of yield curve

Selection of model

Nelson-Siegel model

Model using basis function (f(t))

Spline polynomial modelB-Spline modelBernstein polynomial model

##Read interest rate data, set up termData <- read.table("data/kinri_2.csv",header=T,sep=",")Term <- c(1:10,15,20,30)

-------------------------------------------------<Interpolate by spline function using R function “smooth.spline” in package “stats” >

#spline interpolationfor (i in 1:nrow(Data)){

sp <- smooth.spline(Term ,as.vector(Data[i,2:ncol(Data)]))round(predict(sp, seq(0.5,30, length=60))[[2]],10) }

-------------------------------------------------<Estimate parameters in Nelson-Siegel using R function “estim_nss” in package “termstrc” >

##Set data in datazeroyieldsdatazeroyields <- zeroyields(Term, yield, dates)

##Estimation of parameters for Nelson-Siegel, Svensson modelns_res <- estim_nss(datazeroyields,method = "ns",

tauconstr = c(0.2, 6, 0.1))asv_res <- estim_nss(datazeroyields,method = "asv",

tauconstr = c(0.2, 7, 0.1))

Yield curve model

tfat jj1 ctorDiscountfat:

mm ememr 2210 /1 ratespotmr :

Page 17: Use of R in Actuarial Works

16

Interest Rate ModelEstimation of an Yield Curve

Parameters in Nelson-Siege model

0 5 10 15 20 25 300

0.5

1

1.5

2

2.5

estimate zero yield (2011.12.30)

zero yield

estimate zero yeild

年限

利率 R

ate

Term

Page 18: Use of R in Actuarial Works

PCA of interest rate changes

17

Page 19: Use of R in Actuarial Works

PCA of interest rate changes

PCA is a statistical method to aggregate multi-dimensional variables into lower number of dimensions.

Dissolution of time-series and multi-dimensional interest change data into non-correlated common components can explain the interest rate variances with lower number of variances.

Interest rate changes can be mostly explained with 3 principal components: Parallel, Twist and Butterfly.

R already has the function “prcomp(x)” for PCA, and we can take advantage of it.

18

Page 20: Use of R in Actuarial Works

PCA of JGB spot rate Analysis on JGB spot rate % of variances Conditions

Historical data used:

Converting JGB yield to spot rates and calculate monthly variances for Jan. 2002~Dec. 2011 Grid points: Year of 1,2,3,4,5,7,10,15,20,30年

Results

PC1 PC2 PC3寄与率 74.85% 17.47% 4.16%累積寄与率 74.85% 92.32% 96.48%

19

‐0.4

‐0.3

‐0.2

‐0.1

0

0.1

0.2

0.3

0.4

0.5

0.6

1 2 3 4 5 7 10 15 20 30

PCA Result

PC1

PC2

PC3

Weight

Accm. weight

Page 21: Use of R in Actuarial Works

Comparison of interest risks by products (1) Compared 2 interest risks: risk by PCA (Assumption) and risk by actual interest changes

(Actual Change), assuming CFs from 2 insurance products

Period Jan. 2007~Dec. 2011 (monthly) For PCA, previous 10-year data from valuation date is used Risk Resource Distribution of Actual Change into principal components of variances

Measure weights in Actual Change among each component (PC1,PC2,PC3,Others) by lease square

20

tt

nnn

nx

xnnnx

EVEVRiskrDF

nxa

DFCFaRisk

1

,

23

1,x

)Change Actual(2)1(ctorDiscountFa:

:

)(PC)Assumption(1

値年限の固有ベクトルの成分の第

2PCx ofWeight geActualChan

PCx

PCzPCy

PCyの寄与

PCxの寄与

PCzの寄与

リスク量の変動

weight

weight

weight

Actual Change

: Element of eigenvector at x th component and term n

Page 22: Use of R in Actuarial Works

Products Whole life lump sum (WLL)

Entry age: age 30 Premium payment period :30 years

Whole life annuity (WLA) Entry age: age 30 Premium payment period :30 years Pension commencement age :age 60

We assume the following CFs from the valuation date

21

Comparison of interest risks by products (1)

‐8000‐6000‐4000‐2000

02000400060008000

1000012000

0 5 10 15 20 25 30 35 40 45 50 55 60 65 70

CF

終身保険

終身年金

Year

WLLWLA

Page 23: Use of R in Actuarial Works

Historical JGB yield

22

0

0.5

1

1.5

2

2.5

3

2002

/07/01

2003

/02/01

2003

/09/01

2004

/04/01

2004

/11/01

2005

/06/01

2006

/01/01

2006

/08/01

2007

/03/01

2007

/10/01

2008

/05/01

2008

/12/01

2009

/07/01

2010

/02/01

2010

/09/01

2011

/04/01

2011

/11/01

JGB

JGB 2Y

JGB 10Y

JGB 20Y

Page 24: Use of R in Actuarial Works

Historical Italian Government Bonds yield

23

012345678

2002

/07/01

2003

/02/01

2003

/09/01

2004

/04/01

2004

/11/01

2005

/06/01

2006

/01/01

2006

/08/01

2007

/03/01

2007

/10/01

2008

/05/01

2008

/12/01

2009

/07/01

2010

/02/01

2010

/09/01

2011

/04/01

2011

/11/01

Italian Government Bonds

IT Gov 2Y

IT Gov 10Y

IT Gov 20Y

Page 25: Use of R in Actuarial Works

Result (WLL, JGB Yield)

0

0.05

0.1

0.15

0.2

0.25

0.3

0.35

‐5 ‐4 ‐3 ‐2 ‐1 0 1 2 3 4 5

Histgram

Actuarl/Assump

NormalDistribution

0%10%20%30%40%50%60%70%80%90%100%

2007

/01/01

2007

/07/01

2008

/01/01

2008

/07/01

2009

/01/01

2009

/07/01

2010

/01/01

2010

/07/01

2011

/01/01

2011

/07/01

Risk Resource Distribution

Others

PC3

PC2

PC1

WLL

Actual/AssumptionAverage 0.11 Stdev 0.87

Assumption returns a constant risk amount irrelevant to the timing.

ActualChange varies significantly when the histrical rate experiences huge changes.

Observation

Assumption captures the ActuarlChange in fairly good manner.

PC1(Parallel) contributes to ActualChange largely.

0

5000

10000

15000

20000

25000

2007

/01/01

2007

/07/01

2008

/01/01

2008

/07/01

2009

/01/01

2009

/07/01

2010

/01/01

2010

/07/01

2011

/01/01

2011

/07/01

Actual Change vs Assumption

|Actual Chg|

Assumption

Page 26: Use of R in Actuarial Works

Result (WLA, JGB Yield)

25

0%10%20%30%40%50%60%70%80%90%100%

2007

/01/01

2007

/07/01

2008

/01/01

2008

/07/01

2009

/01/01

2009

/07/01

2010

/01/01

2010

/07/01

2011

/01/01

2011

/07/01

Risk Resource Distribution

Others

PC3

PC2

PC1

0

0.05

0.1

0.15

0.2

0.25

‐5 ‐4 ‐3 ‐2 ‐1 0 1 2 3 4 5

Histgram

Actuarl/Assump

NormalDistribution

Actual/AssumptionAverage (0.07)Stdev 1.22

Assumption returns a constant risk amount irrelevant to the timing.

ActualChange varies significantly when the histrical rate experiences huge changes.

Assumption somewhat underestimates but captures ActuarlChange in fairly good manner.

PC2(Twist) contributes to ActualChange largely.

0100002000030000400005000060000700008000090000

2007

/01/01

2007

/07/01

2008

/01/01

2008

/07/01

2009

/01/01

2009

/07/01

2010

/01/01

2010

/07/01

2011

/01/01

2011

/07/01

Actual Change vs Assumption

|Actual Chg|

Assumption

WLA Observation

Page 27: Use of R in Actuarial Works

Result (WLL, Italian Government Bonds Yield)

Assumption misses to capture ActualChange at the time of Euro crisis (2011-).

Assumption underestimates the risk.

Like JGB, PC1(Parallel) contributes to the variances most.

0%10%20%30%40%50%60%70%80%90%100%

2007

/01/01

2007

/07/01

2008

/01/01

2008

/07/01

2009

/01/01

2009

/07/01

2010

/01/01

2010

/07/01

2011

/01/01

2011

/07/01

Risk Resource Distribution

Others

PC3

PC2

PC1

0

0.05

0.1

0.15

0.2

0.25

‐5 ‐4 ‐3 ‐2 ‐1 0 1 2 3 4 5

Histgram

Actuarl/Assump

NormalDistribution

Actual/AssumptionAverage (0.10)Stdev 1.60

0

10000

20000

30000

40000

50000

60000

2007

/01/01

2007

/07/01

2008

/01/01

2008

/07/01

2009

/01/01

2009

/07/01

2010

/01/01

2010

/07/01

2011

/01/01

2011

/07/01

Actual Change/Assumption

|Actual Chg|

Assumption

WLL Observation

Page 28: Use of R in Actuarial Works

Result (WLA, Italian Government Bonds Yield)

Assumption misses to capture ActualChange at the time of Euro crisis (2011-).

Assumption significantly underestimates the risk.

PC2(Twist) and PC3 (Butterfly) largely contributes to the variances .

0%10%20%30%40%50%60%70%80%90%100%

2007

/01/01

2007

/05/01

2007

/09/01

2008

/01/01

2008

/05/01

2008

/09/01

2009

/01/01

2009

/05/01

2009

/09/01

2010

/01/01

2010

/05/01

2010

/09/01

2011

/01/01

2011

/05/01

2011

/09/01

Risk Resource Distribution

Others

PC3

PC2

PC1

0

0.05

0.1

0.15

0.2

0.25

Histgram

Actuarl/Assump

NormalDistribution

Actual/AssumptionAverage 0.31 Stdev 2.83

0

10000

20000

30000

40000

50000

60000

70000

2007

/01/01

2007

/06/01

2007

/11/01

2008

/04/01

2008

/09/01

2009

/02/01

2009

/07/01

2009

/12/01

2010

/05/01

2010

/10/01

2011

/03/01

2011

/08/01

2012

/01/01

Actual Change vs Assumption

|Actual Chg|

Assumption

WLA Observation

Page 29: Use of R in Actuarial Works

Parameter Estimation of Vasicek Model And Risk Measurement

28

Page 30: Use of R in Actuarial Works

Vasicek modelOutline

A representative equilibrium model Pros: Manageable because short rate is subject to normal distribution Cons: Permit minus interest rate

29

n

iitt yr

1 itiitiiit dzdtydy

itn

i i yBAeP

1

)()()(

ieB

ii

11)(

ji ji

jiji

jiijn

i i

ii

i

ii jieBBBBA

11)()(

4)()()(

1

22

2

2

22 i

i

iiiii

Vasicek model formula: represent short rate with n state variables

Calculate zero bond price using model parameters and obtain term structure of interest rates

tr

Page 31: Use of R in Actuarial Works

Vasicek modelParameter estimation

Assume the short rate is subject to the following random process and estimate model parameters (κ, θ, σ, λ).

One typical solution is to regard the observable shortest interest rate as short rate and estimate parameters using maximum-likelihood method.

However, while maximum-likelihood method is efficient to estimate short rate, it is known that it is not always applicable to model the whole yield curve as it only uses short rate data.

Using historical “yield curve” information is preferable.

Express the model in “state space model” and estimate the parameters using “Kalman filter technique”

30

jitli

i

tktkitl

l

ii

lFtyeeNFtr

,

)|)(},)1({(~|)(11

Page 32: Use of R in Actuarial Works

Vasicek modelParameter estimation

1. Express Vasicek model in “state space model” 2. Use Kalman filter algorithm and conditioned probability distribution of

state variables3. Calculate the log likelihood4. Estimate parameters maximizing log likelihood in 3.

31

kkk ttt yFcy 1

kkk ttt yHaz

K

k tttttT

tttK

k tt kkkkkkkkkkzzdzzdmKl

1 |1||1 | 1111

log2log21)(

111 ||

kkkk tttt yFcy

kkkkk tT

tttt QFVFV 111 ||

1|| 11

RHVHHVK T

ttT

ttt kkkkk

11 |||

kkkkkkkk tttttttt yHazKyy

1||

kkkkk ttttt VHKIV

State space model

Log likelihood

Predict one period ahead Filter

11 ||

kkkk tttt yHAz RHVHd Ttttt kkkk

11 ||

Page 33: Use of R in Actuarial Works

Vasicek modelImplementation in R and risk measurement

Parameter estimate1. Calculate coefficients in state space 2. Calculate log likelihood (using function “fkf” in package “FKF”)3. Estimate parameters maximizing log likelihood (using function “optim”) Measure interest risk4. Generate random variables and yield curves 1 yr later5. Calculate changes in PV of CF and percentile amount

32

0.00%

0.50%

1.00%

1.50%

2.00%

2.50%

3.00%

3.50%

0 5 10 15 20 25 30 35

1年後のイールドカーブ (10個のサンプル)

0

2

4

6

8

10

12

‐110

‐100 ‐90

‐80

‐70

‐60

‐50

‐40

‐30

‐20

‐10 0 10 20 30 40 50 60 70 80 90 100

110

次の

現在価値の変動額のヒストグラム

(Assuming 100 CF in 10 grid points during year 1 - 30)

10 samples of yield curves 1 yr later Histogram of changes in PV of CF

Page 34: Use of R in Actuarial Works

• Even when it is difficult to generate economic scenarios from scratch on Excel, R provide packages for most economic models. Utilizing them help actuaries implement economic models.•We saw that using the package “vars” enables us

to calibrate the VAR model’s coefficients and utilize other functions with a single command.

• As to the interest rate model, we saw that R command can accelerate our analysis in Nelson-Siegel model, PCA and Kalman filter algorithm.

33

Summary

Page 35: Use of R in Actuarial Works

• VAR model• About generalized impulse response function

• M. H. Pesaran and Shin Y (May 1997), “Generalized Impulse Response Analysis in Linear Multivariate Models”

• About GVAR• O. Castren, S. Dees and Zaher, F (February 2008), “Global

Macro-Financial Shocks and Expected Default Frequencies in the Euro Area”

• About vars package

• Reference manual ”Package ‘vars’ January2, 2012”

34

Reference

Page 36: Use of R in Actuarial Works

• Interest Rate Model• About estimation of yield curve and PCA of interest rate variances

• Mark Deacon & Andrew Derry “Estimating the Term Structure of Interest Rates”

• 田中 周二 「アクチュアリーの統計分析」 朝倉書店

• About Vasicek model• 大塚裕次朗 「Vasicek/CIR Modelのキャリブレーション手法と日本

の金利VaR99.5%」 日本アクチュアリー会会報64(1)• Bolder, David “Affine Term Structure Models: Theory and

Implementation “Bank of Canada Working Paper 2001-15• 北川源四郎 「時系列解析入門」 岩波書店

35

Reference