03-10-2016 12:47 AM
I am trying to configure co-variance based simulation in SAS Risk Dimension. I have used seed value as 54321 and have considered the twister random number generator. But the output is not getting tallied with the values generated by using RAND function in sas coding. Below is the piece of code which I tried to execute in SAS -
data test; call streaminit(54321); do i=1 to 10; var1=rand('normal'); output; end; run;
Can anyone help me with the issue. I would like to know how SAS risk dimension is using the seed value for generating the random numbers and why the same is not getting tallied while generating the random numbers in base sas.
03-10-2016 08:58 AM
What you are trying to do is very challenging.
The random normals that we are producing are correlated random normals. The data step code you provide would
only work if you had a single risk factor in your covariance matrix and that risk factor had a variance of 1 and the risk factor is MLEVEL=interval (The default is ratio). If you have multivariate problem you will need to multiply the random normal shocks by the cholesky root of the covariance matrix L where L’L =covariance matrix. You will need
to know the order of the risk factors used in SAS Risk Dimensions, and whether the cholesky root is rank deficient. Pseudo random draws are made in the order of the risk factors and, furthermore, risk factors that are strict linear functions of other risk factors (rank deficient) are skipped.
03-11-2016 02:08 AM
Thanks for your reply.
SIMULATION MonteCarloSim_model METHOD=montecarlo DATA = HistoricalMarketData HORIZON = ( 1 ) INTERVAL = WeekDay GENERATOR = twister NDRAW = 251 SEED = 54321 ERRORMODEL = NORMAL ; SIMULATION MonteCarloSim METHOD=covariance DATA = Covar_matrix_new HORIZON = ( 1 ) INTERVAL = WeekDay GENERATOR = twister NDRAW = 251 SEED = 54321 ERRORMODEL = ASFIT ;
03-11-2016 08:59 AM
There is an output option called SHOCKS that might help.
On the RUNPROJECT statement put
options=(shocks states …)
When the project is run, you get a dataset called “shocks” that contain the raw random normal shock that SAS Risk Dimensions used in that analysis. These are
the shocks before multiplying with the cholesky root.
Let me know if this helps.
03-13-2016 06:24 AM