SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_model_copula_allocation.sas
1/* ************************************************** */
2/* Copula Allocation Model */
3/* ************************************************** */
4
5%macro stm_allocate(gen_type =) / minoperator;
6
7 %local
8 /* *************************** */
9 /* Allocation model parameters */
10 /* *************************** */
11 portfolio_history_key
12 copula_type
13 copula_vars
14 knn_vars
15 /* *************************** */
16 gen_flg
17 elm_flg
18 ds_ptf_hist
19 ;
20
21 /* Get parameters */
22 %let portfolio_history_key = ${params.PORTFOLIOHISTORYDATA.key};
23 %let copula_type = ${params.COPULATYPE};
24 %let copula_vars = ${params.COPULAVARS};
25 %let knn_vars = ${params.KNNVARS};
26 %let knn_nodes_cnt = ${params.KNNNODES};
27
28 /* Set the value of knn_nodes_cnt to blank if it is not a number --> it will be automatically calculated */
29 %if(%sysfunc(prxmatch(/^\d+$/, %superq(knn_nodes_cnt))) = 0) %then
30 %let knn_nodes_cnt =;
31
32 /* Multi selection parameters are returned as arrays: [var1, var2, ..., varN]. Convert them as space separated list of variables */
33 %let copula_vars = %sysfunc(prxchange(s/[\[%str(,)\]]//i, -1, %superq(copula_vars)));
34 %let knn_vars = %sysfunc(prxchange(s/[\[%str(,)\]]//i, -1, %superq(knn_vars)));
35
36
37 %let gen_flg = N;
38 %let elim_flg = N;
39 %let ds_ptf_hist = &ds_in_analysis_data.;
40
41 %if (&gen_type. in (GENERATION MIX)) %then %do;
42 /* Copula based generation of new synthetic instruments */
43 %let gen_flg = Y;
44
45 %if(%sysevalf(%superq(portfolio_history_key) ne, boolean)) %then %do;
46
47 /* Retrieve the historical portfolio data for the copula analysis */
48 %let httpSuccess = 0;
49 %let responseStatus =;
50 %let ds_ptf_hist = portfolio_history;
51 %irm_rgf_retrieve_analysis_data(key = &portfolio_history_key.
52 , libref = rqsst
53 , outds = portfolio_history
54 , outds_partition_list = ptf_hist_partition_list
55 , out_type = view
56 , outds_dataInfo = ptf_hist_dataInfo
57 , outds_dataDef = ptf_hist_dataDef
58 , host = &rgf_protocol.://&rgf_host.
59 , server = &rgf_service.
60 , solution = rmc
61 , port = &rgf_port.
62 , tgt_ticket = &tgt_ticket.
63 , outVarTicket = ticket
64 , outSuccess = httpSuccess
65 , outResponseStatus = responseStatus
66 , restartLUA = Y
67 , clearCache = Y
68 );
69 %end;
70
71 %end;
72 %if %upcase(&gen_type.) in (ELIMINATION MIX) %then %do;
73 /* Random elimination of existing instruments */
74 %let elim_flg = Y;
75 %end;
76
77 /* Run analysis */
78 %irmc_synth_analysis(ds_in_portfolio = &ds_in_analysis_data.
79 , ds_in_auxiliary_portfolio = &ds_ptf_hist.
80 , ds_in_projection = &ds_in_bep_expectations.
81 , ds_in_bounds = credit_portfolio_bounds
82 , ds_generation_out = &ds_out_generation.
83 , ds_elimination_out = &ds_out_elimination.
84 , target_var = &bep_target_var.
85 , relativeValue_var = relativeValue
86 , fit_vars = &copula_vars.
87 , fit_knn_class_vars = &knn_vars.
88 , k = &knn_nodes_cnt.
89 , by_vars = &segmentation_vars.
90 , id_var = instid
91 , horizon_var = ActivationHorizon
92 , scenario_var = bepName
93 , id_var_prefix = synth_inst_
94 , id_var_fmt = z10.
95 , transform_flg = N
96 , custom_seed = 1
97 , simulation_factor = 5
98 , epsilon = .00005
99 , copula_type = &copula_type.
100 , gen_flg = &gen_flg.
101 , elim_flg = &elim_flg.
102 );
103
104%mend;