Simulating Default Times
/*--------------------------------------------------------------
SAS Sample Library
Name: copex02.sas
Description: Example program from SAS/ETS User's Guide,
The COPULA Procedure
Title: Simulating Default Times
Product: SAS/ETS Software
Keys: copula joint distribution
PROC: COPULA
Notes:
--------------------------------------------------------------*/
ods graphics on;
proc IML;
X= J(2,2,0.8);
X = X+ 0.2*I(2);
name = {'Y1','Y2'};
r2 = {'Y1','Y2'};
create inparm from X[colname=r2 rowname=name];
append from X[rowname=name];
quit;
proc print data = inparm;
run;
/* simulate the data from bivariate normal copula */
proc copula ;
var Y1-Y2;
define cop normal (corr=inparm);
simulate cop /
ndraws = 500
seed = 1234
outuniform = normal_unifdata
plots = (datatype = original
distribution = cdf);
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 plot=matrix kendall;
var time1 time2;
run;
proc freq data=default;
table survive survive1-survive2;
run;