turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Risk and Fraud
- /
- SAS Risk Management
- /
- Pseudo Random number generation in sas risk dimens...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-10-2016 12:47 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Anindya

03-10-2016 07:37 AM

I am looking into this for you. I'll have a response soon, I hope.

Simon

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SimonMcGrother

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SimonMcGrother

03-11-2016 02:08 AM

Thanks for your reply.

I have generated the random numbers both for monte carlo - covariance based method and monte carlo - model based method.

For the model based approach I have used single risk factor and for model based method I have used multiple risk factors. But then also both of the analysis are generating the same set of random numbers. I am not sure if it is referring to the covariance matrix or not.

Here I have attached the random numbers generated by system (only first 10 random numbers have been attached). I believe this will help to look into the matter in depth.

Below is the RD code that has been used -

```
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
;
```

I am not able to understand the methodology that system is following to generate these random numbers. I am able to validate the sas - covarinace based monte carlo model in excel but not able to tally the random numbers (with constant seed value).

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Anindya

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.

For example:

Let me know if this helps.

Yours

Simon

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SimonMcGrother

03-13-2016 06:24 AM

Actually I was referring to this dataset even the same was attached in my last response. While generating the shocks dataset, I used Twister generator and mentioned seed as 54321. But the same if I use the same parameters in base sas coding (through RAND function), generated random numbers are not getting tallied with Risk dimension generated random numbers. I am just trying to figure out the reason for this difference.