Resources

Simulating Default Times

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: hpcopex1.sas
 Description: Example program from SAS/ETS User's Guide,
              The HPCOPULA Procedure
       Title: Simulating Default Times
     Product: SAS/ETS Software
        Keys: copula joint distribution
        PROC: HPCOPULA
       Notes:

--------------------------------------------------------------*/

ods graphics on;

data inparm;
    Y1=1.0;
    Y2=0.8;
    output;
    Y1=0.8;
    Y2=1.0;
    output;
run;

proc print data = inparm;
run;


/* simulate the data from bivariate normal copula */
proc hpcopula;
   var Y1-Y2;
   define cop normal (corr=inparm);
   simulate cop /
            ndraws     = 1000000
            seed       = 1234
            outuniform = normal_unifdata;
   PERFORMANCE nodes=4 nthreads=4 details
               host="&GRIDHOST" install="&GRIDINSTALLLOC";
run;


/* default time has exponential marginal distribution with parameter 0.5 */
data default;
   set normal_unifdata;
   array arr{2} Y1-Y2;
   array time{2} time1-time2;
   array surv{2} survive1-survive2;
   lambda = 0.5;
   do i=1 to 2;
      time[i] = -log(1-arr[i])/lambda;
      surv[i] = 0;
      if (time[i] >3) then surv[i]=1;
   end;
   survive = 0;
   if (time1 >3) && (time2 >3) then survive = 1;
run;

proc corr data = default pearson kendall;
   var time1 time2;
run;

proc freq data=default;
   table survive survive1-survive2;
run;