SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_model_mip_preexec_ecl.sas
1/* ****************************************** */
2/* MIP Pre-Execution Code - Stage Allocation */
3/* ****************************************** */
4
5/* Detailed Output Flag */
6%let runDetailedOutput_flg = ${params.RUNDETAILEDOUTPUTFLG};
7
8/* Stage 1 Threshold */
9%let stage1State_max = ${params.STAGE1STATEMAX};
10/* Downgrade Threshold */
11%let deteriorationState_delta = ${params.DETERIORATIONSTATEDELTA};
12/* PD Threshold */
13%let lowPD_max = ${params.LOWPDMAX};
14/* PD Deterioration Threshold */
15%let deteriorationPD_delta = ${params.DETERIORATIONPDDELTA};
16
17/* ****************************************** */
18
19
20/* In order to change the content of the detailed output, you need to
211) change the definition of the macro variable ""detailedOutputCode""
222) add/remove the corresponding output variable from the MIP model group used for the analysis.*/
23
24%if &runDetailedOutput_flg. = Y %then %do;
25 /* Change the definition of the macro variable ""detailedOutputCode"" in order to choose which output variables should be displayed. */
26 %let detailedOutputCode = %bquote(
27 call addmatrix(CUR_STRS_FRC,0,STRS_FRC);
28 call addmatrix(CUR_STG1_FRC,0,STG1_FRC);
29 call addmatrix(CUR_STG2_FRC,0,STG2_FRC);
30 );
31%end;
32%else %do;
33 %let detailedOutputCode =;
34%end;
35
36
37/* Change the definition of the macro variable stagingCode in order to set custom stage allocation rules. */
38%let stagingCode = %bquote(
39 /*As a general rule:
40 A) stage 1 is set by DEFAULT
41 B) stage 2 is for a significant credit state downgrade: this is triggered by deteriorationState_delta
42 C) stage 2 is for poor quality credit states: this is triggered by stage1State_max
43 D) stage 2 if there is a significant deterioration of the
44 probability of default and the probability of default
45 is larger than low credit risk threshold: this is triggered by deteriorationPD_delta and lowPD_max*/
46
47 /*---A) by default---*/
48 stagingCode_stage = 1;
49
50 /* ---B)---*/
51 if (stagingCode_currentState - stagingCode_origState) >= &deteriorationState_delta. then do;
52 stagingCode_stage = 2;
53 end;
54
55 /*---C)---*/
56 if (stagingCode_currentState > &stage1State_max.) then do;
57 stagingCode_stage = 2;
58 end;
59
60 /* ---D)---*/
61 if ( (stagingCode_currentPD - stagingCode_beginPD) >= &deteriorationPD_delta. and stagingCode_currentPD >= &lowPD_max.) then do;
62 stagingCode_stage = 2;
63 end;
64);
65
66/* ******************************************* */
67/* Setup RD Environment */
68/* ******************************************* */
69
70/* Create new RD environment */
71proc risk;
72 env
73 new = mipenv.risk_env
74 inherit = (mimp_env.base_risk_env)
75 ;
76 setoptions NOBACKSAVE;
77 env save;
78run;
79
80/* Compile RWA functions */
81proc compile outlib = mipenv.risk_env env = mipenv.risk_env package = RWA;
82
83 function OtherRetailRW (PD, LGD)
84 label = "Other Retail RiskWeight function"
85 kind = "Basel II RiskWeight";
86 PD_temp=PD;
87 /* PD Floor */
88 if PD_temp < 0.0003 then PD_temp = 0.0003;
89 /* PD Ceiling */
90 PD_CEILING = 1 - 1e-15;
91 if PD_temp > PD_CEILING then PD_temp = PD_CEILING;
92
93 R = 0.03 * (1 - exp(-35 * PD_temp)) / (1 - exp(-35)) + 0.16 * (1 - (1 - exp(-35 * PD_temp))/(1 - exp(-35)));
94 K = LGD * (probnorm( ((1-R)**(-0.5)) * probit(PD_temp) + ((R/(1-R))**(0.5)) * probit(0.999) )) - PD_temp*LGD;
95
96 Return(K);
97
98 Endsub;
99
100 function RevolvingRetailRW (PD, LGD)
101 label = "Revolving Retail RiskWeight function"
102 kind = "Basel II RiskWeight";
103 PD_temp=PD;
104 /* PD Floor */
105 if PD_temp < 0.0003 then PD_temp = 0.0003;
106 /* PD Ceiling */
107 PD_CEILING = 1 - 1e-15;
108 if PD_temp > PD_CEILING then PD_temp = PD_CEILING;
109
110 R = 0.04;
111 K = LGD * (probnorm( ((1-R)**(-0.5)) * probit(PD_temp) + ((R/(1-R))**(0.5)) * probit(0.999) ) ) - PD_temp*LGD;
112
113 Return(K);
114
115 Endsub;
116
117 function CorporateRW (PD, LGD)
118 label = "Corporate RiskWeight function"
119 kind = "Basel II RiskWeight";
120 PD_temp=PD;
121 /* PD Floor */
122 if PD_temp < 0.0003 then PD_temp = 0.0003;
123 /* PD Ceiling */
124 PD_CEILING = 1 - 1e-15;
125 if PD_temp > PD_CEILING then PD_temp = PD_CEILING;
126
127 /* set generic size=5 */
128 R = 0.12 * (1-exp(-50*PD_temp)) / (1-exp(-50)) + 0.24 * ( 1-((1-exp(-50*PD_temp))/(1-exp(-50))) ) -0.04;
129 B = (0.11852 - 0.05478*log(PD_temp))**2;
130
131 M = 2.5;
132 K = (LGD * probnorm( ((1-R)**(-0.5)) * probit(PD_temp) + ((R/(1-R))**(0.5)) * probit(0.999) ) - PD_temp*LGD ) * ((1-1.5*B)**(-1)) * (1+(M-2.5)*B);
133
134 Return(K);
135
136 Endsub;
137
138 function ResidentialRW (PD, LGD)
139 label = "Residential RiskWeight function"
140 kind = "Basel II RiskWeight";
141 PD_temp=PD;
142 /* PD Floor */
143 if PD_temp < 0.0003 then PD_temp = 0.0003;
144 /* PD Ceiling */
145 PD_CEILING = 1 - 1e-15;
146 if PD_temp > PD_CEILING then PD_temp = PD_CEILING;
147
148
149 R = 0.15;
150 K = LGD * (probnorm( ((1-R)**(-0.5)) * probit(PD_temp) + ((R/(1-R))**(0.5)) * probit(0.999) ) ) - PD_temp*LGD;
151
152 Return(K);
153
154 Endsub;
155
156run;