Hello,
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.
I am looking into this for you. I'll have a response soon, I hope.
Simon
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
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.
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
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
;
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.
For example:
Let me know if this helps.
Yours
Simon
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.