//
//Cox Survival command
//
//This command is regression for survival analysis called Cox Hazard model.
//

//Syntax
cox [target] by [explanation];

//Example 1
//read default compay by grade for 12 years.



get haz2@; //define defalut company (tim_1 to tim_12) to vector. vector tim[12]; //count default company by elapsed time and grade. for(i=0;i<=12;i++) { censor=1; pstime=i; if(i == 0) { default=0; } else { default=tim[i]; } grade=rating; outrec; } select grade censor pstime default; sort pstime grade; //output tempolary file put dmy1; //count safe company after 12 years. get haz2@; vector tim[12]; sum=0; for(i=1;i<=12;i++) { sum=sum+tim[i]; } default=init-sum; grade=rating; pstime=13; censor=0; select grade pstime default censor; put dmy6; //concatinate defaut file and safe file. get dmy1; concat dmy6; select pstime grade default censor; put cox3; get cox3; //execut cox hazard regression cox default by grade; //get regression coefficent(beta) from output. get freq@ana; //make cox survival function for regression coefficent. accume beta_0; beta_0=beta_0; vector haz[9]; for(i=1;i<=9;i++) { haz[i]=base*exp(i*beta_0); } plot line base haz_1 - 9 by time