version 9.0
drop _all
clear
capture log close
set memory 500m
set matsize 6500
set more off
#delimit ;

*************************************************************************;
**** SET OUTPUT FILE ****;
*************************************************************************;

log using "Q:\DATA\PR\FundCredit\outputbandsNEW2SPOCT.smcl", replace;

use "Q:\DATA\PR\FundCredit\finaldatabaseSPOCT.dta";

replace program1=0 if year>2006;
replace programtminus1d1=0 if year>2006;
replace program2=0 if year>2007;
replace programtminus1d2=0 if year>2007;

replace lnoriginal=0 if year>=2006;
replace sba=0 if year>=2006;
replace rexsba=0 if year>=2006;

*************************************************************************;
**** RESIDUALS ****;
*************************************************************************;

**** PROBABILITY RESIDUALS ****;

gen probability=sba if existsample==1;

tsset groups time;

xi: logit sba program1 programtminus1d1 program2 programtminus1d2 l1.intdevoil l1.devoil l1.itermstr l1.tdebtgdp l1.stdres l1.rescov l1.pkfnetgdp l1.rgdpgr l1.cuagdp l1.ggbgdp l1.bmgdp l1.cpirex if existsample==1, robust cluster(ifscode);

lstat, cutoff(0.196667);

predict probhat if e(sample), p;

predict predhat if e(sample), xb;
gen imrinsample=normden(predhat)/norm(predhat);

predict predforecast, xb;
gen imrforecast=normden(predforecast)/norm(predforecast);

gen PDFnew1=normden(predforecast);
gen CDFnew1=norm(predforecast);

gen epsilon=probability-probhat;

**** ACCESS RESIDUALS ****;

tsset groups time;

gen actualaccess=lnoriginal; 

xi: xtgls lnoriginal quotaCDF tdebtgdpCDF diffcuaCDF stdresCDF PDF1 rexsba time if existsample==1, corr(ar1) p(h) force;

predict predaccesshat if e(sample), xb;

gen delta=actualaccess-predaccesshat;

save "Q:\DATA\PR\FundCredit\prealldatabaseSPOCT.dta", replace;

*************************************************************************;
**** DROP COUNTRIES THAT DO NOT HAVE DATA FOR 2006-2010 ****;
*************************************************************************;

gen newha=large*largedebt;

drop if ifscode==542;	*drops Korea*;
drop if ifscode==965;	*drops Serbia*;
drop if ifscode==819;	*drops Fiji*;

sum actualaccess predaccesshat delta;

*************************************************************************;
**** DEFINE NUMBER OF ROUNDS FOR BOOTSTRAP OF RESIDUALS ****;
*************************************************************************;

gen loop=1000;
scalar loops=loop;
gen loop2=1000;
scalar loops2=loop2;

sort ifscode year;
save "Q:\DATA\PR\FundCredit\alldatabaseSPOCT.dta", replace;

matrix RANEPS=J(364,loops,0); 
matrix RANDELPRE=J(1172,loops,0); 
matrix RANDEL=J(1172,loops,0); 

matrix SHOCKEPSt=J(364,loops,0); 
matrix SHOCKDELPREt=J(1172,loops,0); 
matrix SHOCKDELt=J(364,loops,0); 

gen deltaorig=delta;
replace delta=delta-0.0569097;

*************************************************************************;
**** MATRIX OF RESIDUALS ****;
*************************************************************************;

preserve;

*************************************************************************;

drop if epsilon==. | delta==.;

gen randomeps=.;
gen randomepsrd=.;
gen randomdel=.;

gen rr=.;
gen jj=.;
gen tt=.;
gen ww=.;
gen zz=.;

egen cntctry=group(ifscode);
sort cntctry;
gen totctry=cntctry[_N];
mkmat cntctry, matrix(CTRY);

set seed 156487932;

*************************************************************************;
/*;
scalar m=0;
while scalar(m)<loops {;
scalar m=scalar(m)+1;

replace randomeps=uniform();
replace randomepsrd=round(1172*randomeps);
replace randomepsrd=1 if randomepsrd==0;

mkmat randomepsrd, matrix(RANEPSt);
mkmat epsilon, matrix(EPSt);

scalar i=0;
while scalar(i)<364 {;
scalar i=scalar(i)+1;
matrix RANEPS[scalar(i),scalar(m)]=RANEPSt[scalar(i),1];

scalar LOC=RANEPS[scalar(i),scalar(m)];
matrix SHOCKEPSt[scalar(i),scalar(m)]=EPSt[scalar(LOC),1];

};
};
*/;
*************************************************************************;

scalar a=0;
while scalar(a)<loops {;
scalar a=scalar(a)+1;
	
sort ifscode year;
replace rr=_n;
by ifscode (year) : replace ww=_n;
by ifscode (year) : replace jj=int(_N*uniform())+1;
by ifscode (year) : replace tt=rr[1];
by ifscode (year) : replace zz=_N;
by ifscode (year) : replace randomdel=(tt-1)+jj;

sort ifscode year;
mkmat randomdel, matrix(RANDELt);
mkmat delta, matrix(DELt);
mkmat ww, matrix(CNT1);

mkmat ifscode, matrix(CTRYCNT);
sort ww ifscode;
mkmat ww, matrix(CNT2);

sort ifscode year;

scalar b=0;
while scalar(b)<1172 {;
scalar b=scalar(b)+1;
matrix RANDEL[scalar(b),scalar(a)]=RANDELt[scalar(b),1];
scalar LOC2=RANDEL[scalar(b),scalar(a)];
matrix SHOCKDELPREt[scalar(b),scalar(a)]=DELt[scalar(LOC2),1];

};	* this closes b;
};	* this closes a;

rename rr cntcond;
rename ww cntctrycond;
rename tt inictrycond;
rename zz finctrycond;

matrix CC=CTRY,CNT1,SHOCKDELPREt;

matrix colnames CC = ctryorder condorder 
zz1 zz2 zz3 zz4 zz5 zz6 zz7 zz8 zz9 zz10 
zz11 zz12 zz13 zz14 zz15 zz16 zz17 zz18 zz19 zz20
zz21 zz22 zz23 zz24 zz25 zz26 zz27 zz28 zz29 zz30
zz31 zz32 zz33 zz34 zz35 zz36 zz37 zz38 zz39 zz40
zz41 zz42 zz43 zz44 zz45 zz46 zz47 zz48 zz49 zz50
zz51 zz52 zz53 zz54 zz55 zz56 zz57 zz58 zz59 zz60
zz61 zz62 zz63 zz64 zz65 zz66 zz67 zz68 zz69 zz70
zz71 zz72 zz73 zz74 zz75 zz76 zz77 zz78 zz79 zz80
zz81 zz82 zz83 zz84 zz85 zz86 zz87 zz88 zz89 zz90
zz91 zz92 zz93 zz94 zz95 zz96 zz97 zz98 zz99 zz100
zz101 zz102 zz103 zz104 zz105 zz106 zz107 zz108 zz109 zz110 
zz111 zz112 zz113 zz114 zz115 zz116 zz117 zz118 zz119 zz120
zz121 zz122 zz123 zz124 zz125 zz126 zz127 zz128 zz129 zz130
zz131 zz132 zz133 zz134 zz135 zz136 zz137 zz138 zz139 zz140
zz141 zz142 zz143 zz144 zz145 zz146 zz147 zz148 zz149 zz150
zz151 zz152 zz153 zz154 zz155 zz156 zz157 zz158 zz159 zz160
zz161 zz162 zz163 zz164 zz165 zz166 zz167 zz168 zz169 zz170
zz171 zz172 zz173 zz174 zz175 zz176 zz177 zz178 zz179 zz180
zz181 zz182 zz183 zz184 zz185 zz186 zz187 zz188 zz189 zz190
zz191 zz192 zz193 zz194 zz195 zz196 zz197 zz198 zz199 zz200
zz201 zz202 zz203 zz204 zz205 zz206 zz207 zz208 zz209 zz210 
zz211 zz212 zz213 zz214 zz215 zz216 zz217 zz218 zz219 zz220
zz221 zz222 zz223 zz224 zz225 zz226 zz227 zz228 zz229 zz230
zz231 zz232 zz233 zz234 zz235 zz236 zz237 zz238 zz239 zz240
zz241 zz242 zz243 zz244 zz245 zz246 zz247 zz248 zz249 zz250
zz251 zz252 zz253 zz254 zz255 zz256 zz257 zz258 zz259 zz260
zz261 zz262 zz263 zz264 zz265 zz266 zz267 zz268 zz269 zz270
zz271 zz272 zz273 zz274 zz275 zz276 zz277 zz278 zz279 zz280
zz281 zz282 zz283 zz284 zz285 zz286 zz287 zz288 zz289 zz290
zz291 zz292 zz293 zz294 zz295 zz296 zz297 zz298 zz299 zz300
zz301 zz302 zz303 zz304 zz305 zz306 zz307 zz308 zz309 zz310 
zz311 zz312 zz313 zz314 zz315 zz316 zz317 zz318 zz319 zz320
zz321 zz322 zz323 zz324 zz325 zz326 zz327 zz328 zz329 zz330
zz331 zz332 zz333 zz334 zz335 zz336 zz337 zz338 zz339 zz340
zz341 zz342 zz343 zz344 zz345 zz346 zz347 zz348 zz349 zz350
zz351 zz352 zz353 zz354 zz355 zz356 zz357 zz358 zz359 zz360
zz361 zz362 zz363 zz364 zz365 zz366 zz367 zz368 zz369 zz370
zz371 zz372 zz373 zz374 zz375 zz376 zz377 zz378 zz379 zz380
zz381 zz382 zz383 zz384 zz385 zz386 zz387 zz388 zz389 zz390
zz391 zz392 zz393 zz394 zz395 zz396 zz397 zz398 zz399 zz400
zz401 zz402 zz403 zz404 zz405 zz406 zz407 zz408 zz409 zz410 
zz411 zz412 zz413 zz414 zz415 zz416 zz417 zz418 zz419 zz420
zz421 zz422 zz423 zz424 zz425 zz426 zz427 zz428 zz429 zz430
zz431 zz432 zz433 zz434 zz435 zz436 zz437 zz438 zz439 zz440
zz441 zz442 zz443 zz444 zz445 zz446 zz447 zz448 zz449 zz450
zz451 zz452 zz453 zz454 zz455 zz456 zz457 zz458 zz459 zz460
zz461 zz462 zz463 zz464 zz465 zz466 zz467 zz468 zz469 zz470
zz471 zz472 zz473 zz474 zz475 zz476 zz477 zz478 zz479 zz480
zz481 zz482 zz483 zz484 zz485 zz486 zz487 zz488 zz489 zz490
zz491 zz492 zz493 zz494 zz495 zz496 zz497 zz498 zz499 zz500
zz501 zz502 zz503 zz504 zz505 zz506 zz507 zz508 zz509 zz510 
zz511 zz512 zz513 zz514 zz515 zz516 zz517 zz518 zz519 zz520
zz521 zz522 zz523 zz524 zz525 zz526 zz527 zz528 zz529 zz530
zz531 zz532 zz533 zz534 zz535 zz536 zz537 zz538 zz539 zz540
zz541 zz542 zz543 zz544 zz545 zz546 zz547 zz548 zz549 zz550
zz551 zz552 zz553 zz554 zz555 zz556 zz557 zz558 zz559 zz560
zz561 zz562 zz563 zz564 zz565 zz566 zz567 zz568 zz569 zz570
zz571 zz572 zz573 zz574 zz575 zz576 zz577 zz578 zz579 zz580
zz581 zz582 zz583 zz584 zz585 zz586 zz587 zz588 zz589 zz590
zz591 zz592 zz593 zz594 zz595 zz596 zz597 zz598 zz599 zz600
zz601 zz602 zz603 zz604 zz605 zz606 zz607 zz608 zz609 zz610 
zz611 zz612 zz613 zz614 zz615 zz616 zz617 zz618 zz619 zz620
zz621 zz622 zz623 zz624 zz625 zz626 zz627 zz628 zz629 zz630
zz631 zz632 zz633 zz634 zz635 zz636 zz637 zz638 zz639 zz640
zz641 zz642 zz643 zz644 zz645 zz646 zz647 zz648 zz649 zz650
zz651 zz652 zz653 zz654 zz655 zz656 zz657 zz658 zz659 zz660
zz661 zz662 zz663 zz664 zz665 zz666 zz667 zz668 zz669 zz670
zz671 zz672 zz673 zz674 zz675 zz676 zz677 zz678 zz679 zz680
zz681 zz682 zz683 zz684 zz685 zz686 zz687 zz688 zz689 zz690
zz691 zz692 zz693 zz694 zz695 zz696 zz697 zz698 zz699 zz700
zz701 zz702 zz703 zz704 zz705 zz706 zz707 zz708 zz709 zz710 
zz711 zz712 zz713 zz714 zz715 zz716 zz717 zz718 zz719 zz720
zz721 zz722 zz723 zz724 zz725 zz726 zz727 zz728 zz729 zz730
zz731 zz732 zz733 zz734 zz735 zz736 zz737 zz738 zz739 zz740
zz741 zz742 zz743 zz744 zz745 zz746 zz747 zz748 zz749 zz750
zz751 zz752 zz753 zz754 zz755 zz756 zz757 zz758 zz759 zz760
zz761 zz762 zz763 zz764 zz765 zz766 zz767 zz768 zz769 zz770
zz771 zz772 zz773 zz774 zz775 zz776 zz777 zz778 zz779 zz780
zz781 zz782 zz783 zz784 zz785 zz786 zz787 zz788 zz789 zz790
zz791 zz792 zz793 zz794 zz795 zz796 zz797 zz798 zz799 zz800
zz801 zz802 zz803 zz804 zz805 zz806 zz807 zz808 zz809 zz810 
zz811 zz812 zz813 zz814 zz815 zz816 zz817 zz818 zz819 zz820
zz821 zz822 zz823 zz824 zz825 zz826 zz827 zz828 zz829 zz830
zz831 zz832 zz833 zz834 zz835 zz836 zz837 zz838 zz839 zz840
zz841 zz842 zz843 zz844 zz845 zz846 zz847 zz848 zz849 zz850
zz851 zz852 zz853 zz854 zz855 zz856 zz857 zz858 zz859 zz860
zz861 zz862 zz863 zz864 zz865 zz866 zz867 zz868 zz869 zz870
zz871 zz872 zz873 zz874 zz875 zz876 zz877 zz878 zz879 zz880
zz881 zz882 zz883 zz884 zz885 zz886 zz887 zz888 zz889 zz890
zz891 zz892 zz893 zz894 zz895 zz896 zz897 zz898 zz899 zz900
zz901 zz902 zz903 zz904 zz905 zz906 zz907 zz908 zz909 zz910 
zz911 zz912 zz913 zz914 zz915 zz916 zz917 zz918 zz919 zz920
zz921 zz922 zz923 zz924 zz925 zz926 zz927 zz928 zz929 zz930
zz931 zz932 zz933 zz934 zz935 zz936 zz937 zz938 zz939 zz940
zz941 zz942 zz943 zz944 zz945 zz946 zz947 zz948 zz949 zz950
zz951 zz952 zz953 zz954 zz955 zz956 zz957 zz958 zz959 zz960
zz961 zz962 zz963 zz964 zz965 zz966 zz967 zz968 zz969 zz970
zz971 zz972 zz973 zz974 zz975 zz976 zz977 zz978 zz979 zz980
zz981 zz982 zz983 zz984 zz985 zz986 zz987 zz988 zz989 zz990
zz991 zz992 zz993 zz994 zz995 zz996 zz997 zz998 zz999 zz1000;

svmat CC, names(col);

sort ifscode year;
outsheet ifscode year condorder ctryorder cntctry totctry cntcond cntctrycond inictrycond finctrycond randomdel delta deltaorig using "Q:\DATA\PR\FundCredit\testSPOCT.txt", replace;

sort condorder ctryorder;
drop if condorder>5;
mkmat zz1, matrix(RANDEL1);
mkmat zz2, matrix(RANDEL2);
mkmat zz3, matrix(RANDEL3);
mkmat zz4, matrix(RANDEL4);
mkmat zz5, matrix(RANDEL5);
mkmat zz6, matrix(RANDEL6);
mkmat zz7, matrix(RANDEL7);
mkmat zz8, matrix(RANDEL8);
mkmat zz9, matrix(RANDEL9);
mkmat zz10, matrix(RANDEL10);
mkmat zz11, matrix(RANDEL11);
mkmat zz12, matrix(RANDEL12);
mkmat zz13, matrix(RANDEL13);
mkmat zz14, matrix(RANDEL14);
mkmat zz15, matrix(RANDEL15);
mkmat zz16, matrix(RANDEL16);
mkmat zz17, matrix(RANDEL17);
mkmat zz18, matrix(RANDEL18);
mkmat zz19, matrix(RANDEL19);
mkmat zz20, matrix(RANDEL20);
mkmat zz21, matrix(RANDEL21);
mkmat zz22, matrix(RANDEL22);
mkmat zz23, matrix(RANDEL23);
mkmat zz24, matrix(RANDEL24);
mkmat zz25, matrix(RANDEL25);
mkmat zz26, matrix(RANDEL26);
mkmat zz27, matrix(RANDEL27);
mkmat zz28, matrix(RANDEL28);
mkmat zz29, matrix(RANDEL29);
mkmat zz30, matrix(RANDEL30);
mkmat zz31, matrix(RANDEL31);
mkmat zz32, matrix(RANDEL32);
mkmat zz33, matrix(RANDEL33);
mkmat zz34, matrix(RANDEL34);
mkmat zz35, matrix(RANDEL35);
mkmat zz36, matrix(RANDEL36);
mkmat zz37, matrix(RANDEL37);
mkmat zz38, matrix(RANDEL38);
mkmat zz39, matrix(RANDEL39);
mkmat zz40, matrix(RANDEL40);
mkmat zz41, matrix(RANDEL41);
mkmat zz42, matrix(RANDEL42);
mkmat zz43, matrix(RANDEL43);
mkmat zz44, matrix(RANDEL44);
mkmat zz45, matrix(RANDEL45);
mkmat zz46, matrix(RANDEL46);
mkmat zz47, matrix(RANDEL47);
mkmat zz48, matrix(RANDEL48);
mkmat zz49, matrix(RANDEL49);
mkmat zz50, matrix(RANDEL50);
mkmat zz51, matrix(RANDEL51);
mkmat zz52, matrix(RANDEL52);
mkmat zz53, matrix(RANDEL53);
mkmat zz54, matrix(RANDEL54);
mkmat zz55, matrix(RANDEL55);
mkmat zz56, matrix(RANDEL56);
mkmat zz57, matrix(RANDEL57);
mkmat zz58, matrix(RANDEL58);
mkmat zz59, matrix(RANDEL59);
mkmat zz60, matrix(RANDEL60);
mkmat zz61, matrix(RANDEL61);
mkmat zz62, matrix(RANDEL62);
mkmat zz63, matrix(RANDEL63);
mkmat zz64, matrix(RANDEL64);
mkmat zz65, matrix(RANDEL65);
mkmat zz66, matrix(RANDEL66);
mkmat zz67, matrix(RANDEL67);
mkmat zz68, matrix(RANDEL68);
mkmat zz69, matrix(RANDEL69);
mkmat zz70, matrix(RANDEL70);
mkmat zz71, matrix(RANDEL71);
mkmat zz72, matrix(RANDEL72);
mkmat zz73, matrix(RANDEL73);
mkmat zz74, matrix(RANDEL74);
mkmat zz75, matrix(RANDEL75);
mkmat zz76, matrix(RANDEL76);
mkmat zz77, matrix(RANDEL77);
mkmat zz78, matrix(RANDEL78);
mkmat zz79, matrix(RANDEL79);
mkmat zz80, matrix(RANDEL80);
mkmat zz81, matrix(RANDEL81);
mkmat zz82, matrix(RANDEL82);
mkmat zz83, matrix(RANDEL83);
mkmat zz84, matrix(RANDEL84);
mkmat zz85, matrix(RANDEL85);
mkmat zz86, matrix(RANDEL86);
mkmat zz87, matrix(RANDEL87);
mkmat zz88, matrix(RANDEL88);
mkmat zz89, matrix(RANDEL89);
mkmat zz90, matrix(RANDEL90);
mkmat zz91, matrix(RANDEL91);
mkmat zz92, matrix(RANDEL92);
mkmat zz93, matrix(RANDEL93);
mkmat zz94, matrix(RANDEL94);
mkmat zz95, matrix(RANDEL95);
mkmat zz96, matrix(RANDEL96);
mkmat zz97, matrix(RANDEL97);
mkmat zz98, matrix(RANDEL98);
mkmat zz99, matrix(RANDEL99);
mkmat zz100, matrix(RANDEL100);
mkmat zz101, matrix(RANDEL101);
mkmat zz102, matrix(RANDEL102);
mkmat zz103, matrix(RANDEL103);
mkmat zz104, matrix(RANDEL104);
mkmat zz105, matrix(RANDEL105);
mkmat zz106, matrix(RANDEL106);
mkmat zz107, matrix(RANDEL107);
mkmat zz108, matrix(RANDEL108);
mkmat zz109, matrix(RANDEL109);
mkmat zz110, matrix(RANDEL110);
mkmat zz111, matrix(RANDEL111);
mkmat zz112, matrix(RANDEL112);
mkmat zz113, matrix(RANDEL113);
mkmat zz114, matrix(RANDEL114);
mkmat zz115, matrix(RANDEL115);
mkmat zz116, matrix(RANDEL116);
mkmat zz117, matrix(RANDEL117);
mkmat zz118, matrix(RANDEL118);
mkmat zz119, matrix(RANDEL119);
mkmat zz120, matrix(RANDEL120);
mkmat zz121, matrix(RANDEL121);
mkmat zz122, matrix(RANDEL122);
mkmat zz123, matrix(RANDEL123);
mkmat zz124, matrix(RANDEL124);
mkmat zz125, matrix(RANDEL125);
mkmat zz126, matrix(RANDEL126);
mkmat zz127, matrix(RANDEL127);
mkmat zz128, matrix(RANDEL128);
mkmat zz129, matrix(RANDEL129);
mkmat zz130, matrix(RANDEL130);
mkmat zz131, matrix(RANDEL131);
mkmat zz132, matrix(RANDEL132);
mkmat zz133, matrix(RANDEL133);
mkmat zz134, matrix(RANDEL134);
mkmat zz135, matrix(RANDEL135);
mkmat zz136, matrix(RANDEL136);
mkmat zz137, matrix(RANDEL137);
mkmat zz138, matrix(RANDEL138);
mkmat zz139, matrix(RANDEL139);
mkmat zz140, matrix(RANDEL140);
mkmat zz141, matrix(RANDEL141);
mkmat zz142, matrix(RANDEL142);
mkmat zz143, matrix(RANDEL143);
mkmat zz144, matrix(RANDEL144);
mkmat zz145, matrix(RANDEL145);
mkmat zz146, matrix(RANDEL146);
mkmat zz147, matrix(RANDEL147);
mkmat zz148, matrix(RANDEL148);
mkmat zz149, matrix(RANDEL149);
mkmat zz150, matrix(RANDEL150);
mkmat zz151, matrix(RANDEL151);
mkmat zz152, matrix(RANDEL152);
mkmat zz153, matrix(RANDEL153);
mkmat zz154, matrix(RANDEL154);
mkmat zz155, matrix(RANDEL155);
mkmat zz156, matrix(RANDEL156);
mkmat zz157, matrix(RANDEL157);
mkmat zz158, matrix(RANDEL158);
mkmat zz159, matrix(RANDEL159);
mkmat zz160, matrix(RANDEL160);
mkmat zz161, matrix(RANDEL161);
mkmat zz162, matrix(RANDEL162);
mkmat zz163, matrix(RANDEL163);
mkmat zz164, matrix(RANDEL164);
mkmat zz165, matrix(RANDEL165);
mkmat zz166, matrix(RANDEL166);
mkmat zz167, matrix(RANDEL167);
mkmat zz168, matrix(RANDEL168);
mkmat zz169, matrix(RANDEL169);
mkmat zz170, matrix(RANDEL170);
mkmat zz171, matrix(RANDEL171);
mkmat zz172, matrix(RANDEL172);
mkmat zz173, matrix(RANDEL173);
mkmat zz174, matrix(RANDEL174);
mkmat zz175, matrix(RANDEL175);
mkmat zz176, matrix(RANDEL176);
mkmat zz177, matrix(RANDEL177);
mkmat zz178, matrix(RANDEL178);
mkmat zz179, matrix(RANDEL179);
mkmat zz180, matrix(RANDEL180);
mkmat zz181, matrix(RANDEL181);
mkmat zz182, matrix(RANDEL182);
mkmat zz183, matrix(RANDEL183);
mkmat zz184, matrix(RANDEL184);
mkmat zz185, matrix(RANDEL185);
mkmat zz186, matrix(RANDEL186);
mkmat zz187, matrix(RANDEL187);
mkmat zz188, matrix(RANDEL188);
mkmat zz189, matrix(RANDEL189);
mkmat zz190, matrix(RANDEL190);
mkmat zz191, matrix(RANDEL191);
mkmat zz192, matrix(RANDEL192);
mkmat zz193, matrix(RANDEL193);
mkmat zz194, matrix(RANDEL194);
mkmat zz195, matrix(RANDEL195);
mkmat zz196, matrix(RANDEL196);
mkmat zz197, matrix(RANDEL197);
mkmat zz198, matrix(RANDEL198);
mkmat zz199, matrix(RANDEL199);

mkmat zz200, matrix(RANDEL200);
mkmat zz201, matrix(RANDEL201);
mkmat zz202, matrix(RANDEL202);
mkmat zz203, matrix(RANDEL203);
mkmat zz204, matrix(RANDEL204);
mkmat zz205, matrix(RANDEL205);
mkmat zz206, matrix(RANDEL206);
mkmat zz207, matrix(RANDEL207);
mkmat zz208, matrix(RANDEL208);
mkmat zz209, matrix(RANDEL209);
mkmat zz210, matrix(RANDEL210);
mkmat zz211, matrix(RANDEL211);
mkmat zz212, matrix(RANDEL212);
mkmat zz213, matrix(RANDEL213);
mkmat zz214, matrix(RANDEL214);
mkmat zz215, matrix(RANDEL215);
mkmat zz216, matrix(RANDEL216);
mkmat zz217, matrix(RANDEL217);
mkmat zz218, matrix(RANDEL218);
mkmat zz219, matrix(RANDEL219);
mkmat zz220, matrix(RANDEL220);
mkmat zz221, matrix(RANDEL221);
mkmat zz222, matrix(RANDEL222);
mkmat zz223, matrix(RANDEL223);
mkmat zz224, matrix(RANDEL224);
mkmat zz225, matrix(RANDEL225);
mkmat zz226, matrix(RANDEL226);
mkmat zz227, matrix(RANDEL227);
mkmat zz228, matrix(RANDEL228);
mkmat zz229, matrix(RANDEL229);
mkmat zz230, matrix(RANDEL230);
mkmat zz231, matrix(RANDEL231);
mkmat zz232, matrix(RANDEL232);
mkmat zz233, matrix(RANDEL233);
mkmat zz234, matrix(RANDEL234);
mkmat zz235, matrix(RANDEL235);
mkmat zz236, matrix(RANDEL236);
mkmat zz237, matrix(RANDEL237);
mkmat zz238, matrix(RANDEL238);
mkmat zz239, matrix(RANDEL239);
mkmat zz240, matrix(RANDEL240);
mkmat zz241, matrix(RANDEL241);
mkmat zz242, matrix(RANDEL242);
mkmat zz243, matrix(RANDEL243);
mkmat zz244, matrix(RANDEL244);
mkmat zz245, matrix(RANDEL245);
mkmat zz246, matrix(RANDEL246);
mkmat zz247, matrix(RANDEL247);
mkmat zz248, matrix(RANDEL248);
mkmat zz249, matrix(RANDEL249);
mkmat zz250, matrix(RANDEL250);
mkmat zz251, matrix(RANDEL251);
mkmat zz252, matrix(RANDEL252);
mkmat zz253, matrix(RANDEL253);
mkmat zz254, matrix(RANDEL254);
mkmat zz255, matrix(RANDEL255);
mkmat zz256, matrix(RANDEL256);
mkmat zz257, matrix(RANDEL257);
mkmat zz258, matrix(RANDEL258);
mkmat zz259, matrix(RANDEL259);
mkmat zz260, matrix(RANDEL260);
mkmat zz261, matrix(RANDEL261);
mkmat zz262, matrix(RANDEL262);
mkmat zz263, matrix(RANDEL263);
mkmat zz264, matrix(RANDEL264);
mkmat zz265, matrix(RANDEL265);
mkmat zz266, matrix(RANDEL266);
mkmat zz267, matrix(RANDEL267);
mkmat zz268, matrix(RANDEL268);
mkmat zz269, matrix(RANDEL269);
mkmat zz270, matrix(RANDEL270);
mkmat zz271, matrix(RANDEL271);
mkmat zz272, matrix(RANDEL272);
mkmat zz273, matrix(RANDEL273);
mkmat zz274, matrix(RANDEL274);
mkmat zz275, matrix(RANDEL275);
mkmat zz276, matrix(RANDEL276);
mkmat zz277, matrix(RANDEL277);
mkmat zz278, matrix(RANDEL278);
mkmat zz279, matrix(RANDEL279);
mkmat zz280, matrix(RANDEL280);
mkmat zz281, matrix(RANDEL281);
mkmat zz282, matrix(RANDEL282);
mkmat zz283, matrix(RANDEL283);
mkmat zz284, matrix(RANDEL284);
mkmat zz285, matrix(RANDEL285);
mkmat zz286, matrix(RANDEL286);
mkmat zz287, matrix(RANDEL287);
mkmat zz288, matrix(RANDEL288);
mkmat zz289, matrix(RANDEL289);
mkmat zz290, matrix(RANDEL290);
mkmat zz291, matrix(RANDEL291);
mkmat zz292, matrix(RANDEL292);
mkmat zz293, matrix(RANDEL293);
mkmat zz294, matrix(RANDEL294);
mkmat zz295, matrix(RANDEL295);
mkmat zz296, matrix(RANDEL296);
mkmat zz297, matrix(RANDEL297);
mkmat zz298, matrix(RANDEL298);
mkmat zz299, matrix(RANDEL299);

mkmat zz300, matrix(RANDEL300);
mkmat zz301, matrix(RANDEL301);
mkmat zz302, matrix(RANDEL302);
mkmat zz303, matrix(RANDEL303);
mkmat zz304, matrix(RANDEL304);
mkmat zz305, matrix(RANDEL305);
mkmat zz306, matrix(RANDEL306);
mkmat zz307, matrix(RANDEL307);
mkmat zz308, matrix(RANDEL308);
mkmat zz309, matrix(RANDEL309);
mkmat zz310, matrix(RANDEL310);
mkmat zz311, matrix(RANDEL311);
mkmat zz312, matrix(RANDEL312);
mkmat zz313, matrix(RANDEL313);
mkmat zz314, matrix(RANDEL314);
mkmat zz315, matrix(RANDEL315);
mkmat zz316, matrix(RANDEL316);
mkmat zz317, matrix(RANDEL317);
mkmat zz318, matrix(RANDEL318);
mkmat zz319, matrix(RANDEL319);
mkmat zz320, matrix(RANDEL320);
mkmat zz321, matrix(RANDEL321);
mkmat zz322, matrix(RANDEL322);
mkmat zz323, matrix(RANDEL323);
mkmat zz324, matrix(RANDEL324);
mkmat zz325, matrix(RANDEL325);
mkmat zz326, matrix(RANDEL326);
mkmat zz327, matrix(RANDEL327);
mkmat zz328, matrix(RANDEL328);
mkmat zz329, matrix(RANDEL329);
mkmat zz330, matrix(RANDEL330);
mkmat zz331, matrix(RANDEL331);
mkmat zz332, matrix(RANDEL332);
mkmat zz333, matrix(RANDEL333);
mkmat zz334, matrix(RANDEL334);
mkmat zz335, matrix(RANDEL335);
mkmat zz336, matrix(RANDEL336);
mkmat zz337, matrix(RANDEL337);
mkmat zz338, matrix(RANDEL338);
mkmat zz339, matrix(RANDEL339);
mkmat zz340, matrix(RANDEL340);
mkmat zz341, matrix(RANDEL341);
mkmat zz342, matrix(RANDEL342);
mkmat zz343, matrix(RANDEL343);
mkmat zz344, matrix(RANDEL344);
mkmat zz345, matrix(RANDEL345);
mkmat zz346, matrix(RANDEL346);
mkmat zz347, matrix(RANDEL347);
mkmat zz348, matrix(RANDEL348);
mkmat zz349, matrix(RANDEL349);
mkmat zz350, matrix(RANDEL350);
mkmat zz351, matrix(RANDEL351);
mkmat zz352, matrix(RANDEL352);
mkmat zz353, matrix(RANDEL353);
mkmat zz354, matrix(RANDEL354);
mkmat zz355, matrix(RANDEL355);
mkmat zz356, matrix(RANDEL356);
mkmat zz357, matrix(RANDEL357);
mkmat zz358, matrix(RANDEL358);
mkmat zz359, matrix(RANDEL359);
mkmat zz360, matrix(RANDEL360);
mkmat zz361, matrix(RANDEL361);
mkmat zz362, matrix(RANDEL362);
mkmat zz363, matrix(RANDEL363);
mkmat zz364, matrix(RANDEL364);
mkmat zz365, matrix(RANDEL365);
mkmat zz366, matrix(RANDEL366);
mkmat zz367, matrix(RANDEL367);
mkmat zz368, matrix(RANDEL368);
mkmat zz369, matrix(RANDEL369);
mkmat zz370, matrix(RANDEL370);
mkmat zz371, matrix(RANDEL371);
mkmat zz372, matrix(RANDEL372);
mkmat zz373, matrix(RANDEL373);
mkmat zz374, matrix(RANDEL374);
mkmat zz375, matrix(RANDEL375);
mkmat zz376, matrix(RANDEL376);
mkmat zz377, matrix(RANDEL377);
mkmat zz378, matrix(RANDEL378);
mkmat zz379, matrix(RANDEL379);
mkmat zz380, matrix(RANDEL380);
mkmat zz381, matrix(RANDEL381);
mkmat zz382, matrix(RANDEL382);
mkmat zz383, matrix(RANDEL383);
mkmat zz384, matrix(RANDEL384);
mkmat zz385, matrix(RANDEL385);
mkmat zz386, matrix(RANDEL386);
mkmat zz387, matrix(RANDEL387);
mkmat zz388, matrix(RANDEL388);
mkmat zz389, matrix(RANDEL389);
mkmat zz390, matrix(RANDEL390);
mkmat zz391, matrix(RANDEL391);
mkmat zz392, matrix(RANDEL392);
mkmat zz393, matrix(RANDEL393);
mkmat zz394, matrix(RANDEL394);
mkmat zz395, matrix(RANDEL395);
mkmat zz396, matrix(RANDEL396);
mkmat zz397, matrix(RANDEL397);
mkmat zz398, matrix(RANDEL398);
mkmat zz399, matrix(RANDEL399);

mkmat zz400, matrix(RANDEL400);
mkmat zz401, matrix(RANDEL401);
mkmat zz402, matrix(RANDEL402);
mkmat zz403, matrix(RANDEL403);
mkmat zz404, matrix(RANDEL404);
mkmat zz405, matrix(RANDEL405);
mkmat zz406, matrix(RANDEL406);
mkmat zz407, matrix(RANDEL407);
mkmat zz408, matrix(RANDEL408);
mkmat zz409, matrix(RANDEL409);
mkmat zz410, matrix(RANDEL410);
mkmat zz411, matrix(RANDEL411);
mkmat zz412, matrix(RANDEL412);
mkmat zz413, matrix(RANDEL413);
mkmat zz414, matrix(RANDEL414);
mkmat zz415, matrix(RANDEL415);
mkmat zz416, matrix(RANDEL416);
mkmat zz417, matrix(RANDEL417);
mkmat zz418, matrix(RANDEL418);
mkmat zz419, matrix(RANDEL419);
mkmat zz420, matrix(RANDEL420);
mkmat zz421, matrix(RANDEL421);
mkmat zz422, matrix(RANDEL422);
mkmat zz423, matrix(RANDEL423);
mkmat zz424, matrix(RANDEL424);
mkmat zz425, matrix(RANDEL425);
mkmat zz426, matrix(RANDEL426);
mkmat zz427, matrix(RANDEL427);
mkmat zz428, matrix(RANDEL428);
mkmat zz429, matrix(RANDEL429);
mkmat zz430, matrix(RANDEL430);
mkmat zz431, matrix(RANDEL431);
mkmat zz432, matrix(RANDEL432);
mkmat zz433, matrix(RANDEL433);
mkmat zz434, matrix(RANDEL434);
mkmat zz435, matrix(RANDEL435);
mkmat zz436, matrix(RANDEL436);
mkmat zz437, matrix(RANDEL437);
mkmat zz438, matrix(RANDEL438);
mkmat zz439, matrix(RANDEL439);
mkmat zz440, matrix(RANDEL440);
mkmat zz441, matrix(RANDEL441);
mkmat zz442, matrix(RANDEL442);
mkmat zz443, matrix(RANDEL443);
mkmat zz444, matrix(RANDEL444);
mkmat zz445, matrix(RANDEL445);
mkmat zz446, matrix(RANDEL446);
mkmat zz447, matrix(RANDEL447);
mkmat zz448, matrix(RANDEL448);
mkmat zz449, matrix(RANDEL449);
mkmat zz450, matrix(RANDEL450);
mkmat zz451, matrix(RANDEL451);
mkmat zz452, matrix(RANDEL452);
mkmat zz453, matrix(RANDEL453);
mkmat zz454, matrix(RANDEL454);
mkmat zz455, matrix(RANDEL455);
mkmat zz456, matrix(RANDEL456);
mkmat zz457, matrix(RANDEL457);
mkmat zz458, matrix(RANDEL458);
mkmat zz459, matrix(RANDEL459);
mkmat zz460, matrix(RANDEL460);
mkmat zz461, matrix(RANDEL461);
mkmat zz462, matrix(RANDEL462);
mkmat zz463, matrix(RANDEL463);
mkmat zz464, matrix(RANDEL464);
mkmat zz465, matrix(RANDEL465);
mkmat zz466, matrix(RANDEL466);
mkmat zz467, matrix(RANDEL467);
mkmat zz468, matrix(RANDEL468);
mkmat zz469, matrix(RANDEL469);
mkmat zz470, matrix(RANDEL470);
mkmat zz471, matrix(RANDEL471);
mkmat zz472, matrix(RANDEL472);
mkmat zz473, matrix(RANDEL473);
mkmat zz474, matrix(RANDEL474);
mkmat zz475, matrix(RANDEL475);
mkmat zz476, matrix(RANDEL476);
mkmat zz477, matrix(RANDEL477);
mkmat zz478, matrix(RANDEL478);
mkmat zz479, matrix(RANDEL479);
mkmat zz480, matrix(RANDEL480);
mkmat zz481, matrix(RANDEL481);
mkmat zz482, matrix(RANDEL482);
mkmat zz483, matrix(RANDEL483);
mkmat zz484, matrix(RANDEL484);
mkmat zz485, matrix(RANDEL485);
mkmat zz486, matrix(RANDEL486);
mkmat zz487, matrix(RANDEL487);
mkmat zz488, matrix(RANDEL488);
mkmat zz489, matrix(RANDEL489);
mkmat zz490, matrix(RANDEL490);
mkmat zz491, matrix(RANDEL491);
mkmat zz492, matrix(RANDEL492);
mkmat zz493, matrix(RANDEL493);
mkmat zz494, matrix(RANDEL494);
mkmat zz495, matrix(RANDEL495);
mkmat zz496, matrix(RANDEL496);
mkmat zz497, matrix(RANDEL497);
mkmat zz498, matrix(RANDEL498);
mkmat zz499, matrix(RANDEL499);

mkmat zz500, matrix(RANDEL500);
mkmat zz501, matrix(RANDEL501);
mkmat zz502, matrix(RANDEL502);
mkmat zz503, matrix(RANDEL503);
mkmat zz504, matrix(RANDEL504);
mkmat zz505, matrix(RANDEL505);
mkmat zz506, matrix(RANDEL506);
mkmat zz507, matrix(RANDEL507);
mkmat zz508, matrix(RANDEL508);
mkmat zz509, matrix(RANDEL509);
mkmat zz510, matrix(RANDEL510);
mkmat zz511, matrix(RANDEL511);
mkmat zz512, matrix(RANDEL512);
mkmat zz513, matrix(RANDEL513);
mkmat zz514, matrix(RANDEL514);
mkmat zz515, matrix(RANDEL515);
mkmat zz516, matrix(RANDEL516);
mkmat zz517, matrix(RANDEL517);
mkmat zz518, matrix(RANDEL518);
mkmat zz519, matrix(RANDEL519);
mkmat zz520, matrix(RANDEL520);
mkmat zz521, matrix(RANDEL521);
mkmat zz522, matrix(RANDEL522);
mkmat zz523, matrix(RANDEL523);
mkmat zz524, matrix(RANDEL524);
mkmat zz525, matrix(RANDEL525);
mkmat zz526, matrix(RANDEL526);
mkmat zz527, matrix(RANDEL527);
mkmat zz528, matrix(RANDEL528);
mkmat zz529, matrix(RANDEL529);
mkmat zz530, matrix(RANDEL530);
mkmat zz531, matrix(RANDEL531);
mkmat zz532, matrix(RANDEL532);
mkmat zz533, matrix(RANDEL533);
mkmat zz534, matrix(RANDEL534);
mkmat zz535, matrix(RANDEL535);
mkmat zz536, matrix(RANDEL536);
mkmat zz537, matrix(RANDEL537);
mkmat zz538, matrix(RANDEL538);
mkmat zz539, matrix(RANDEL539);
mkmat zz540, matrix(RANDEL540);
mkmat zz541, matrix(RANDEL541);
mkmat zz542, matrix(RANDEL542);
mkmat zz543, matrix(RANDEL543);
mkmat zz544, matrix(RANDEL544);
mkmat zz545, matrix(RANDEL545);
mkmat zz546, matrix(RANDEL546);
mkmat zz547, matrix(RANDEL547);
mkmat zz548, matrix(RANDEL548);
mkmat zz549, matrix(RANDEL549);
mkmat zz550, matrix(RANDEL550);
mkmat zz551, matrix(RANDEL551);
mkmat zz552, matrix(RANDEL552);
mkmat zz553, matrix(RANDEL553);
mkmat zz554, matrix(RANDEL554);
mkmat zz555, matrix(RANDEL555);
mkmat zz556, matrix(RANDEL556);
mkmat zz557, matrix(RANDEL557);
mkmat zz558, matrix(RANDEL558);
mkmat zz559, matrix(RANDEL559);
mkmat zz560, matrix(RANDEL560);
mkmat zz561, matrix(RANDEL561);
mkmat zz562, matrix(RANDEL562);
mkmat zz563, matrix(RANDEL563);
mkmat zz564, matrix(RANDEL564);
mkmat zz565, matrix(RANDEL565);
mkmat zz566, matrix(RANDEL566);
mkmat zz567, matrix(RANDEL567);
mkmat zz568, matrix(RANDEL568);
mkmat zz569, matrix(RANDEL569);
mkmat zz570, matrix(RANDEL570);
mkmat zz571, matrix(RANDEL571);
mkmat zz572, matrix(RANDEL572);
mkmat zz573, matrix(RANDEL573);
mkmat zz574, matrix(RANDEL574);
mkmat zz575, matrix(RANDEL575);
mkmat zz576, matrix(RANDEL576);
mkmat zz577, matrix(RANDEL577);
mkmat zz578, matrix(RANDEL578);
mkmat zz579, matrix(RANDEL579);
mkmat zz580, matrix(RANDEL580);
mkmat zz581, matrix(RANDEL581);
mkmat zz582, matrix(RANDEL582);
mkmat zz583, matrix(RANDEL583);
mkmat zz584, matrix(RANDEL584);
mkmat zz585, matrix(RANDEL585);
mkmat zz586, matrix(RANDEL586);
mkmat zz587, matrix(RANDEL587);
mkmat zz588, matrix(RANDEL588);
mkmat zz589, matrix(RANDEL589);
mkmat zz590, matrix(RANDEL590);
mkmat zz591, matrix(RANDEL591);
mkmat zz592, matrix(RANDEL592);
mkmat zz593, matrix(RANDEL593);
mkmat zz594, matrix(RANDEL594);
mkmat zz595, matrix(RANDEL595);
mkmat zz596, matrix(RANDEL596);
mkmat zz597, matrix(RANDEL597);
mkmat zz598, matrix(RANDEL598);
mkmat zz599, matrix(RANDEL599);

mkmat zz600, matrix(RANDEL600);
mkmat zz601, matrix(RANDEL601);
mkmat zz602, matrix(RANDEL602);
mkmat zz603, matrix(RANDEL603);
mkmat zz604, matrix(RANDEL604);
mkmat zz605, matrix(RANDEL605);
mkmat zz606, matrix(RANDEL606);
mkmat zz607, matrix(RANDEL607);
mkmat zz608, matrix(RANDEL608);
mkmat zz609, matrix(RANDEL609);
mkmat zz610, matrix(RANDEL610);
mkmat zz611, matrix(RANDEL611);
mkmat zz612, matrix(RANDEL612);
mkmat zz613, matrix(RANDEL613);
mkmat zz614, matrix(RANDEL614);
mkmat zz615, matrix(RANDEL615);
mkmat zz616, matrix(RANDEL616);
mkmat zz617, matrix(RANDEL617);
mkmat zz618, matrix(RANDEL618);
mkmat zz619, matrix(RANDEL619);
mkmat zz620, matrix(RANDEL620);
mkmat zz621, matrix(RANDEL621);
mkmat zz622, matrix(RANDEL622);
mkmat zz623, matrix(RANDEL623);
mkmat zz624, matrix(RANDEL624);
mkmat zz625, matrix(RANDEL625);
mkmat zz626, matrix(RANDEL626);
mkmat zz627, matrix(RANDEL627);
mkmat zz628, matrix(RANDEL628);
mkmat zz629, matrix(RANDEL629);
mkmat zz630, matrix(RANDEL630);
mkmat zz631, matrix(RANDEL631);
mkmat zz632, matrix(RANDEL632);
mkmat zz633, matrix(RANDEL633);
mkmat zz634, matrix(RANDEL634);
mkmat zz635, matrix(RANDEL635);
mkmat zz636, matrix(RANDEL636);
mkmat zz637, matrix(RANDEL637);
mkmat zz638, matrix(RANDEL638);
mkmat zz639, matrix(RANDEL639);
mkmat zz640, matrix(RANDEL640);
mkmat zz641, matrix(RANDEL641);
mkmat zz642, matrix(RANDEL642);
mkmat zz643, matrix(RANDEL643);
mkmat zz644, matrix(RANDEL644);
mkmat zz645, matrix(RANDEL645);
mkmat zz646, matrix(RANDEL646);
mkmat zz647, matrix(RANDEL647);
mkmat zz648, matrix(RANDEL648);
mkmat zz649, matrix(RANDEL649);
mkmat zz650, matrix(RANDEL650);
mkmat zz651, matrix(RANDEL651);
mkmat zz652, matrix(RANDEL652);
mkmat zz653, matrix(RANDEL653);
mkmat zz654, matrix(RANDEL654);
mkmat zz655, matrix(RANDEL655);
mkmat zz656, matrix(RANDEL656);
mkmat zz657, matrix(RANDEL657);
mkmat zz658, matrix(RANDEL658);
mkmat zz659, matrix(RANDEL659);
mkmat zz660, matrix(RANDEL660);
mkmat zz661, matrix(RANDEL661);
mkmat zz662, matrix(RANDEL662);
mkmat zz663, matrix(RANDEL663);
mkmat zz664, matrix(RANDEL664);
mkmat zz665, matrix(RANDEL665);
mkmat zz666, matrix(RANDEL666);
mkmat zz667, matrix(RANDEL667);
mkmat zz668, matrix(RANDEL668);
mkmat zz669, matrix(RANDEL669);
mkmat zz670, matrix(RANDEL670);
mkmat zz671, matrix(RANDEL671);
mkmat zz672, matrix(RANDEL672);
mkmat zz673, matrix(RANDEL673);
mkmat zz674, matrix(RANDEL674);
mkmat zz675, matrix(RANDEL675);
mkmat zz676, matrix(RANDEL676);
mkmat zz677, matrix(RANDEL677);
mkmat zz678, matrix(RANDEL678);
mkmat zz679, matrix(RANDEL679);
mkmat zz680, matrix(RANDEL680);
mkmat zz681, matrix(RANDEL681);
mkmat zz682, matrix(RANDEL682);
mkmat zz683, matrix(RANDEL683);
mkmat zz684, matrix(RANDEL684);
mkmat zz685, matrix(RANDEL685);
mkmat zz686, matrix(RANDEL686);
mkmat zz687, matrix(RANDEL687);
mkmat zz688, matrix(RANDEL688);
mkmat zz689, matrix(RANDEL689);
mkmat zz690, matrix(RANDEL690);
mkmat zz691, matrix(RANDEL691);
mkmat zz692, matrix(RANDEL692);
mkmat zz693, matrix(RANDEL693);
mkmat zz694, matrix(RANDEL694);
mkmat zz695, matrix(RANDEL695);
mkmat zz696, matrix(RANDEL696);
mkmat zz697, matrix(RANDEL697);
mkmat zz698, matrix(RANDEL698);
mkmat zz699, matrix(RANDEL699);

mkmat zz700, matrix(RANDEL700);
mkmat zz701, matrix(RANDEL701);
mkmat zz702, matrix(RANDEL702);
mkmat zz703, matrix(RANDEL703);
mkmat zz704, matrix(RANDEL704);
mkmat zz705, matrix(RANDEL705);
mkmat zz706, matrix(RANDEL706);
mkmat zz707, matrix(RANDEL707);
mkmat zz708, matrix(RANDEL708);
mkmat zz709, matrix(RANDEL709);
mkmat zz710, matrix(RANDEL710);
mkmat zz711, matrix(RANDEL711);
mkmat zz712, matrix(RANDEL712);
mkmat zz713, matrix(RANDEL713);
mkmat zz714, matrix(RANDEL714);
mkmat zz715, matrix(RANDEL715);
mkmat zz716, matrix(RANDEL716);
mkmat zz717, matrix(RANDEL717);
mkmat zz718, matrix(RANDEL718);
mkmat zz719, matrix(RANDEL719);
mkmat zz720, matrix(RANDEL720);
mkmat zz721, matrix(RANDEL721);
mkmat zz722, matrix(RANDEL722);
mkmat zz723, matrix(RANDEL723);
mkmat zz724, matrix(RANDEL724);
mkmat zz725, matrix(RANDEL725);
mkmat zz726, matrix(RANDEL726);
mkmat zz727, matrix(RANDEL727);
mkmat zz728, matrix(RANDEL728);
mkmat zz729, matrix(RANDEL729);
mkmat zz730, matrix(RANDEL730);
mkmat zz731, matrix(RANDEL731);
mkmat zz732, matrix(RANDEL732);
mkmat zz733, matrix(RANDEL733);
mkmat zz734, matrix(RANDEL734);
mkmat zz735, matrix(RANDEL735);
mkmat zz736, matrix(RANDEL736);
mkmat zz737, matrix(RANDEL737);
mkmat zz738, matrix(RANDEL738);
mkmat zz739, matrix(RANDEL739);
mkmat zz740, matrix(RANDEL740);
mkmat zz741, matrix(RANDEL741);
mkmat zz742, matrix(RANDEL742);
mkmat zz743, matrix(RANDEL743);
mkmat zz744, matrix(RANDEL744);
mkmat zz745, matrix(RANDEL745);
mkmat zz746, matrix(RANDEL746);
mkmat zz747, matrix(RANDEL747);
mkmat zz748, matrix(RANDEL748);
mkmat zz749, matrix(RANDEL749);
mkmat zz750, matrix(RANDEL750);
mkmat zz751, matrix(RANDEL751);
mkmat zz752, matrix(RANDEL752);
mkmat zz753, matrix(RANDEL753);
mkmat zz754, matrix(RANDEL754);
mkmat zz755, matrix(RANDEL755);
mkmat zz756, matrix(RANDEL756);
mkmat zz757, matrix(RANDEL757);
mkmat zz758, matrix(RANDEL758);
mkmat zz759, matrix(RANDEL759);
mkmat zz760, matrix(RANDEL760);
mkmat zz761, matrix(RANDEL761);
mkmat zz762, matrix(RANDEL762);
mkmat zz763, matrix(RANDEL763);
mkmat zz764, matrix(RANDEL764);
mkmat zz765, matrix(RANDEL765);
mkmat zz766, matrix(RANDEL766);
mkmat zz767, matrix(RANDEL767);
mkmat zz768, matrix(RANDEL768);
mkmat zz769, matrix(RANDEL769);
mkmat zz770, matrix(RANDEL770);
mkmat zz771, matrix(RANDEL771);
mkmat zz772, matrix(RANDEL772);
mkmat zz773, matrix(RANDEL773);
mkmat zz774, matrix(RANDEL774);
mkmat zz775, matrix(RANDEL775);
mkmat zz776, matrix(RANDEL776);
mkmat zz777, matrix(RANDEL777);
mkmat zz778, matrix(RANDEL778);
mkmat zz779, matrix(RANDEL779);
mkmat zz780, matrix(RANDEL780);
mkmat zz781, matrix(RANDEL781);
mkmat zz782, matrix(RANDEL782);
mkmat zz783, matrix(RANDEL783);
mkmat zz784, matrix(RANDEL784);
mkmat zz785, matrix(RANDEL785);
mkmat zz786, matrix(RANDEL786);
mkmat zz787, matrix(RANDEL787);
mkmat zz788, matrix(RANDEL788);
mkmat zz789, matrix(RANDEL789);
mkmat zz790, matrix(RANDEL790);
mkmat zz791, matrix(RANDEL791);
mkmat zz792, matrix(RANDEL792);
mkmat zz793, matrix(RANDEL793);
mkmat zz794, matrix(RANDEL794);
mkmat zz795, matrix(RANDEL795);
mkmat zz796, matrix(RANDEL796);
mkmat zz797, matrix(RANDEL797);
mkmat zz798, matrix(RANDEL798);
mkmat zz799, matrix(RANDEL799);

mkmat zz800, matrix(RANDEL800);
mkmat zz801, matrix(RANDEL801);
mkmat zz802, matrix(RANDEL802);
mkmat zz803, matrix(RANDEL803);
mkmat zz804, matrix(RANDEL804);
mkmat zz805, matrix(RANDEL805);
mkmat zz806, matrix(RANDEL806);
mkmat zz807, matrix(RANDEL807);
mkmat zz808, matrix(RANDEL808);
mkmat zz809, matrix(RANDEL809);
mkmat zz810, matrix(RANDEL810);
mkmat zz811, matrix(RANDEL811);
mkmat zz812, matrix(RANDEL812);
mkmat zz813, matrix(RANDEL813);
mkmat zz814, matrix(RANDEL814);
mkmat zz815, matrix(RANDEL815);
mkmat zz816, matrix(RANDEL816);
mkmat zz817, matrix(RANDEL817);
mkmat zz818, matrix(RANDEL818);
mkmat zz819, matrix(RANDEL819);
mkmat zz820, matrix(RANDEL820);
mkmat zz821, matrix(RANDEL821);
mkmat zz822, matrix(RANDEL822);
mkmat zz823, matrix(RANDEL823);
mkmat zz824, matrix(RANDEL824);
mkmat zz825, matrix(RANDEL825);
mkmat zz826, matrix(RANDEL826);
mkmat zz827, matrix(RANDEL827);
mkmat zz828, matrix(RANDEL828);
mkmat zz829, matrix(RANDEL829);
mkmat zz830, matrix(RANDEL830);
mkmat zz831, matrix(RANDEL831);
mkmat zz832, matrix(RANDEL832);
mkmat zz833, matrix(RANDEL833);
mkmat zz834, matrix(RANDEL834);
mkmat zz835, matrix(RANDEL835);
mkmat zz836, matrix(RANDEL836);
mkmat zz837, matrix(RANDEL837);
mkmat zz838, matrix(RANDEL838);
mkmat zz839, matrix(RANDEL839);
mkmat zz840, matrix(RANDEL840);
mkmat zz841, matrix(RANDEL841);
mkmat zz842, matrix(RANDEL842);
mkmat zz843, matrix(RANDEL843);
mkmat zz844, matrix(RANDEL844);
mkmat zz845, matrix(RANDEL845);
mkmat zz846, matrix(RANDEL846);
mkmat zz847, matrix(RANDEL847);
mkmat zz848, matrix(RANDEL848);
mkmat zz849, matrix(RANDEL849);
mkmat zz850, matrix(RANDEL850);
mkmat zz851, matrix(RANDEL851);
mkmat zz852, matrix(RANDEL852);
mkmat zz853, matrix(RANDEL853);
mkmat zz854, matrix(RANDEL854);
mkmat zz855, matrix(RANDEL855);
mkmat zz856, matrix(RANDEL856);
mkmat zz857, matrix(RANDEL857);
mkmat zz858, matrix(RANDEL858);
mkmat zz859, matrix(RANDEL859);
mkmat zz860, matrix(RANDEL860);
mkmat zz861, matrix(RANDEL861);
mkmat zz862, matrix(RANDEL862);
mkmat zz863, matrix(RANDEL863);
mkmat zz864, matrix(RANDEL864);
mkmat zz865, matrix(RANDEL865);
mkmat zz866, matrix(RANDEL866);
mkmat zz867, matrix(RANDEL867);
mkmat zz868, matrix(RANDEL868);
mkmat zz869, matrix(RANDEL869);
mkmat zz870, matrix(RANDEL870);
mkmat zz871, matrix(RANDEL871);
mkmat zz872, matrix(RANDEL872);
mkmat zz873, matrix(RANDEL873);
mkmat zz874, matrix(RANDEL874);
mkmat zz875, matrix(RANDEL875);
mkmat zz876, matrix(RANDEL876);
mkmat zz877, matrix(RANDEL877);
mkmat zz878, matrix(RANDEL878);
mkmat zz879, matrix(RANDEL879);
mkmat zz880, matrix(RANDEL880);
mkmat zz881, matrix(RANDEL881);
mkmat zz882, matrix(RANDEL882);
mkmat zz883, matrix(RANDEL883);
mkmat zz884, matrix(RANDEL884);
mkmat zz885, matrix(RANDEL885);
mkmat zz886, matrix(RANDEL886);
mkmat zz887, matrix(RANDEL887);
mkmat zz888, matrix(RANDEL888);
mkmat zz889, matrix(RANDEL889);
mkmat zz890, matrix(RANDEL890);
mkmat zz891, matrix(RANDEL891);
mkmat zz892, matrix(RANDEL892);
mkmat zz893, matrix(RANDEL893);
mkmat zz894, matrix(RANDEL894);
mkmat zz895, matrix(RANDEL895);
mkmat zz896, matrix(RANDEL896);
mkmat zz897, matrix(RANDEL897);
mkmat zz898, matrix(RANDEL898);
mkmat zz899, matrix(RANDEL899);

mkmat zz900, matrix(RANDEL900);
mkmat zz901, matrix(RANDEL901);
mkmat zz902, matrix(RANDEL902);
mkmat zz903, matrix(RANDEL903);
mkmat zz904, matrix(RANDEL904);
mkmat zz905, matrix(RANDEL905);
mkmat zz906, matrix(RANDEL906);
mkmat zz907, matrix(RANDEL907);
mkmat zz908, matrix(RANDEL908);
mkmat zz909, matrix(RANDEL909);
mkmat zz910, matrix(RANDEL910);
mkmat zz911, matrix(RANDEL911);
mkmat zz912, matrix(RANDEL912);
mkmat zz913, matrix(RANDEL913);
mkmat zz914, matrix(RANDEL914);
mkmat zz915, matrix(RANDEL915);
mkmat zz916, matrix(RANDEL916);
mkmat zz917, matrix(RANDEL917);
mkmat zz918, matrix(RANDEL918);
mkmat zz919, matrix(RANDEL919);
mkmat zz920, matrix(RANDEL920);
mkmat zz921, matrix(RANDEL921);
mkmat zz922, matrix(RANDEL922);
mkmat zz923, matrix(RANDEL923);
mkmat zz924, matrix(RANDEL924);
mkmat zz925, matrix(RANDEL925);
mkmat zz926, matrix(RANDEL926);
mkmat zz927, matrix(RANDEL927);
mkmat zz928, matrix(RANDEL928);
mkmat zz929, matrix(RANDEL929);
mkmat zz930, matrix(RANDEL930);
mkmat zz931, matrix(RANDEL931);
mkmat zz932, matrix(RANDEL932);
mkmat zz933, matrix(RANDEL933);
mkmat zz934, matrix(RANDEL934);
mkmat zz935, matrix(RANDEL935);
mkmat zz936, matrix(RANDEL936);
mkmat zz937, matrix(RANDEL937);
mkmat zz938, matrix(RANDEL938);
mkmat zz939, matrix(RANDEL939);
mkmat zz940, matrix(RANDEL940);
mkmat zz941, matrix(RANDEL941);
mkmat zz942, matrix(RANDEL942);
mkmat zz943, matrix(RANDEL943);
mkmat zz944, matrix(RANDEL944);
mkmat zz945, matrix(RANDEL945);
mkmat zz946, matrix(RANDEL946);
mkmat zz947, matrix(RANDEL947);
mkmat zz948, matrix(RANDEL948);
mkmat zz949, matrix(RANDEL949);
mkmat zz950, matrix(RANDEL950);
mkmat zz951, matrix(RANDEL951);
mkmat zz952, matrix(RANDEL952);
mkmat zz953, matrix(RANDEL953);
mkmat zz954, matrix(RANDEL954);
mkmat zz955, matrix(RANDEL955);
mkmat zz956, matrix(RANDEL956);
mkmat zz957, matrix(RANDEL957);
mkmat zz958, matrix(RANDEL958);
mkmat zz959, matrix(RANDEL959);
mkmat zz960, matrix(RANDEL960);
mkmat zz961, matrix(RANDEL961);
mkmat zz962, matrix(RANDEL962);
mkmat zz963, matrix(RANDEL963);
mkmat zz964, matrix(RANDEL964);
mkmat zz965, matrix(RANDEL965);
mkmat zz966, matrix(RANDEL966);
mkmat zz967, matrix(RANDEL967);
mkmat zz968, matrix(RANDEL968);
mkmat zz969, matrix(RANDEL969);
mkmat zz970, matrix(RANDEL970);
mkmat zz971, matrix(RANDEL971);
mkmat zz972, matrix(RANDEL972);
mkmat zz973, matrix(RANDEL973);
mkmat zz974, matrix(RANDEL974);
mkmat zz975, matrix(RANDEL975);
mkmat zz976, matrix(RANDEL976);
mkmat zz977, matrix(RANDEL977);
mkmat zz978, matrix(RANDEL978);
mkmat zz979, matrix(RANDEL979);
mkmat zz980, matrix(RANDEL980);
mkmat zz981, matrix(RANDEL981);
mkmat zz982, matrix(RANDEL982);
mkmat zz983, matrix(RANDEL983);
mkmat zz984, matrix(RANDEL984);
mkmat zz985, matrix(RANDEL985);
mkmat zz986, matrix(RANDEL986);
mkmat zz987, matrix(RANDEL987);
mkmat zz988, matrix(RANDEL988);
mkmat zz989, matrix(RANDEL989);
mkmat zz990, matrix(RANDEL990);
mkmat zz991, matrix(RANDEL991);
mkmat zz992, matrix(RANDEL992);
mkmat zz993, matrix(RANDEL993);
mkmat zz994, matrix(RANDEL994);
mkmat zz995, matrix(RANDEL995);
mkmat zz996, matrix(RANDEL996);
mkmat zz997, matrix(RANDEL997);
mkmat zz998, matrix(RANDEL998);
mkmat zz999, matrix(RANDEL999);
mkmat zz1000, matrix(RANDEL1000);

matrix SHOCKDELt1=RANDEL1,RANDEL2,RANDEL3,RANDEL4,RANDEL5,RANDEL6,RANDEL7,RANDEL8,RANDEL9,RANDEL10;
matrix SHOCKDELt2=RANDEL11,RANDEL12,RANDEL13,RANDEL14,RANDEL15,RANDEL16,RANDEL17,RANDEL18,RANDEL19,RANDEL20;
matrix SHOCKDELt3=RANDEL21,RANDEL22,RANDEL23,RANDEL24,RANDEL25;
matrix SHOCKDELt3=RANDEL21,RANDEL22,RANDEL23,RANDEL24,RANDEL25,RANDEL26,RANDEL27,RANDEL28,RANDEL29,RANDEL30;
matrix SHOCKDELt4=RANDEL31,RANDEL32,RANDEL33,RANDEL34,RANDEL35,RANDEL36,RANDEL37,RANDEL38,RANDEL39,RANDEL40;
matrix SHOCKDELt5=RANDEL41,RANDEL42,RANDEL43,RANDEL44,RANDEL45,RANDEL46,RANDEL47,RANDEL48,RANDEL49,RANDEL50;
matrix SHOCKDELt6=RANDEL51,RANDEL52,RANDEL53,RANDEL54,RANDEL55,RANDEL56,RANDEL57,RANDEL58,RANDEL59,RANDEL60;
matrix SHOCKDELt7=RANDEL61,RANDEL62,RANDEL63,RANDEL64,RANDEL65,RANDEL66,RANDEL67,RANDEL68,RANDEL69,RANDEL70;
matrix SHOCKDELt8=RANDEL71,RANDEL72,RANDEL73,RANDEL74,RANDEL75,RANDEL76,RANDEL77,RANDEL78,RANDEL79,RANDEL80;
matrix SHOCKDELt9=RANDEL81,RANDEL82,RANDEL83,RANDEL84,RANDEL85,RANDEL86,RANDEL87,RANDEL88,RANDEL89,RANDEL90;
matrix SHOCKDELt10=RANDEL91,RANDEL92,RANDEL93,RANDEL94,RANDEL95,RANDEL96,RANDEL97,RANDEL98,RANDEL99,RANDEL100;
matrix SHOCKDELt11=RANDEL101,RANDEL102,RANDEL103,RANDEL104,RANDEL105,RANDEL106,RANDEL107,RANDEL108,RANDEL109,RANDEL110;
matrix SHOCKDELt12=RANDEL111,RANDEL112,RANDEL113,RANDEL114,RANDEL115,RANDEL116,RANDEL117,RANDEL118,RANDEL119,RANDEL120;
matrix SHOCKDELt13=RANDEL121,RANDEL122,RANDEL123,RANDEL124,RANDEL125,RANDEL126,RANDEL127,RANDEL128,RANDEL129,RANDEL130;
matrix SHOCKDELt14=RANDEL131,RANDEL132,RANDEL133,RANDEL134,RANDEL135,RANDEL136,RANDEL137,RANDEL138,RANDEL139,RANDEL140;
matrix SHOCKDELt15=RANDEL141,RANDEL142,RANDEL143,RANDEL144,RANDEL145,RANDEL146,RANDEL147,RANDEL148,RANDEL149,RANDEL150;
matrix SHOCKDELt16=RANDEL151,RANDEL152,RANDEL153,RANDEL154,RANDEL155,RANDEL156,RANDEL157,RANDEL158,RANDEL159,RANDEL160;
matrix SHOCKDELt17=RANDEL161,RANDEL162,RANDEL163,RANDEL164,RANDEL165,RANDEL166,RANDEL167,RANDEL168,RANDEL169,RANDEL170;
matrix SHOCKDELt18=RANDEL171,RANDEL172,RANDEL173,RANDEL174,RANDEL175,RANDEL176,RANDEL177,RANDEL178,RANDEL179,RANDEL180;
matrix SHOCKDELt19=RANDEL181,RANDEL182,RANDEL183,RANDEL184,RANDEL185,RANDEL186,RANDEL187,RANDEL188,RANDEL189,RANDEL190;
matrix SHOCKDELt20=RANDEL191,RANDEL192,RANDEL193,RANDEL194,RANDEL195,RANDEL196,RANDEL197,RANDEL198,RANDEL199,RANDEL200;
matrix SHOCKDELt21=RANDEL201,RANDEL202,RANDEL203,RANDEL204,RANDEL205,RANDEL206,RANDEL207,RANDEL208,RANDEL209,RANDEL210;
matrix SHOCKDELt22=RANDEL211,RANDEL212,RANDEL213,RANDEL214,RANDEL215,RANDEL216,RANDEL217,RANDEL218,RANDEL219,RANDEL220;
matrix SHOCKDELt23=RANDEL221,RANDEL222,RANDEL223,RANDEL224,RANDEL225,RANDEL226,RANDEL227,RANDEL228,RANDEL229,RANDEL230;
matrix SHOCKDELt24=RANDEL231,RANDEL232,RANDEL233,RANDEL234,RANDEL235,RANDEL236,RANDEL237,RANDEL238,RANDEL239,RANDEL240;
matrix SHOCKDELt25=RANDEL241,RANDEL242,RANDEL243,RANDEL244,RANDEL245,RANDEL246,RANDEL247,RANDEL248,RANDEL249,RANDEL250;
matrix SHOCKDELt26=RANDEL251,RANDEL252,RANDEL253,RANDEL254,RANDEL255,RANDEL256,RANDEL257,RANDEL258,RANDEL259,RANDEL260;
matrix SHOCKDELt27=RANDEL261,RANDEL262,RANDEL263,RANDEL264,RANDEL265,RANDEL266,RANDEL267,RANDEL268,RANDEL269,RANDEL270;
matrix SHOCKDELt28=RANDEL271,RANDEL272,RANDEL273,RANDEL274,RANDEL275,RANDEL276,RANDEL277,RANDEL278,RANDEL279,RANDEL280;
matrix SHOCKDELt29=RANDEL281,RANDEL282,RANDEL283,RANDEL284,RANDEL285,RANDEL286,RANDEL287,RANDEL288,RANDEL289,RANDEL290;
matrix SHOCKDELt30=RANDEL291,RANDEL292,RANDEL293,RANDEL294,RANDEL295,RANDEL296,RANDEL297,RANDEL298,RANDEL299,RANDEL300;
matrix SHOCKDELt31=RANDEL301,RANDEL302,RANDEL303,RANDEL304,RANDEL305,RANDEL306,RANDEL307,RANDEL308,RANDEL309,RANDEL310;
matrix SHOCKDELt32=RANDEL311,RANDEL312,RANDEL313,RANDEL314,RANDEL315,RANDEL316,RANDEL317,RANDEL318,RANDEL319,RANDEL320;
matrix SHOCKDELt33=RANDEL321,RANDEL322,RANDEL323,RANDEL324,RANDEL325,RANDEL326,RANDEL327,RANDEL328,RANDEL329,RANDEL330;
matrix SHOCKDELt34=RANDEL331,RANDEL332,RANDEL333,RANDEL334,RANDEL335,RANDEL336,RANDEL337,RANDEL338,RANDEL339,RANDEL340;
matrix SHOCKDELt35=RANDEL341,RANDEL342,RANDEL343,RANDEL344,RANDEL345,RANDEL346,RANDEL347,RANDEL348,RANDEL349,RANDEL350;
matrix SHOCKDELt36=RANDEL351,RANDEL352,RANDEL353,RANDEL354,RANDEL355,RANDEL356,RANDEL357,RANDEL358,RANDEL359,RANDEL360;
matrix SHOCKDELt37=RANDEL361,RANDEL362,RANDEL363,RANDEL364,RANDEL365,RANDEL366,RANDEL367,RANDEL368,RANDEL369,RANDEL370;
matrix SHOCKDELt38=RANDEL371,RANDEL372,RANDEL373,RANDEL374,RANDEL375,RANDEL376,RANDEL377,RANDEL378,RANDEL379,RANDEL380;
matrix SHOCKDELt39=RANDEL381,RANDEL382,RANDEL383,RANDEL384,RANDEL385,RANDEL386,RANDEL387,RANDEL388,RANDEL389,RANDEL390;
matrix SHOCKDELt40=RANDEL391,RANDEL392,RANDEL393,RANDEL394,RANDEL395,RANDEL396,RANDEL397,RANDEL398,RANDEL399,RANDEL400;
matrix SHOCKDELt41=RANDEL401,RANDEL402,RANDEL403,RANDEL404,RANDEL405,RANDEL406,RANDEL407,RANDEL408,RANDEL409,RANDEL410;
matrix SHOCKDELt42=RANDEL411,RANDEL412,RANDEL413,RANDEL414,RANDEL415,RANDEL416,RANDEL417,RANDEL418,RANDEL419,RANDEL420;
matrix SHOCKDELt43=RANDEL421,RANDEL422,RANDEL423,RANDEL424,RANDEL425,RANDEL426,RANDEL427,RANDEL428,RANDEL429,RANDEL430;
matrix SHOCKDELt44=RANDEL431,RANDEL432,RANDEL433,RANDEL434,RANDEL435,RANDEL436,RANDEL437,RANDEL438,RANDEL439,RANDEL440;
matrix SHOCKDELt45=RANDEL441,RANDEL442,RANDEL443,RANDEL444,RANDEL445,RANDEL446,RANDEL447,RANDEL448,RANDEL449,RANDEL450;
matrix SHOCKDELt46=RANDEL451,RANDEL452,RANDEL453,RANDEL454,RANDEL455,RANDEL456,RANDEL457,RANDEL458,RANDEL459,RANDEL460;
matrix SHOCKDELt47=RANDEL461,RANDEL462,RANDEL463,RANDEL464,RANDEL465,RANDEL466,RANDEL467,RANDEL468,RANDEL469,RANDEL470;
matrix SHOCKDELt48=RANDEL471,RANDEL472,RANDEL473,RANDEL474,RANDEL475,RANDEL476,RANDEL477,RANDEL478,RANDEL479,RANDEL480;
matrix SHOCKDELt49=RANDEL481,RANDEL482,RANDEL483,RANDEL484,RANDEL485,RANDEL486,RANDEL487,RANDEL488,RANDEL489,RANDEL490;
matrix SHOCKDELt50=RANDEL491,RANDEL492,RANDEL493,RANDEL494,RANDEL495,RANDEL496,RANDEL497,RANDEL498,RANDEL499,RANDEL500;
matrix SHOCKDELt51=RANDEL501,RANDEL502,RANDEL503,RANDEL504,RANDEL505,RANDEL506,RANDEL507,RANDEL508,RANDEL509,RANDEL510;
matrix SHOCKDELt52=RANDEL511,RANDEL512,RANDEL513,RANDEL514,RANDEL515,RANDEL516,RANDEL517,RANDEL518,RANDEL519,RANDEL520;
matrix SHOCKDELt53=RANDEL521,RANDEL522,RANDEL523,RANDEL524,RANDEL525,RANDEL526,RANDEL527,RANDEL528,RANDEL529,RANDEL530;
matrix SHOCKDELt54=RANDEL531,RANDEL532,RANDEL533,RANDEL534,RANDEL535,RANDEL536,RANDEL537,RANDEL538,RANDEL539,RANDEL540;
matrix SHOCKDELt55=RANDEL541,RANDEL542,RANDEL543,RANDEL544,RANDEL545,RANDEL546,RANDEL547,RANDEL548,RANDEL549,RANDEL550;
matrix SHOCKDELt56=RANDEL551,RANDEL552,RANDEL553,RANDEL554,RANDEL555,RANDEL556,RANDEL557,RANDEL558,RANDEL559,RANDEL560;
matrix SHOCKDELt57=RANDEL561,RANDEL562,RANDEL563,RANDEL564,RANDEL565,RANDEL566,RANDEL567,RANDEL568,RANDEL569,RANDEL570;
matrix SHOCKDELt58=RANDEL571,RANDEL572,RANDEL573,RANDEL574,RANDEL575,RANDEL576,RANDEL577,RANDEL578,RANDEL579,RANDEL580;
matrix SHOCKDELt59=RANDEL581,RANDEL582,RANDEL583,RANDEL584,RANDEL585,RANDEL586,RANDEL587,RANDEL588,RANDEL589,RANDEL590;
matrix SHOCKDELt60=RANDEL591,RANDEL592,RANDEL593,RANDEL594,RANDEL595,RANDEL596,RANDEL597,RANDEL598,RANDEL599,RANDEL600;
matrix SHOCKDELt61=RANDEL601,RANDEL602,RANDEL603,RANDEL604,RANDEL605,RANDEL606,RANDEL607,RANDEL608,RANDEL609,RANDEL610;
matrix SHOCKDELt62=RANDEL611,RANDEL612,RANDEL613,RANDEL614,RANDEL615,RANDEL616,RANDEL617,RANDEL618,RANDEL619,RANDEL620;
matrix SHOCKDELt63=RANDEL621,RANDEL622,RANDEL623,RANDEL624,RANDEL625,RANDEL626,RANDEL627,RANDEL628,RANDEL629,RANDEL630;
matrix SHOCKDELt64=RANDEL631,RANDEL632,RANDEL633,RANDEL634,RANDEL635,RANDEL636,RANDEL637,RANDEL638,RANDEL639,RANDEL640;
matrix SHOCKDELt65=RANDEL641,RANDEL642,RANDEL643,RANDEL644,RANDEL645,RANDEL646,RANDEL647,RANDEL648,RANDEL649,RANDEL650;
matrix SHOCKDELt66=RANDEL651,RANDEL652,RANDEL653,RANDEL654,RANDEL655,RANDEL656,RANDEL657,RANDEL658,RANDEL659,RANDEL660;
matrix SHOCKDELt67=RANDEL661,RANDEL662,RANDEL663,RANDEL664,RANDEL665,RANDEL666,RANDEL667,RANDEL668,RANDEL669,RANDEL670;
matrix SHOCKDELt68=RANDEL671,RANDEL672,RANDEL673,RANDEL674,RANDEL675,RANDEL676,RANDEL677,RANDEL678,RANDEL679,RANDEL680;
matrix SHOCKDELt69=RANDEL681,RANDEL682,RANDEL683,RANDEL684,RANDEL685,RANDEL686,RANDEL687,RANDEL688,RANDEL689,RANDEL690;
matrix SHOCKDELt70=RANDEL691,RANDEL692,RANDEL693,RANDEL694,RANDEL695,RANDEL696,RANDEL697,RANDEL698,RANDEL699,RANDEL700;
matrix SHOCKDELt71=RANDEL701,RANDEL702,RANDEL703,RANDEL704,RANDEL705,RANDEL706,RANDEL707,RANDEL708,RANDEL709,RANDEL710;
matrix SHOCKDELt72=RANDEL711,RANDEL712,RANDEL713,RANDEL714,RANDEL715,RANDEL716,RANDEL717,RANDEL718,RANDEL719,RANDEL720;
matrix SHOCKDELt73=RANDEL721,RANDEL722,RANDEL723,RANDEL724,RANDEL725,RANDEL726,RANDEL727,RANDEL728,RANDEL729,RANDEL730;
matrix SHOCKDELt74=RANDEL731,RANDEL732,RANDEL733,RANDEL734,RANDEL735,RANDEL736,RANDEL737,RANDEL738,RANDEL739,RANDEL740;
matrix SHOCKDELt75=RANDEL741,RANDEL742,RANDEL743,RANDEL744,RANDEL745,RANDEL746,RANDEL747,RANDEL748,RANDEL749,RANDEL750;
matrix SHOCKDELt76=RANDEL751,RANDEL752,RANDEL753,RANDEL754,RANDEL755,RANDEL756,RANDEL757,RANDEL758,RANDEL759,RANDEL760;
matrix SHOCKDELt77=RANDEL761,RANDEL762,RANDEL763,RANDEL764,RANDEL765,RANDEL766,RANDEL767,RANDEL768,RANDEL769,RANDEL770;
matrix SHOCKDELt78=RANDEL771,RANDEL772,RANDEL773,RANDEL774,RANDEL775,RANDEL776,RANDEL777,RANDEL778,RANDEL779,RANDEL780;
matrix SHOCKDELt79=RANDEL781,RANDEL782,RANDEL783,RANDEL784,RANDEL785,RANDEL786,RANDEL787,RANDEL788,RANDEL789,RANDEL790;
matrix SHOCKDELt80=RANDEL791,RANDEL792,RANDEL793,RANDEL794,RANDEL795,RANDEL796,RANDEL797,RANDEL798,RANDEL799,RANDEL800;
matrix SHOCKDELt81=RANDEL801,RANDEL802,RANDEL803,RANDEL804,RANDEL805,RANDEL806,RANDEL807,RANDEL808,RANDEL809,RANDEL810;
matrix SHOCKDELt82=RANDEL811,RANDEL812,RANDEL813,RANDEL814,RANDEL815,RANDEL816,RANDEL817,RANDEL818,RANDEL819,RANDEL820;
matrix SHOCKDELt83=RANDEL821,RANDEL822,RANDEL823,RANDEL824,RANDEL825,RANDEL826,RANDEL827,RANDEL828,RANDEL829,RANDEL830;
matrix SHOCKDELt84=RANDEL831,RANDEL832,RANDEL833,RANDEL834,RANDEL835,RANDEL836,RANDEL837,RANDEL838,RANDEL839,RANDEL840;
matrix SHOCKDELt85=RANDEL841,RANDEL842,RANDEL843,RANDEL844,RANDEL845,RANDEL846,RANDEL847,RANDEL848,RANDEL849,RANDEL850;
matrix SHOCKDELt86=RANDEL851,RANDEL852,RANDEL853,RANDEL854,RANDEL855,RANDEL856,RANDEL857,RANDEL858,RANDEL859,RANDEL860;
matrix SHOCKDELt87=RANDEL861,RANDEL862,RANDEL863,RANDEL864,RANDEL865,RANDEL866,RANDEL867,RANDEL868,RANDEL869,RANDEL870;
matrix SHOCKDELt88=RANDEL871,RANDEL872,RANDEL873,RANDEL874,RANDEL875,RANDEL876,RANDEL877,RANDEL878,RANDEL879,RANDEL880;
matrix SHOCKDELt89=RANDEL881,RANDEL882,RANDEL883,RANDEL884,RANDEL885,RANDEL886,RANDEL887,RANDEL888,RANDEL889,RANDEL890;
matrix SHOCKDELt90=RANDEL891,RANDEL892,RANDEL893,RANDEL894,RANDEL895,RANDEL896,RANDEL897,RANDEL898,RANDEL899,RANDEL900;
matrix SHOCKDELt91=RANDEL901,RANDEL902,RANDEL903,RANDEL904,RANDEL905,RANDEL906,RANDEL907,RANDEL908,RANDEL909,RANDEL910;
matrix SHOCKDELt92=RANDEL911,RANDEL912,RANDEL913,RANDEL914,RANDEL915,RANDEL916,RANDEL917,RANDEL918,RANDEL919,RANDEL920;
matrix SHOCKDELt93=RANDEL921,RANDEL922,RANDEL923,RANDEL924,RANDEL925,RANDEL926,RANDEL927,RANDEL928,RANDEL929,RANDEL930;
matrix SHOCKDELt94=RANDEL931,RANDEL932,RANDEL933,RANDEL934,RANDEL935,RANDEL936,RANDEL937,RANDEL938,RANDEL939,RANDEL940;
matrix SHOCKDELt95=RANDEL941,RANDEL942,RANDEL943,RANDEL944,RANDEL945,RANDEL946,RANDEL947,RANDEL948,RANDEL949,RANDEL950;
matrix SHOCKDELt96=RANDEL951,RANDEL952,RANDEL953,RANDEL954,RANDEL955,RANDEL956,RANDEL957,RANDEL958,RANDEL959,RANDEL960;
matrix SHOCKDELt97=RANDEL961,RANDEL962,RANDEL963,RANDEL964,RANDEL965,RANDEL966,RANDEL967,RANDEL968,RANDEL969,RANDEL970;
matrix SHOCKDELt98=RANDEL971,RANDEL972,RANDEL973,RANDEL974,RANDEL975,RANDEL976,RANDEL977,RANDEL978,RANDEL979,RANDEL980;
matrix SHOCKDELt99=RANDEL981,RANDEL982,RANDEL983,RANDEL984,RANDEL985,RANDEL986,RANDEL987,RANDEL988,RANDEL989,RANDEL990;
matrix SHOCKDELt100=RANDEL991,RANDEL992,RANDEL993,RANDEL994,RANDEL995,RANDEL996,RANDEL997,RANDEL998,RANDEL999,RANDEL1000;

*************************************************************************;

matrix SHOCKDELt0p=SHOCKDELt1,SHOCKDELt2,SHOCKDELt3,SHOCKDELt4,SHOCKDELt5,SHOCKDELt6, SHOCKDELt7,SHOCKDELt8,SHOCKDELt9,SHOCKDELt10;

matrix SHOCKDELt1p=SHOCKDELt11,SHOCKDELt12,SHOCKDELt13,SHOCKDELt14,SHOCKDELt15,SHOCKDELt16, SHOCKDELt17,SHOCKDELt18,SHOCKDELt19,SHOCKDELt20;

matrix SHOCKDELt2p=SHOCKDELt21,SHOCKDELt22,SHOCKDELt23,SHOCKDELt24,SHOCKDELt25,SHOCKDELt26, SHOCKDELt27,SHOCKDELt28,SHOCKDELt29,SHOCKDELt30;

matrix SHOCKDELt3p=SHOCKDELt31,SHOCKDELt32,SHOCKDELt33,SHOCKDELt34,SHOCKDELt35,SHOCKDELt36, SHOCKDELt37,SHOCKDELt38,SHOCKDELt39,SHOCKDELt40;

matrix SHOCKDELt4p=SHOCKDELt41,SHOCKDELt42,SHOCKDELt43,SHOCKDELt44,SHOCKDELt45,SHOCKDELt46, SHOCKDELt47,SHOCKDELt48,SHOCKDELt49,SHOCKDELt50;

matrix SHOCKDELt5p=SHOCKDELt51,SHOCKDELt52,SHOCKDELt53,SHOCKDELt54,SHOCKDELt55,SHOCKDELt56, SHOCKDELt57,SHOCKDELt58,SHOCKDELt59,SHOCKDELt60;

matrix SHOCKDELt6p=SHOCKDELt61,SHOCKDELt62,SHOCKDELt63,SHOCKDELt64,SHOCKDELt65,SHOCKDELt66, SHOCKDELt67,SHOCKDELt68,SHOCKDELt69,SHOCKDELt70;

matrix SHOCKDELt7p=SHOCKDELt71,SHOCKDELt72,SHOCKDELt73,SHOCKDELt74,SHOCKDELt75,SHOCKDELt76, SHOCKDELt77,SHOCKDELt78,SHOCKDELt79,SHOCKDELt80;

matrix SHOCKDELt8p=SHOCKDELt81,SHOCKDELt82,SHOCKDELt83,SHOCKDELt84,SHOCKDELt85,SHOCKDELt86, SHOCKDELt87,SHOCKDELt88,SHOCKDELt89,SHOCKDELt90;

matrix SHOCKDELt9p=SHOCKDELt91,SHOCKDELt92,SHOCKDELt93,SHOCKDELt94,SHOCKDELt95,SHOCKDELt96, SHOCKDELt97,SHOCKDELt98,SHOCKDELt99,SHOCKDELt100;

*************************************************************************;

matrix SHOCKDELt= SHOCKDELt0p,SHOCKDELt1p,SHOCKDELt2p,SHOCKDELt3p,SHOCKDELt4p,SHOCKDELt5p,SHOCKDELt6p,SHOCKDELt7p,SHOCKDELt8p,SHOCKDELt9p;

restore;

*************************************************************************;
**** CREATING COLUMN VECTORS ****;
*************************************************************************;

drop if year<2004;

sort year ifscode;

mkmat program1, matrix(PROG1t);
mkmat programtminus1d1, matrix(PROG12t);
mkmat program2, matrix(PROG2t);
mkmat programtminus1d2, matrix(PROG22t);
mkmat sba, matrix(SBAt);
mkmat newha, matrix(NEWHAt);
mkmat rexsba, matrix(REXSBAt);

mkmat intdevoillag1, matrix(INTOILt);
mkmat devoillag1, matrix(OILt);
mkmat itermstrlag1, matrix(REALIt);
mkmat totgrlag1, matrix(TOTt);
mkmat tdebtgdplag1, matrix(DEBTt);
mkmat rescovlag1, matrix(RESt);
mkmat pkfnetgdplag1, matrix(KF1t);
mkmat pkfnetgdpdif1, matrix(KF2t);
mkmat cuagdplag1, matrix(CUAt);
mkmat ggbgdplag1, matrix(FBt);
mkmat rgdpgrlag1, matrix(GROWTHt);
mkmat bmgdplag1, matrix(BMt);
mkmat cpirexlag1, matrix(INFLt);

mkmat quota, matrix(QUOTAt);
mkmat diffcua, matrix(CUADIFt);
mkmat stdreslag1, matrix(STDRESt);
mkmat imrforecast, matrix(IMRNEWt);
mkmat lnoriginal, matrix(LNACCESSt);
mkmat time, matrix(TIMEt);
mkmat large, matrix(LARGEt);
mkmat largedebt, matrix(LARGEDEBTt);
mkmat ngdpdoll, matrix(NGDPDOLLt);
mkmat sdrerate, matrix(SDRt);
mkmat year, matrix(YEARt);

mkmat PDFnew1, matrix(PDFt);
mkmat CDFnew1, matrix(CDFt);

*************************************************************************;
**** SET INDICATORS FOR MATRIX SIZE ****;
*************************************************************************;

sort ifscode;
egen ctrygr=group(ifscode);
sort ctrygr;
gen countries=ctrygr[_N];
summarize countries;
gen maxctry1=r(max);
scalar maxctry=maxctry1;
scalar maxyear=7;
display maxctry;
display maxyear;

sort ifscode year;
save "Q:\DATA\PR\FundCredit\newdatabaseSPOCT.dta", replace;

*************************************************************************;
**** CREATING MATRICES FOR VARIABLES ****;
*************************************************************************;

matrix INTOIL=J(maxctry,maxyear,0);
matrix OIL=J(maxctry,maxyear,0);
matrix REALI=J(maxctry,maxyear,0);
matrix TOT=J(maxctry,maxyear,0);
matrix DEBT=J(maxctry,maxyear,0);
matrix RES=J(maxctry,maxyear,0);
matrix KF1=J(maxctry,maxyear,0);
matrix KF2=J(maxctry,maxyear,0);
matrix CUA=J(maxctry,maxyear,0);
matrix FB=J(maxctry,maxyear,0);
matrix GROWTH=J(maxctry,maxyear,0);
matrix BM=J(maxctry,maxyear,0);
matrix INFL=J(maxctry,maxyear,0);
matrix NEWHA=J(maxctry,maxyear,0);

matrix QUOTA=J(maxctry,maxyear,0);
matrix CUADIF=J(maxctry,maxyear,0);
matrix STDRES=J(maxctry,maxyear,0);
matrix IMRNEW=J(maxctry,maxyear,0);
matrix TIME=J(maxctry,maxyear,0);
matrix LARGEDEBT=J(maxctry,maxyear,0);
matrix LARGE=J(maxctry,maxyear,0);
matrix NGDPDOLL=J(maxctry,maxyear,0);
matrix SDR=J(maxctry,maxyear,0);
matrix YEAR=J(maxctry,maxyear,0);

matrix PDF=J(maxctry,maxyear,0);
matrix CDF=J(maxctry,maxyear,0);

*************************************************************************;
**** FILLING UP MATRICES ****;
*************************************************************************;

scalar c=0;
while scalar(c)<maxctry {;
scalar c=scalar(c)+1;

matrix INTOIL[scalar(c),1]=INTOILt[scalar(c),1];
matrix INTOIL[scalar(c),2]=INTOILt[scalar(c)+52,1];
matrix INTOIL[scalar(c),3]=INTOILt[scalar(c)+104,1];
matrix INTOIL[scalar(c),4]=INTOILt[scalar(c)+156,1];
matrix INTOIL[scalar(c),5]=INTOILt[scalar(c)+208,1];
matrix INTOIL[scalar(c),6]=INTOILt[scalar(c)+260,1];
matrix INTOIL[scalar(c),7]=INTOILt[scalar(c)+312,1];

matrix YEAR[scalar(c),1]=YEARt[scalar(c),1];
matrix YEAR[scalar(c),2]=YEARt[scalar(c)+52,1];
matrix YEAR[scalar(c),3]=YEARt[scalar(c)+104,1];
matrix YEAR[scalar(c),4]=YEARt[scalar(c)+156,1];
matrix YEAR[scalar(c),5]=YEARt[scalar(c)+208,1];
matrix YEAR[scalar(c),6]=YEARt[scalar(c)+260,1];
matrix YEAR[scalar(c),7]=YEARt[scalar(c)+312,1];

matrix NEWHA[scalar(c),1]=NEWHAt[scalar(c),1];
matrix NEWHA[scalar(c),2]=NEWHAt[scalar(c)+52,1];
matrix NEWHA[scalar(c),3]=NEWHAt[scalar(c)+104,1];
matrix NEWHA[scalar(c),4]=NEWHAt[scalar(c)+156,1];
matrix NEWHA[scalar(c),5]=NEWHAt[scalar(c)+208,1];
matrix NEWHA[scalar(c),6]=NEWHAt[scalar(c)+260,1];
matrix NEWHA[scalar(c),7]=NEWHAt[scalar(c)+312,1];

matrix OIL[scalar(c),1]=OILt[scalar(c),1];
matrix OIL[scalar(c),2]=OILt[scalar(c)+52,1];
matrix OIL[scalar(c),3]=OILt[scalar(c)+104,1];
matrix OIL[scalar(c),4]=OILt[scalar(c)+156,1];
matrix OIL[scalar(c),5]=OILt[scalar(c)+208,1];
matrix OIL[scalar(c),6]=OILt[scalar(c)+260,1];
matrix OIL[scalar(c),7]=OILt[scalar(c)+312,1];

matrix REALI[scalar(c),1]=REALIt[scalar(c),1];
matrix REALI[scalar(c),2]=REALIt[scalar(c)+52,1];
matrix REALI[scalar(c),3]=REALIt[scalar(c)+104,1];
matrix REALI[scalar(c),4]=REALIt[scalar(c)+156,1];
matrix REALI[scalar(c),5]=REALIt[scalar(c)+208,1];
matrix REALI[scalar(c),6]=REALIt[scalar(c)+260,1];
matrix REALI[scalar(c),7]=REALIt[scalar(c)+312,1];

matrix DEBT[scalar(c),1]=DEBTt[scalar(c),1];
matrix DEBT[scalar(c),2]=DEBTt[scalar(c)+52,1];
matrix DEBT[scalar(c),3]=DEBTt[scalar(c)+104,1];
matrix DEBT[scalar(c),4]=DEBTt[scalar(c)+156,1];
matrix DEBT[scalar(c),5]=DEBTt[scalar(c)+208,1];
matrix DEBT[scalar(c),6]=DEBTt[scalar(c)+260,1];
matrix DEBT[scalar(c),7]=DEBTt[scalar(c)+312,1];

matrix TOT[scalar(c),1]=TOTt[scalar(c),1];
matrix TOT[scalar(c),2]=TOTt[scalar(c)+52,1];
matrix TOT[scalar(c),3]=TOTt[scalar(c)+104,1];
matrix TOT[scalar(c),4]=TOTt[scalar(c)+156,1];
matrix TOT[scalar(c),5]=TOTt[scalar(c)+208,1];
matrix TOT[scalar(c),6]=TOTt[scalar(c)+260,1];
matrix TOT[scalar(c),7]=TOTt[scalar(c)+312,1];

matrix KF1[scalar(c),1]=KF1t[scalar(c),1];
matrix KF1[scalar(c),2]=KF1t[scalar(c)+52,1];
matrix KF1[scalar(c),3]=KF1t[scalar(c)+104,1];
matrix KF1[scalar(c),4]=KF1t[scalar(c)+156,1];
matrix KF1[scalar(c),5]=KF1t[scalar(c)+208,1];
matrix KF1[scalar(c),6]=KF1t[scalar(c)+260,1];
matrix KF1[scalar(c),7]=KF1t[scalar(c)+312,1];

matrix KF2[scalar(c),1]=KF2t[scalar(c),1];
matrix KF2[scalar(c),2]=KF2t[scalar(c)+52,1];
matrix KF2[scalar(c),3]=KF2t[scalar(c)+104,1];
matrix KF2[scalar(c),4]=KF2t[scalar(c)+156,1];
matrix KF2[scalar(c),5]=KF2t[scalar(c)+208,1];
matrix KF2[scalar(c),6]=KF2t[scalar(c)+260,1];
matrix KF2[scalar(c),7]=KF2t[scalar(c)+312,1];

matrix RES[scalar(c),1]=RESt[scalar(c),1];
matrix RES[scalar(c),2]=RESt[scalar(c)+52,1];
matrix RES[scalar(c),3]=RESt[scalar(c)+104,1];
matrix RES[scalar(c),4]=RESt[scalar(c)+156,1];
matrix RES[scalar(c),5]=RESt[scalar(c)+208,1];
matrix RES[scalar(c),6]=RESt[scalar(c)+260,1];
matrix RES[scalar(c),7]=RESt[scalar(c)+312,1];

matrix CUA[scalar(c),1]=CUAt[scalar(c),1];
matrix CUA[scalar(c),2]=CUAt[scalar(c)+52,1];
matrix CUA[scalar(c),3]=CUAt[scalar(c)+104,1];
matrix CUA[scalar(c),4]=CUAt[scalar(c)+156,1];
matrix CUA[scalar(c),5]=CUAt[scalar(c)+208,1];
matrix CUA[scalar(c),6]=CUAt[scalar(c)+260,1];
matrix CUA[scalar(c),7]=CUAt[scalar(c)+312,1];

matrix FB[scalar(c),1]=FBt[scalar(c),1];
matrix FB[scalar(c),2]=FBt[scalar(c)+52,1];
matrix FB[scalar(c),3]=FBt[scalar(c)+104,1];
matrix FB[scalar(c),4]=FBt[scalar(c)+156,1];
matrix FB[scalar(c),5]=FBt[scalar(c)+208,1];
matrix FB[scalar(c),6]=FBt[scalar(c)+260,1];
matrix FB[scalar(c),7]=FBt[scalar(c)+312,1];

matrix GROWTH[scalar(c),1]=GROWTHt[scalar(c),1];
matrix GROWTH[scalar(c),2]=GROWTHt[scalar(c)+52,1];
matrix GROWTH[scalar(c),3]=GROWTHt[scalar(c)+104,1];
matrix GROWTH[scalar(c),4]=GROWTHt[scalar(c)+156,1];
matrix GROWTH[scalar(c),5]=GROWTHt[scalar(c)+208,1];
matrix GROWTH[scalar(c),6]=GROWTHt[scalar(c)+260,1];
matrix GROWTH[scalar(c),7]=GROWTHt[scalar(c)+312,1];

matrix BM[scalar(c),1]=BMt[scalar(c),1];
matrix BM[scalar(c),2]=BMt[scalar(c)+52,1];
matrix BM[scalar(c),3]=BMt[scalar(c)+104,1];
matrix BM[scalar(c),4]=BMt[scalar(c)+156,1];
matrix BM[scalar(c),5]=BMt[scalar(c)+208,1];
matrix BM[scalar(c),6]=BMt[scalar(c)+260,1];
matrix BM[scalar(c),7]=BMt[scalar(c)+312,1];

matrix INFL[scalar(c),1]=INFLt[scalar(c),1];
matrix INFL[scalar(c),2]=INFLt[scalar(c)+52,1];
matrix INFL[scalar(c),3]=INFLt[scalar(c)+104,1];
matrix INFL[scalar(c),4]=INFLt[scalar(c)+156,1];
matrix INFL[scalar(c),5]=INFLt[scalar(c)+208,1];
matrix INFL[scalar(c),6]=INFLt[scalar(c)+260,1];
matrix INFL[scalar(c),7]=INFLt[scalar(c)+312,1];

matrix QUOTA[scalar(c),1]=QUOTAt[scalar(c),1];
matrix QUOTA[scalar(c),2]=QUOTAt[scalar(c)+52,1];
matrix QUOTA[scalar(c),3]=QUOTAt[scalar(c)+104,1];
matrix QUOTA[scalar(c),4]=QUOTAt[scalar(c)+156,1];
matrix QUOTA[scalar(c),5]=QUOTAt[scalar(c)+208,1];
matrix QUOTA[scalar(c),6]=QUOTAt[scalar(c)+260,1];
matrix QUOTA[scalar(c),7]=QUOTAt[scalar(c)+312,1];

matrix CUADIF[scalar(c),1]=CUADIFt[scalar(c),1];
matrix CUADIF[scalar(c),2]=CUADIFt[scalar(c)+52,1];
matrix CUADIF[scalar(c),3]=CUADIFt[scalar(c)+104,1];
matrix CUADIF[scalar(c),4]=CUADIFt[scalar(c)+156,1];
matrix CUADIF[scalar(c),5]=CUADIFt[scalar(c)+208,1];
matrix CUADIF[scalar(c),6]=CUADIFt[scalar(c)+260,1];
matrix CUADIF[scalar(c),7]=CUADIFt[scalar(c)+312,1];

matrix STDRES[scalar(c),1]=STDRESt[scalar(c),1];
matrix STDRES[scalar(c),2]=STDRESt[scalar(c)+52,1];
matrix STDRES[scalar(c),3]=STDRESt[scalar(c)+104,1];
matrix STDRES[scalar(c),4]=STDRESt[scalar(c)+156,1];
matrix STDRES[scalar(c),5]=STDRESt[scalar(c)+208,1];
matrix STDRES[scalar(c),6]=STDRESt[scalar(c)+260,1];
matrix STDRES[scalar(c),7]=STDRESt[scalar(c)+312,1];

matrix IMRNEW[scalar(c),1]=IMRNEWt[scalar(c),1];
matrix IMRNEW[scalar(c),2]=IMRNEWt[scalar(c)+52,1];
matrix IMRNEW[scalar(c),3]=IMRNEWt[scalar(c)+104,1];
matrix IMRNEW[scalar(c),4]=IMRNEWt[scalar(c)+156,1];
matrix IMRNEW[scalar(c),5]=IMRNEWt[scalar(c)+208,1];
matrix IMRNEW[scalar(c),6]=IMRNEWt[scalar(c)+260,1];
matrix IMRNEW[scalar(c),7]=IMRNEWt[scalar(c)+312,1];

matrix PDF[scalar(c),1]=PDFt[scalar(c),1];
matrix PDF[scalar(c),2]=PDFt[scalar(c)+52,1];
matrix PDF[scalar(c),3]=PDFt[scalar(c)+104,1];
matrix PDF[scalar(c),4]=PDFt[scalar(c)+156,1];
matrix PDF[scalar(c),5]=PDFt[scalar(c)+208,1];
matrix PDF[scalar(c),6]=PDFt[scalar(c)+260,1];
matrix PDF[scalar(c),7]=PDFt[scalar(c)+312,1];

matrix CDF[scalar(c),1]=CDFt[scalar(c),1];
matrix CDF[scalar(c),2]=CDFt[scalar(c)+52,1];
matrix CDF[scalar(c),3]=CDFt[scalar(c)+104,1];
matrix CDF[scalar(c),4]=CDFt[scalar(c)+156,1];
matrix CDF[scalar(c),5]=CDFt[scalar(c)+208,1];
matrix CDF[scalar(c),6]=CDFt[scalar(c)+260,1];
matrix CDF[scalar(c),7]=CDFt[scalar(c)+312,1];

matrix TIME[scalar(c),1]=TIMEt[scalar(c),1];
matrix TIME[scalar(c),2]=TIMEt[scalar(c)+52,1];
matrix TIME[scalar(c),3]=TIMEt[scalar(c)+104,1];
matrix TIME[scalar(c),4]=TIMEt[scalar(c)+156,1];
matrix TIME[scalar(c),5]=TIMEt[scalar(c)+208,1];
matrix TIME[scalar(c),6]=TIMEt[scalar(c)+260,1];
matrix TIME[scalar(c),7]=TIMEt[scalar(c)+312,1];

matrix NGDPDOLL[scalar(c),1]=NGDPDOLLt[scalar(c),1];
matrix NGDPDOLL[scalar(c),2]=NGDPDOLLt[scalar(c)+52,1];
matrix NGDPDOLL[scalar(c),3]=NGDPDOLLt[scalar(c)+104,1];
matrix NGDPDOLL[scalar(c),4]=NGDPDOLLt[scalar(c)+156,1];
matrix NGDPDOLL[scalar(c),5]=NGDPDOLLt[scalar(c)+208,1];
matrix NGDPDOLL[scalar(c),6]=NGDPDOLLt[scalar(c)+260,1];
matrix NGDPDOLL[scalar(c),7]=NGDPDOLLt[scalar(c)+312,1];

matrix LARGE[scalar(c),1]=LARGEt[scalar(c),1];
matrix LARGE[scalar(c),2]=LARGEt[scalar(c)+52,1];
matrix LARGE[scalar(c),3]=LARGEt[scalar(c)+104,1];
matrix LARGE[scalar(c),4]=LARGEt[scalar(c)+156,1];
matrix LARGE[scalar(c),5]=LARGEt[scalar(c)+208,1];
matrix LARGE[scalar(c),6]=LARGEt[scalar(c)+260,1];
matrix LARGE[scalar(c),7]=LARGEt[scalar(c)+312,1];

matrix LARGEDEBT[scalar(c),1]=LARGEDEBTt[scalar(c),1];
matrix LARGEDEBT[scalar(c),2]=LARGEDEBTt[scalar(c)+52,1];
matrix LARGEDEBT[scalar(c),3]=LARGEDEBTt[scalar(c)+104,1];
matrix LARGEDEBT[scalar(c),4]=LARGEDEBTt[scalar(c)+156,1];
matrix LARGEDEBT[scalar(c),5]=LARGEDEBTt[scalar(c)+208,1];
matrix LARGEDEBT[scalar(c),6]=LARGEDEBTt[scalar(c)+260,1];
matrix LARGEDEBT[scalar(c),7]=LARGEDEBTt[scalar(c)+312,1];

matrix SDR[scalar(c),1]=SDRt[scalar(c),1];
matrix SDR[scalar(c),2]=SDRt[scalar(c)+52,1];
matrix SDR[scalar(c),3]=SDRt[scalar(c)+104,1];
matrix SDR[scalar(c),4]=SDRt[scalar(c)+156,1];
matrix SDR[scalar(c),5]=SDRt[scalar(c)+208,1];
matrix SDR[scalar(c),6]=SDRt[scalar(c)+260,1];
matrix SDR[scalar(c),7]=SDRt[scalar(c)+312,1];

};	* this closes c;

*************************************************************************;
**** CREATING MATRICES FOR PROGRAM MATRICES, PROBABILITIES, AND ACCESS ****;
*************************************************************************;

matrix SUM1=J(1,maxyear,0);
matrix SUM2=J(loops,maxyear,0);
matrix SUMSBA1=J(1,maxyear,0);
matrix SUMSBA2=J(loops,maxyear,0);
matrix SUMREXSBA1=J(1,maxyear,0);
matrix SUMREXSBA2=J(loops,maxyear,0);

matrix SUMNEW1=J(1,maxyear,0);
matrix SUMNEW2=J(loops,maxyear,0);
matrix SUMSBANEW1=J(1,maxyear,0);
matrix SUMSBANEW2=J(loops,maxyear,0);
matrix SUMREXSBANEW1=J(1,maxyear,0);
matrix SUMREXSBANEW2=J(loops2,maxyear,0);

scalar d=0;
while scalar(d)<loops {;
scalar d=scalar(d)+1;

matrix SBA=J(maxctry,maxyear,0);
matrix PROG1=J(maxctry,maxyear,0);
matrix PROG12=J(maxctry,maxyear,0);
matrix PROG2=J(maxctry,maxyear,0);
matrix PROG22=J(maxctry,maxyear,0);

matrix QUOTACDF=J(maxctry,maxyear,0);
matrix DEBTCDF=J(maxctry,maxyear,0);
matrix CUADIFCDF=J(maxctry,maxyear,0);
matrix STDRESCDF=J(maxctry,maxyear,0);
matrix QUOTACDF2=J(maxctry,maxyear,0);
matrix DEBTCDF2=J(maxctry,maxyear,0);
matrix CUADIFCDF2=J(maxctry,maxyear,0);
matrix STDRESCDF2=J(maxctry,maxyear,0);

matrix REXSBA=J(maxctry,maxyear,0);
matrix REXSBANEW=J(maxctry,maxyear,0);

matrix SHOCKEPS=J(maxctry,maxyear,0);
matrix SHOCKDEL=J(maxctry,maxyear,0);

matrix IDENTITY=J(maxctry,maxyear,1);
matrix PROB1=J(maxctry,maxyear,0);
matrix PROB2=J(maxctry,maxyear,0);
matrix PROB3=J(maxctry,maxyear,0);
matrix PROB4=J(maxctry,maxyear,0);
matrix ACCESS1=J(maxctry,maxyear,0);
matrix ACCESS2=J(maxctry,maxyear,0);
matrix ACCESS3=J(maxctry,maxyear,0);
matrix ORIG1=J(maxctry,maxyear,0);
matrix ORIG2=J(maxctry,maxyear,0);
matrix ORIG3=J(maxctry,maxyear,0);

matrix ACCESSNEW1=J(maxctry,maxyear,0);
matrix ACCESSNEW2=J(maxctry,maxyear,0);
matrix ACCESSNEW3=J(maxctry,maxyear,0);
matrix ORIGNEW1=J(maxctry,maxyear,0);
matrix ORIGNEW2=J(maxctry,maxyear,0);
matrix ORIGNEW3=J(maxctry,maxyear,0);

matrix U=J(1,maxctry,1);

scalar e=0;
while scalar(e)<maxctry {;
scalar e=scalar(e)+1;

matrix PROG1[scalar(e),1]=PROG1t[scalar(e),1];
matrix PROG1[scalar(e),2]=PROG1t[scalar(e)+52,1];
matrix PROG1[scalar(e),3]=PROG1t[scalar(e)+104,1];

matrix PROG12[scalar(e),1]=PROG12t[scalar(e),1];
matrix PROG12[scalar(e),2]=PROG12t[scalar(e)+52,1];
matrix PROG12[scalar(e),3]=PROG12t[scalar(e)+104,1];

matrix PROG2[scalar(e),1]=PROG2t[scalar(e),1];
matrix PROG2[scalar(e),2]=PROG2t[scalar(e)+52,1];
matrix PROG2[scalar(e),3]=PROG2t[scalar(e)+104,1];
matrix PROG2[scalar(e),4]=PROG2t[scalar(e)+156,1];

matrix PROG22[scalar(e),1]=PROG22t[scalar(e),1];
matrix PROG22[scalar(e),2]=PROG22t[scalar(e)+52,1];
matrix PROG22[scalar(e),3]=PROG22t[scalar(e)+104,1];
matrix PROG22[scalar(e),4]=PROG22t[scalar(e)+156,1];

matrix SBA[scalar(e),1]=SBAt[scalar(e),1];
matrix SBA[scalar(e),2]=SBAt[scalar(e)+52,1];

matrix REXSBA[scalar(e),1]=REXSBAt[scalar(e),1];
matrix REXSBA[scalar(e),2]=REXSBAt[scalar(e)+52,1];

matrix SHOCKEPS[scalar(e),1]=SHOCKEPSt[scalar(e),scalar(d)];
matrix SHOCKEPS[scalar(e),2]=SHOCKEPSt[scalar(e)+52,scalar(d)];
matrix SHOCKEPS[scalar(e),3]=SHOCKEPSt[scalar(e)+104,scalar(d)];
matrix SHOCKEPS[scalar(e),4]=SHOCKEPSt[scalar(e)+156,scalar(d)];
matrix SHOCKEPS[scalar(e),5]=SHOCKEPSt[scalar(e)+208,scalar(d)];
matrix SHOCKEPS[scalar(e),6]=SHOCKEPSt[scalar(e)+260,scalar(d)];
matrix SHOCKEPS[scalar(e),7]=SHOCKEPSt[scalar(e)+312,scalar(d)];

matrix SHOCKDEL[scalar(e),3]=SHOCKDELt[scalar(e),scalar(d)];
matrix SHOCKDEL[scalar(e),4]=SHOCKDELt[scalar(e)+52,scalar(d)];
matrix SHOCKDEL[scalar(e),5]=SHOCKDELt[scalar(e)+104,scalar(d)];
matrix SHOCKDEL[scalar(e),6]=SHOCKDELt[scalar(e)+156,scalar(d)];
matrix SHOCKDEL[scalar(e),7]=SHOCKDELt[scalar(e)+208,scalar(d)];

};	* this closes e;

scalar f=2;
while scalar(f)<maxyear {;
scalar f=scalar(f)+1;

scalar g=0;
while scalar(g)<maxctry {;
scalar g=scalar(g)+1;

matrix PROB1[scalar(g),scalar(f)]=PROG1[scalar(g),scalar(f)]*0.5083-
PROG12[scalar(g),scalar(f)]*1.6719+PROG2[scalar(g),scalar(f)]*1.0307-
PROG22[scalar(g),scalar(f)]*1.0070-INTOIL[scalar(g),scalar(f)]*0.6153+
OIL[scalar(g),scalar(f)]*0.2235+REALI[scalar(g),scalar(f)]*0.0655+
STDRES[scalar(g),scalar(f)]*0.0786+DEBT[scalar(g),scalar(f)]*0.0115-
RES[scalar(g),scalar(f)]*0.0875+KF1[scalar(g),scalar(f)]*0.0237-
CUA[scalar(g),scalar(f)]*0.0132-FB[scalar(g),scalar(f)]*0.0365-GROWTH[scalar(g),scalar(f)]*0.0487-BM[scalar(g),scalar(f)]*0.0087+
INFL[scalar(g),scalar(f)]*0.0015-IDENTITY[scalar(g),scalar(f)]*1.6111;

*************************************************************************;
**** PROBABILITIES ****;
*************************************************************************;

matrix PROB2[scalar(g),scalar(f)]=PROB1[scalar(g),scalar(f)]+
SHOCKEPS[scalar(g),scalar(f)];

matrix PROB3[scalar(g),scalar(f)]=1/(1+exp(1)^(-PROB2[scalar(g),scalar(f)]));

*************************************************************************;
**** ADJUSTING SBA AND PROGRAM REGRESSORS ****;
*************************************************************************;

local val1a=PROB3[scalar(g),scalar(f)];
local val1aa=YEAR[scalar(g),scalar(f)];
if `val1a'>=0.196667 & `val1aa'>=2006 {;
matrix PROB4[scalar(g),scalar(f)]=1;
};
if `val1a'<0.196667 & `val1aa'>=2006 {;
matrix PROB4[scalar(g),scalar(f)]=0;
};

local val1b=PROB4[scalar(g),scalar(f)];
if `val1b'==1 & `val1aa'>=2006  {;
matrix SBA[scalar(g),scalar(f)]=1;
};
if `val1b'==0 & `val1aa'>=2006  {;
matrix SBA[scalar(g),scalar(f)]=0;
};

local val2=SBA[scalar(g),scalar(f)-1];
if `val2'==1 & `val1aa'>=2006  {;
matrix SBA[scalar(g),scalar(f)]=0;
};
if `val2'==1 & `val1aa'>=2007  {;
matrix PROG1[scalar(g),scalar(f)]=1;
matrix PROG12[scalar(g),scalar(f)]=1;
};
if `val2'==0 & `val1aa'>=2007  {;
matrix PROG1[scalar(g),scalar(f)]=0;
matrix PROG12[scalar(g),scalar(f)]=0;
};

local val3=SBA[scalar(g),scalar(f)-2];
if `val3'==1 & `val1aa'>=2008  {;
matrix PROG2[scalar(g),scalar(f)]=1;
};
if `val3'==0 & `val1aa'>=2008  {;
matrix PROG2[scalar(g),scalar(f)]=0;
};

*************************************************************************;
**** CREATE MATRICES ON ACCESS ****;
*************************************************************************;

matrix REXSBA[scalar(g),scalar(f)]=SBA[scalar(g),scalar(f)]*
LARGEDEBT[scalar(g),scalar(f)]*LARGE[scalar(g),scalar(f)];

matrix QUOTACDF[scalar(g),scalar(f)]=QUOTA[scalar(g),scalar(f)]*
CDF[scalar(g),scalar(f)];
matrix DEBTCDF[scalar(g),scalar(f)]=DEBT[scalar(g),scalar(f)]*
CDF[scalar(g),scalar(f)];
matrix CUADIFCDF[scalar(g),scalar(f)]=CUADIF[scalar(g),scalar(f)]*
CDF[scalar(g),scalar(f)];
matrix STDRESCDF[scalar(g),scalar(f)]=STDRES[scalar(g),scalar(f)]*
CDF[scalar(g),scalar(f)];

matrix ACCESS1[scalar(g),scalar(f)]=-QUOTACDF[scalar(g),scalar(f)]*0.0001124+
DEBTCDF[scalar(g),scalar(f)]*0.0026268+CUADIFCDF[scalar(g),scalar(f)]*0.0657039+
STDRESCDF[scalar(g),scalar(f)]*0.0085844+PDF[scalar(g),scalar(f)]*0.692221+
REXSBA[scalar(g),scalar(f)]*1.409773-TIME[scalar(g),scalar(f)]*0.0019477+
0.0471998*IDENTITY[scalar(g),scalar(f)];

*************************************************************************;
**** SHOCKS FOR ACCESS ****;
*************************************************************************;

matrix ACCESS2[scalar(g),scalar(f)]=ACCESS1[scalar(g),scalar(f)]+
SHOCKDEL[scalar(g),scalar(f)];

*************************************************************************;
**** MATCHING PROBABILITIES AND ACCESS LEVELS ****;
*************************************************************************;

local val5=ACCESS2[scalar(g),scalar(f)];
if `val5'<0 & `val1aa'>=2006 {;
matrix ACCESS2[scalar(g),scalar(f)]=0;
};

local val4=SBA[scalar(g),scalar(f)];
if `val4'==1 & `val1aa'>=2006 {;
matrix ACCESS3[scalar(g),scalar(f)]=ACCESS2[scalar(g),scalar(f)];
};
if `val4'==0 & `val1aa'>=2006 {;
matrix ACCESS3[scalar(g),scalar(f)]=0;
};

matrix ORIG1[scalar(g),scalar(f)]=exp(ACCESS3[scalar(g),scalar(f)]);

matrix ORIG2[scalar(g),scalar(f)]=
(ORIG1[scalar(g),scalar(f)]-1)*NGDPDOLL[scalar(g),scalar(f)]/100;

matrix ORIG3[scalar(g),scalar(f)]=ORIG2[scalar(g),scalar(f)]*
SDR[scalar(g),scalar(f)];

};	* this closes g;

matrix SUM1=U*ORIG3;
matrix SUM2[scalar(d),scalar(f)]=SUM1[1,scalar(f)];

matrix SUMSBA1=U*SBA;
matrix SUMSBA2[scalar(d),scalar(f)]=SUMSBA1[1,scalar(f)];

matrix SUMREXSBA1=U*REXSBA;
matrix SUMREXSBA2[scalar(d),scalar(f)]=SUMREXSBA1[1,scalar(f)];

};	* this closes f;

};	* this closes d;

matrix ID1=J(rowsof(SUM2),1,1);
matrix SUM3=ID1'*SUM2;
matrix SUM3AVE=SUM3/rowsof(SUM2);

matrix list SUM2;

matrix list SUM3;
matrix list SUM3AVE;

matrix colnames SUM2 = YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

svmat SUM2, names(col);

outsheet YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010 using "Q:\DATA\PR\FundCredit\out1aSPOCT.txt", replace;

drop YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

matrix ID2=J(rowsof(SUMSBA2),1,1);
matrix SUMSBA3=ID2'*SUMSBA2;
matrix SUMSBA3AVE=SUMSBA3/rowsof(SUMSBA2);

matrix list SUMSBA2;
matrix list SUMSBA3;
matrix list SUMSBA3AVE;

matrix colnames SUMSBA2 = YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

svmat SUMSBA2, names(col);

outsheet YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010 using "Q:\DATA\PR\FundCredit\out2aSPOCT.txt", replace;

drop YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

matrix ID3=J(rowsof(SUMREXSBA2),1,1);
matrix SUMREXSBA3=ID3'*SUMREXSBA2;
matrix SUMREXSBA3AVE=SUMREXSBA3/rowsof(SUMREXSBA2);

matrix list SUMREXSBA2;
matrix list SUMREXSBA3;
matrix list SUMREXSBA3AVE;

matrix colnames SUMREXSBA2 = YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

svmat SUMREXSBA2, names(col);

outsheet YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010 using "Q:\DATA\PR\FundCredit\out3aSPOCT.txt", replace;

svmat SHOCKEPS, names(col);

outsheet c1 c2 c3 c4 c5 c6 c7 using "Q:\DATA\PR\FundCredit\out4aSPOCT.txt", replace;

*************************************************************************;
**** SHOCKS TO PROBABILITIES ****;
*************************************************************************;

matrix BINEPS1=J(52,loops2,.); 
matrix BINEPS2=J(52,loops2,.); 
matrix BINEPS3=J(52,loops2,.); 
matrix BINEPS4=J(52,loops2,.); 
matrix BINEPS5=J(52,loops2,.); 

matrix BIN2004=J(52,1,.); 
matrix BIN2005=J(52,1,.); 
matrix BIN2006=J(52,1,.); 
matrix BIN2007=J(52,1,.); 
matrix BIN2008=J(52,1,.); 
matrix BIN2009=J(52,1,.); 
matrix BIN2010=J(52,1,.); 

matrix BIN=J(52,maxyear,.); 

scalar h=0;
while scalar(h)<maxctry {;
scalar h=scalar(h)+1;

local LOC100=PROB3[scalar(h),3];
rndbin 5000 `LOC100' 1;
gen xb1=xb;
display `LOC100';
sum xb;
mkmat xb, matrix(xb100);
drop xb;
matrix xb100=xb100';

local LOC200=PROB3[scalar(h),4];
rndbin 5000 `LOC200' 1;
gen xb1=xb;
display `LOC200';
sum xb;
mkmat xb, matrix(xb200);
drop xb;
matrix xb200=xb200';

local LOC300=PROB3[scalar(h),5];
rndbin 5000 `LOC300' 1;
gen xb1=xb;
display `LOC300';
sum xb;
mkmat xb, matrix(xb300);
drop xb;
matrix xb300=xb300';

local LOC400=PROB3[scalar(h),6];
rndbin 5000 `LOC400' 1;
gen xb1=xb;
display `LOC400';
sum xb;
mkmat xb, matrix(xb400);
drop xb;
matrix xb400=xb400';

local LOC500=PROB3[scalar(h),7];
rndbin 5000 `LOC500' 1;
gen xb1=xb;
display `LOC500';
sum xb;
mkmat xb, matrix(xb500);
drop xb;
matrix xb500=xb500';

scalar i=0;
while scalar(i)<1000 {;
scalar i=scalar(i)+1;
matrix BINEPS1[scalar(h),scalar(i)]=xb100[1,scalar(i)];
matrix BINEPS2[scalar(h),scalar(i)]=xb200[1,scalar(i)];
matrix BINEPS3[scalar(h),scalar(i)]=xb300[1,scalar(i)];
matrix BINEPS4[scalar(h),scalar(i)]=xb400[1,scalar(i)];
matrix BINEPS5[scalar(h),scalar(i)]=xb500[1,scalar(i)];

};	* this closes i;

};	* this closes h;

*************************************************************************;

scalar j=0;
while scalar(j)<1000 {;
scalar j=scalar(j)+1;

scalar k=0;
while scalar(k)<maxctry {;
scalar k=scalar(k)+1;

matrix BIN2004[scalar(k),1]=SBA[scalar(k),1];
matrix BIN2005[scalar(k),1]=SBA[scalar(k),2];
matrix BIN2006[scalar(k),1]=BINEPS1[scalar(k),scalar(j)];
matrix BIN2007[scalar(k),1]=BINEPS2[scalar(k),scalar(j)];
matrix BIN2008[scalar(k),1]=BINEPS3[scalar(k),scalar(j)];
matrix BIN2009[scalar(k),1]=BINEPS4[scalar(k),scalar(j)];
matrix BIN2010[scalar(k),1]=BINEPS5[scalar(k),scalar(j)];

matrix BIN=BIN2004,BIN2005,BIN2006,BIN2007,BIN2008,BIN2009,BIN2010;

};	* this closes k;

**** ADJUSTING FOR SUCCESSIVE PROGRAMS ****;

scalar s=2;
while scalar(s)<maxyear {;
scalar s=scalar(s)+1;
scalar t=0;
while scalar(t)<maxctry {;
scalar t=scalar(t)+1;

local valbin=BIN[scalar(t),scalar(s)-1];
local valyr=YEAR[scalar(t),scalar(s)];
if `valbin'==1 & `valyr'>=2006  {;
matrix BIN[scalar(t),scalar(s)]=0;
};
};	* this closes t;
};	* this closes s;

*************************************************************************;
**** INTERACTING WITH ACCESS ****;
*************************************************************************;

scalar v=2;
while scalar(v)<maxyear {;
scalar v=scalar(v)+1;
scalar w=0;
while scalar(w)<maxctry {;
scalar w=scalar(w)+1;

matrix REXSBANEW[scalar(w),scalar(v)]=BIN[scalar(w),scalar(v)]*
LARGEDEBT[scalar(w),scalar(v)]*LARGE[scalar(w),scalar(v)];

matrix QUOTACDF2[scalar(w),scalar(v)]=QUOTA[scalar(w),scalar(v)]*
CDF[scalar(w),scalar(v)];
matrix DEBTCDF2[scalar(w),scalar(v)]=DEBT[scalar(w),scalar(v)]*
CDF[scalar(w),scalar(v)];
matrix CUADIFCDF2[scalar(w),scalar(v)]=CUADIF[scalar(w),scalar(v)]*
CDF[scalar(w),scalar(v)];
matrix STDRESCDF2[scalar(w),scalar(v)]=STDRES[scalar(w),scalar(v)]*
CDF[scalar(w),scalar(v)];

matrix ACCESSNEW1[scalar(w),scalar(v)]=-QUOTACDF2[scalar(w),scalar(v)]*0.0001124+
DEBTCDF2[scalar(w),scalar(v)]*0.0026268+
CUADIFCDF2[scalar(w),scalar(v)]*0.0657039+
STDRESCDF2[scalar(w),scalar(v)]*0.0085844+
PDF[scalar(w),scalar(v)]*0.692221+
REXSBA[scalar(w),scalar(v)]*1.409773-
TIME[scalar(w),scalar(v)]*0.0019477+
IDENTITY[scalar(w),scalar(v)]*0.0471998;

matrix ACCESSNEW2[scalar(w),scalar(v)]=ACCESSNEW1[scalar(w),scalar(v)]+
SHOCKDEL[scalar(w),scalar(v)];

local val5NEW=ACCESSNEW2[scalar(w),scalar(v)];
if `val5NEW'<0 & `val1aa'>=2006 {;
matrix ACCESSNEW2[scalar(w),scalar(v)]=0;
};

local val4NEW=BIN[scalar(w),scalar(v)];
if `val4NEW'==1 & `val1aa'>=2006 {;
matrix ACCESSNEW3[scalar(w),scalar(v)]=ACCESSNEW2[scalar(w),scalar(v)];
};
if `val4NEW'==0 & `val1aa'>=2006 {;
matrix ACCESSNEW3[scalar(w),scalar(v)]=0;
};

matrix ORIGNEW1[scalar(w),scalar(v)]=exp(ACCESSNEW3[scalar(w),scalar(v)]);

matrix ORIGNEW2[scalar(w),scalar(v)]=
(ORIGNEW1[scalar(w),scalar(v)]-1)*NGDPDOLL[scalar(w),scalar(v)]/100;

matrix ORIGNEW3[scalar(w),scalar(v)]=ORIGNEW2[scalar(w),scalar(v)]*
SDR[scalar(w),scalar(v)];

};	* this closes w;

matrix SUMNEW1=U*ORIGNEW3;
matrix SUMNEW2[scalar(j),scalar(v)]=SUMNEW1[1,scalar(v)];

matrix SUMSBANEW1=U*BIN;
matrix SUMSBANEW2[scalar(j),scalar(v)]=SUMSBANEW1[1,scalar(v)];

matrix SUMREXSBANEW1=U*REXSBANEW;
matrix SUMREXSBANEW2[scalar(j),scalar(v)]=SUMREXSBANEW1[1,scalar(v)];

};	* this closes v;

*************************************************************************;
**** CLOSING THE ROUNDS OF PROBABILITY SHOCKS ****;
*************************************************************************;

};	* this closes j;

*************************************************************************;
**** CONCLUDING CALCULATIONS ****;
*************************************************************************;

drop YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

matrix IDNEW1=J(rowsof(SUMNEW2),1,1);
matrix SUMNEW3=IDNEW1'*SUMNEW2;
matrix SUMNEW3AVE=SUMNEW3/rowsof(SUMNEW2);

matrix list SUMNEW2;

matrix list SUMNEW3;
matrix list SUMNEW3AVE;

matrix colnames SUMNEW2 = YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

svmat SUMNEW2, names(col);

outsheet YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010 using "Q:\DATA\PR\FundCredit\out1NEWaSPOCT.txt", replace;

drop YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

matrix IDNEW2=J(rowsof(SUMSBANEW2),1,1);
matrix SUMSBANEW3=IDNEW2'*SUMSBANEW2;
matrix SUMSBANEW3AVE=SUMSBANEW3/rowsof(SUMSBANEW2);

matrix list SUMSBANEW2;
matrix list SUMSBANEW3;
matrix list SUMSBANEW3AVE;

matrix colnames SUMSBANEW2 = YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

svmat SUMSBANEW2, names(col);

outsheet YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010 using "Q:\DATA\PR\FundCredit\out2NEWaSPOCT.txt", replace;

drop YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

matrix IDNEW3=J(rowsof(SUMREXSBANEW2),1,1);
matrix SUMREXSBANEW3=IDNEW3'*SUMREXSBANEW2;
matrix SUMREXSBANEW3AVE=SUMREXSBANEW3/rowsof(SUMREXSBANEW2);

matrix list SUMREXSBANEW2;
matrix list SUMREXSBANEW3;
matrix list SUMREXSBANEW3AVE;

matrix colnames SUMREXSBANEW2 = YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010;

svmat SUMREXSBANEW2, names(col);

outsheet YR2004 YR2005 YR2006 YR2007 YR2008 YR2009 YR2010 using "Q:\DATA\PR\FundCredit\out3NEWaSPOCT.txt", replace;

*************************************************************************;
**** SAVING DATA AND CLOSING OUTPUT ****;
*************************************************************************;

log close;
view "Q:\DATA\PR\FundCredit\outputbandsNEW2SPOCT.smcl";
