JMJ77 / ecb

0 stars 0 forks source link

ECB #1

Open JMJ77 opened 2 years ago

JMJ77 commented 2 years ago

%macro test3(var1,var2);

%let lagvar1=%sysfunc(cats(%substr(&var1,5,4),_lag)); %let lagvar2=%sysfunc(cats(%substr(&var2,5,4),_lag)); ods output ModelType=info(where=(Label1 eq "Type de modèle")); proc varmax data=Daily; model &var1 &var2 / minic=(type=AIC p=10 q=0); run; data null; set info; call symputx("ordre",compress(cValue1,,"kd"));run; proc reg data=Daily; model &var1 = &lagvar1.1-&lagvar1.&ordre; output out=res1(keep =res1) r=res1; run;quit; proc reg data=Daily; model &var2 = &lagvar2.1-&lagvar2.&ordre; output out=res2(keep =res2) r=res2; run;quit; proc reg data=Daily ; model &var1 = &lagvar1.1-&lagvar1.&ordre &lagvar2.1-&lagvar2.&ordre ; output out=res3(keep = res3) r=res3; run;quit; proc reg data=Daily; model &var2 = &lagvar2.1-&lagvar2.&ordre &lagvar1.1-&lagvar1.&ordre ; output out=res4(keep = res4) r=res4; run;quit; data residus1; merge res1(where=(res1^=.)) res2(where=(res2^=.)); run; data residus2; merge res3(where=(res3^=.)) res4(where=(res4^=.)); run; ods output Cov=covres2; proc corr data=residus2 cov; var res3 res4; run; ods output Cov=covres; proc corr data=residus1 cov; var res1 res2; run; data final; merge covres covres2; by Label;run;

proc iml; use final; read all into x; close final; eta1=x[1,1]; eta2=x[2,2]; eps1=x[1,3]; eps2=x[2,4]; Y=x[1:2,3:4]; mesure=j(1,4,.); mesure[1,1]=log(eta1/eps1); mesure[1,2]=log(eta2/eps2); mesure[1,3]=log((eps1eps2)/det(Y)); mesure[1,4]=log((eta1eta2)/det(Y)); cn={"X_Y" "Y_X" "instant" "globale"}; create dep from mesure[colname=cn]; append from mesure; quit;

data toto(drop= X_Y Y_X instant globale) ; set dep; p_valueX_Y=1-cdf('CHISQUARE',3914X_Y,&ordre); p_valueY_X=1-cdf('CHISQUARE',3914Y_X,&ordre); if p_valueX_Y < 0.05 then Dep_X_Y="non";else Dep_X_Y="oui"; if p_valueY_X < 0.05 then Dep_Y_X="non";else Dep_Y_X="oui"; percX_Y=(X_Y/globale)100; percY_X=(Y_X/globale)100; perc_instant=(instant/globale)*100; run; %ouvrir proc print data=dep;run; proc print data=toto;run;

%mend;