From 6b458d3c0d8da1e0eb316332ee5d8f27bcc38e9e Mon Sep 17 00:00:00 2001 From: ikeuchi-screen Date: Thu, 7 Jan 2021 11:32:32 +0900 Subject: [PATCH] Add get_error_independence_p_values --- docs/image/bottom_up_parce.svg | 98 +-- docs/image/bottom_up_parce2.svg | 108 ++- docs/image/bottom_up_parce_hist.png | Bin 3663 -> 4448 bytes docs/image/lingam1.svg | 85 ++ docs/image/lingam2.svg | 85 ++ docs/image/longitudinal_hist.png | Bin 3836 -> 4021 bytes docs/image/multiple_dataset_dag3.svg | 70 +- docs/image/multiple_dataset_dag4.svg | 92 +-- docs/image/multiple_dataset_dag5.svg | 172 ++-- docs/image/multiple_dataset_hist.png | Bin 4199 -> 5791 bytes docs/image/rcd_dag1.svg | 136 ++- docs/image/rcd_dag2.svg | 131 +-- docs/image/rcd_hist.png | Bin 4764 -> 4147 bytes docs/image/var_hist.png | Bin 3978 -> 4149 bytes docs/image/varma_hist.png | Bin 4323 -> 4459 bytes docs/tutorial/bottom_up_parce.rst | 177 ++-- docs/tutorial/lingam.rst | 255 +++++- docs/tutorial/longitudinal.rst | 404 +++++---- docs/tutorial/multiple_dataset.rst | 366 +++++---- docs/tutorial/rcd.rst | 406 ++++----- docs/tutorial/var.rst | 379 +++++---- docs/tutorial/varma.rst | 352 ++++---- examples/BottomUpParceLiNGAM.ipynb | 489 +++++------ examples/DirectLiNGAM.ipynb | 149 ++-- examples/LongitudinalLiNGAM.ipynb | 565 +++++++------ examples/MultiGroupDirectLiNGAM.ipynb | 1092 ++++++++++++++++++------- examples/RCD.ipynb | 746 +++++++++-------- examples/VARLiNGAM.ipynb | 474 +++++------ examples/VARMALiNGAM.ipynb | 460 ++++++----- lingam/__init__.py | 15 +- lingam/base.py | 38 +- lingam/bottom_up_parce_lingam.py | 58 +- lingam/longitudinal_lingam.py | 71 +- lingam/multi_group_direct_lingam.py | 58 +- lingam/rcd.py | 63 +- lingam/var_lingam.py | 48 +- lingam/varma_lingam.py | 48 +- 37 files changed, 4450 insertions(+), 3240 deletions(-) create mode 100644 docs/image/lingam1.svg create mode 100644 docs/image/lingam2.svg diff --git a/docs/image/bottom_up_parce.svg b/docs/image/bottom_up_parce.svg index 926440f..59c942e 100644 --- a/docs/image/bottom_up_parce.svg +++ b/docs/image/bottom_up_parce.svg @@ -1,110 +1,96 @@ - - + - +%3 + - -x0 +x0 x0 - -x1 +x1 x1 - -x0->x1 - - +x0->x1 + + 0.50 - -x4 +x4 x4 - -x0->x4 - - +x0->x4 + + 0.50 - -x5 +x5 x5 - -x0->x5 - - +x0->x5 + + 0.50 - -x2 +x2 x2 - -x2->x1 - - +x2->x1 + + 0.50 - -x2->x4 - - +x2->x4 + + -0.50 - -x3 - -x3 +x3 + +x3 - -x3->x0 - - -0.50 +x3->x0 + + +0.50 - -x6 - -x6 +x6 + +x6 - -x6->x2 - - -2.00 +x6->x2 + + +2.00 - -x6->x3 - - -2.00 +x6->x3 + + +2.00 diff --git a/docs/image/bottom_up_parce2.svg b/docs/image/bottom_up_parce2.svg index 1917e57..ffb7f66 100644 --- a/docs/image/bottom_up_parce2.svg +++ b/docs/image/bottom_up_parce2.svg @@ -1,97 +1,85 @@ - - - + + - +%3 + - -x0 - -x0 +x0 + +x0 - -x1 +x1 x1 - -x0->x1 - - -0.50 +x0->x1 + + +0.50 - -x4 +x4 x4 - -x0->x4 - - -0.45 +x0->x4 + + +0.45 - -x5 - -x5 +x5 + +x5 - -x0->x5 - - -0.48 +x0->x5 + + +0.48 - -x2 - -x2 +x2 + +x2 - -x2->x1 - - -0.49 +x2->x1 + + +0.49 - -x3 - -x3 +x3 + +x3 - -x2->x3 - - - +x2->x3 + + + - -x2->x4 - - --0.45 +x2->x4 + + +-0.45 - -x3->x0 - - -0.51 +x3->x0 + + +0.51 diff --git a/docs/image/bottom_up_parce_hist.png b/docs/image/bottom_up_parce_hist.png index 0eef81f1795ac05aa09295cc258d869d17a2ac9e..f1c0ea55d6ce39fea2fb28e72501ef345b336c20 100644 GIT binary pat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$Fp=f zIx#c4l+BdrvdS7V-rJrZ3C?F{!0Pv{yvOgVF%;FSi}&GiTagbPIZD^Ox$)_ednPYp zymgnu&8;U|xm^Sys=4OZp2^*z1QUYrsLXpQRH;^lrcG&98g|V*XH=<)QG#Y#t50V* z$(oqX;KSCCL66zG>@1 zMxaT1X2Lr+K8v?Dqbka*V3(6G=QdBO>H2_D^U5j|ABNC@Ex~j(_`Qx-Wm}1e#Fx}> zo+^TcYxfN&-{D2o-i{jK!CUh9;sfXJE?%BslGRI z;lwaC|NUYciz$H%&N3`-M)kdfq~pHA?r7G-yu0O&97Dk|!FHykmRa3XitU-IX2F&m zIc+O)bAjW>4ps2xM)n^UW^hNr6-Eq|P?#`HeVW`oRh_6KcEPiE>Jw;u#kELT#mhUX z*Hg(3oJ8b8XD8t@4C}->2zd%FoimPIr_p)j`!ilt1+wP+7=wIO6#At8r|!@(u1|5| zgPsI*fNmLF+``$6qlLt4+h3bl0_Lwk)^@#XXI7dH+-X)m3A)3k-n95+_3Qro1oWS+ b#eBncO3v$1 + + + + + +%3 + + +x0 + +x0 + + +x1 + +x1 + + +x0->x1 + + +3.00 + + +x4 + +x4 + + +x0->x4 + + +8.00 + + +x5 + +x5 + + +x0->x5 + + +4.00 + + +x2 + +x2 + + +x2->x1 + + +2.00 + + +x2->x4 + + +-1.00 + + +x3 + +x3 + + +x3->x0 + + +3.00 + + +x3->x2 + + +6.00 + + + diff --git a/docs/image/lingam2.svg b/docs/image/lingam2.svg new file mode 100644 index 0000000..e06d39b --- /dev/null +++ b/docs/image/lingam2.svg @@ -0,0 +1,85 @@ + + + + + + +%3 + + +x0 + +x0 + + +x1 + +x1 + + +x0->x1 + + +2.99 + + +x4 + +x4 + + +x0->x4 + + +7.98 + + +x5 + +x5 + + +x0->x5 + + +3.80 + + +x2 + +x2 + + +x2->x1 + + +1.99 + + +x2->x4 + + +-1.00 + + +x3 + +x3 + + +x3->x0 + + +2.99 + + +x3->x2 + + +5.59 + + + diff --git a/docs/image/longitudinal_hist.png b/docs/image/longitudinal_hist.png index 8eb989cfb2bd6f963eb232f37af349c4557f2292..191a9e37952a4b943294ac77587cd42bf922cf9e 100644 GIT binary patch literal 4021 zcmd6qc~Fzr`o|Mcq9UY`OBGPiBrGjE5eS5(RRkh}7TdD#YuF*EK_Db@)mT9^C=gaH zR7^2|MKLVGONASqIh&$s%J@`i&BmSCuMBxVCkNY zpg_F?`bPw(+IOgq-iSZ-xjplMFKr*Uj>g zc^00&xOVkm1v(pAfW?H$13>9#@e75)`%z?fv61zz#G8p7@;5 zJ+^1^kTd2t_g*)F!C(QqbU9NnK&4^GNz=nuCz)6BWiosp6#A7 zn`=Ke_4u=*>CD1UJNWRTaVTo)F!h;@^hxWd&a|*zN{}UMF7P{T zR44tcAmOaKr{oeqCwI^g|2F@->DQ=8`-K{Y>?^n6aq>xB|G-;ge`_9{quxy#8=AAQ zB2=h^6&IN)74F_Exa}@A5Qm}hzTKItE;3GM)i93mkkbU6 zh8xk*%&^tohJV+0*Cgr68NzXiyB+7<{7B0)=>Y?WlLh+^yS}_DI9MCopJOZk+3wqW_2uVR0mPI)#e78nXPn3>>6sJg^{%tTQ&Uq zx}0KcL(G%Q?g25X-e2P126_;e7_wkDKEz4Q36ca8`X$-GE1#^B=yjo)dyU~28T038 zaEP4J63^vXR;Ya5;jmC*UeP|5^Bs}clAFznDF2w{wjjYf%!Q*RDTflo5jsLyK+9{? zR8siE#d#`krm&k#%aO9tNwv6EsuuZTu zZ*#62Wu?>Rq42oTFJn|!C+x+FqtWZCfCeIc59^8C0{k5OjfT}4g$I8va=(ct6l7)y z-n)RIU=6iN1s*4?r#4VK2;66`ntWS!8NJTPvAmea5m7}&*^aA$a& zTd>W;tMoeYF`Ez!Jh+rG$>mH_@-_~tR6pb>l(raE54Hm;>2+$um5u$Jynr=FB$+mR zo9hvOW&M{du%N5H82!Gk)**{R`+!htETu%p=tIDIEHM7MsjXW?lTIas*dj@MZB^)f8J|+ zHe;XCNjsfLH>O8)T9r`da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)fVX{=gPu`g0yvb>W8raexsW`F1W?vXN& z8iSdG)|oy&J;5LBf*dI^Vj2DpIPQnzZHzT+T4xF`fx+k{n?@V$L*MkGL)#1~-;bQ* zxo9S-t;BFp;(K7iZ8eun(7Jsrj%1`7_jo_eR=SyaZyn}XE=f4ib#jNuw`cGoeTEFT zfeE36SU-tM>G<0?!~&{!nSl|yU!`#Tp%7c|z6FGU=XJl=r&fM51;is`&x< zqX;QdJ4u_Ms%lG3t4zwBa76V0bkZt}JGDmWuP3t(6TRk)Ec96x#7zz(nZ%6gPr37P zu)V>Pvqa$$8$l7BGiQ$BAZcz=QeO_pPkY`iDjVnLq?$m(76b1EXY@R3f9PB*3hXgW zUc4y_q;(}K$n89e7P*Zj*izHnz^g*qN(%+m53W^0{=`E6&#TDK_3?`o{-k-~h!m71 z5nK=fTVo`1E)-(+`MA9Ow6nU11(kpda4D@Zb-JFv-tNG)$0wh)I4Ah+QNCmgCYMh4 z!bx3WTX=1sk{cZHlLbWXHTo5tG*!?RQEw}K^-$}UEU{w>OPsZ5+7}$Ql|I7^1j2LB zD7pC%{wXQjCRA8WkGE(l@_Nwv*rfXO_`T@;r62Vq04z@RNNroLc+XQbG;4}Idj^Ny z`h%@-p`$f!#*n`F$(_v;XN@IGnykJ_i#t3wqw|)f71lod3{{^Jj+3(Q7Dfq`bIH^s nDcL)aQL6jXjPg5Ok=)FaWn&elcCS`BsUiS3A41`_pl|*LdG1I~ diff --git a/docs/image/multiple_dataset_dag3.svg b/docs/image/multiple_dataset_dag3.svg index 0f0de89..b7ead97 100644 --- a/docs/image/multiple_dataset_dag3.svg +++ b/docs/image/multiple_dataset_dag3.svg @@ -4,26 +4,26 @@ - + %3 - + x0 - -x0 + +x0 x1 - -x1 + +x1 x0->x1 - - -3.00 + + +2.87 x4 @@ -32,54 +32,48 @@ x0->x4 - - -7.98 + + +6.09 x5 - -x5 + +x5 -x0->x5 - - -4.00 +x0->x5 + + +3.97 x2 - -x2 + +x2 x2->x1 - - -2.00 - - -x2->x4 - - --0.99 + + +1.97 x3 - -x3 + +x3 x3->x0 - - -3.01 + + +3.01 x3->x2 - - -6.00 + + +5.88 diff --git a/docs/image/multiple_dataset_dag4.svg b/docs/image/multiple_dataset_dag4.svg index 33c6687..51a3f35 100644 --- a/docs/image/multiple_dataset_dag4.svg +++ b/docs/image/multiple_dataset_dag4.svg @@ -4,88 +4,88 @@ - - + + %3 - + x0 - -x0 + +x0 x1 - -x1 + +x1 -x0->x1 - - -3.51 +x0->x1 + + +3.52 x4 - -x4 + +x4 x0->x4 - - -7.52 + + +8.46 x5 - -x5 + +x5 x0->x5 - - -4.42 + + +4.45 x2 - -x2 - - -x2->x0 - - -0.04 + +x2 -x2->x1 - - -2.49 +x2->x1 + + +2.47 x2->x4 - - --0.94 + + +-1.47 x3 - -x3 + +x3 -x3->x0 - - -3.25 +x3->x0 + + +3.48 + + +x3->x1 + + +0.17 x3->x2 - - -6.48 + + +6.38 diff --git a/docs/image/multiple_dataset_dag5.svg b/docs/image/multiple_dataset_dag5.svg index fae9a7c..8da908f 100644 --- a/docs/image/multiple_dataset_dag5.svg +++ b/docs/image/multiple_dataset_dag5.svg @@ -4,124 +4,112 @@ - + %3 - + x0 - -x0 + +x0 + + +x4 + +x4 + + +x0->x4 + + +8.98 x1 - -x1 + +x1 x1->x0 - - -0.01 + + +-0.03 x2 - -x2 + +x2 - -x2->x0 - - -0.07 - - -x2->x1 - - -1.66 + +x1->x2 + + +0.32 x3 - -x3 + +x3 - -x3->x0 - - -0.06 + +x1->x3 + + +-0.02 - -x3->x2 - - -5.60 - - -x4 - -x4 - - -x3->x4 - - -18.26 + +x1->x4 + + +-0.25 x5 - -x5 - - -x3->x5 - - -2.84 - - -x4->x0 - - -0.10 - - -x4->x1 - - --0.26 - - -x4->x2 - - --0.12 - - -x4->x5 - - -0.52 + +x5 + + +x1->x5 + + +0.56 + + +x2->x3 + + +0.19 + + +x2->x4 + + +-0.66 - -x5->x0 - - -0.04 + +x3->x0 + + +0.99 - -x5->x1 - - -1.32 + +x5->x0 + + +0.22 -x5->x2 - - -0.22 +x5->x2 + + +-0.17 + + +x5->x3 + + +0.03 diff --git a/docs/image/multiple_dataset_hist.png b/docs/image/multiple_dataset_hist.png index 78bf51d735c97c97ebb5f015d9f7c8c79941bf76..d348a2c26de729cadb64789f6274bc095f53ee8f 100644 GIT binary patch literal 5791 zcmb7|2UJsO-o{gCf|NKS9W>zRh*FH93dk4)1_7lAhB}l45=s;h5J_k*yf?Qz&;R-V-upk7Y|O<) z%O4C??VXz!Jz^EUWae^UJvmP4mym`(9%GhJnR=5N-)sW z{J#kr!Pl{xnPSB`AdvKyCCbzxB4cihRO#j$Gqbqbcw}Gi=y7$|-!&=azo!f$V`YK( zhnfB#&`(9a$%H9g6_mNHVl^9jTclXJrwCt?BVM}&z5zIxe@Kv!yLaC+43K*g`{2Zj z6B`e%{QyfUAG#NKz=}9-NXm%e5gI8WUB;W^A)gvNcHe!(nrxn(7>%0W$=LoFvm!@J zOZzs_p|p2h<6PpI=KT=M6B(w5Eq_Fas1*`~C~DGOhkwp}At#XNpm*zBq9|6%!tU+g zCmH%QiRqDF0{*}i&)u^_aLX1iFySCq+%vpDK^!NQAvCHxVP?_yvw_$et{_twDN+sD zS}rj0zW#KnK1ai&>6gHf8#-4UOs?V)B~@}QcAO^z`#J{<3=Cd;f5%9sD8{cq2r04x zy=Y?-CN0oEvR@1zc)Lo++Zm^nZ1AWTU7u#R>QnyZOH>%>hWSzNopO2c= zK+O^j1%W(mU*vRjTwr?xVsd4S=xDo9Tb3F6C#Ka;O8(wLOM>Ic!3@H zHOY#AI!NsagvnS6?xn_q>wijMw5tH-*~XfxI( z@zhoD!~(lLMbl$A%yeqX+btO3QBu|P=7anI8tYBp);$^af;E8F6(I^obOxxyCnJHE zv`BB}8OTQtyS*lGr2XAHhqmpuwzkw%+4!;(`l-0gZkZ)UokV^%=dfHd`c9sWU;bck z@BOUtbF0zoeketWlkE%@#fKd>th5g(1n>Y*YK%W-iM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}B{Q;_u#EO;$0|z^X>HB;c9-pl?tG^X2#66zCl+&g?rJ|J2qP`%8(z!wvzu9Kr z_I?#$G&HgrWp0SCH|rR7PpSHjj6BVPvNt0sgZ&tGn>ytYDbqC%27b;6d(HN9qa{=xylGLZ8{k zg7UZ#hS51`du~#hYSq(M3@L|g(gy}CZ?yVthr}qE<25l^;_+^NLjL4X`Ini`z~|IJ zFT~|fZf0mBs-@gcWLIc7NESH4zFqhW@}pP8mJTLsiS$o`<#a~bDRNq&!(Z2WeA&jE1=&? z_8DWqgQYAn=*o7BjTRR9n;k2GJQe~t!h38Q8rz+R(x5AJdC?@hD)u-dBD5$?nY-la zEoaVp$(Vd`k(V`{*nGcIz9;S#WUWXwc3u(v`O~qs$D^VjRksb@ zWY?gO0WY+#KQoiXV~Sr$crxaR?CU=y zddjAGmaeKh_i`yZ1|TZ}Rtk{NA$0M~FuQ8MW+sm-3)qIvD|1?{6NG*h1Qd;GvnrqQ ztVC=iW;DKgIpWtT2!s diff --git a/docs/image/rcd_dag1.svg b/docs/image/rcd_dag1.svg index cfa9c07..6d9fecc 100644 --- a/docs/image/rcd_dag1.svg +++ b/docs/image/rcd_dag1.svg @@ -1,110 +1,96 @@ - - - + + - +%3 + - -x0 - -x0 +x0 + +x0 - -x2 - -x2 +x2 + +x2 - -x0->x2 - - -0.80 +x0->x2 + + +0.80 - -x4 - -x4 +x4 + +x4 - -x0->x4 - - -1.00 +x0->x4 + + +1.00 - -x1 +x1 x1 - -x1->x0 - - -1.00 +x1->x0 + + +1.00 - -x3 +x3 x3 - -x3->x0 - - -1.00 - - - -f0(x5) - -f0(x5) - - - -f0(x5)->x1 - - -0.60 - - - -f0(x5)->x3 - - -0.50 +x3->x0 + + +1.00 + + +x5 + +x5 + + +x5->x1 + + +0.60 + + +x5->x3 + + +0.50 - -f1(x6) - -f1(x6) +f1(x6) + +f1(x6) - -f1(x6)->x2 - - --0.60 +f1(x6)->x2 + + +-0.60 - -f1(x6)->x4 - - --0.50 +f1(x6)->x4 + + +-0.50 diff --git a/docs/image/rcd_dag2.svg b/docs/image/rcd_dag2.svg index 3c153e5..d8b34c8 100644 --- a/docs/image/rcd_dag2.svg +++ b/docs/image/rcd_dag2.svg @@ -1,84 +1,85 @@ - - - - - + + + +%3 + - -x0 - -x0 - - - -x1 - -x1 - - - -x0->x1 - - - +x0 + +x0 - -x2 - -x2 +x2 + +x2 - -x0->x2 - - -0.75 - - - -x3 - -x3 - - - -x0->x3 - - - +x0->x2 + + +0.75 - -x4 - -x4 +x4 + +x4 - -x0->x4 - - -1.02 +x0->x4 + + +1.02 - - -x1->x3 - - - + +x1 + +x1 + + +x1->x0 + + +0.94 - -x2->x4 - - - +x2->x4 + + + + + +x3 + +x3 + + +x3->x0 + + +0.99 + + +x5 + +x5 + + +x5->x1 + + +0.56 + + +x5->x3 + + +0.56 diff --git a/docs/image/rcd_hist.png b/docs/image/rcd_hist.png index 8be2ceb17747d56f4dfc35479967ed40e97482cf..4c915d9122ffffc265a7a9e65283c3b11768a243 100644 GIT binary patch literal 4147 zcmchac~nzZ9>=plqCkjIabb%fhy`Ua$Rb-65CaGf1yN)#B?A1`A{3#afDs6& zh(aJlluaT$D;9-7RK%bxrl4U;kS($m2opPJren{{bUJ_ZopaAS@1Fba_Wk`n_j@m% za&bV&Da(OCAO!Y=of`-QPLdYzCYZFQEN0+a=}RW|7}kB0^hw^>;GXlrF|nb9s67~cLw(GFJt1*% z#3KdH87VH^K2qU2{tc;Q_%}4K4;Fk378EMsD8i zwBLS0&Ry@^wwgGnAg3JVV%Yx8Ue333H#65l4zCAz)-;~DfG|;!gN5}NAObX$viG<> zm3g~4a_8O=4f;36Ble#c(IwF{K{J|DR!er0cvJ$7EJQa{>`>lx$$z!u2yKq?=9j7APyTo60DZFT`qGmj+h(y)=8ow~y_ zvam>Y1xic3A8@&hfMTOliyY%Y@tBFV^$*>JS;zEjnbLnd6bvmaOlca(Zz6o+8zyc% zVB|azzvts~Ze-cdLiKt#4TD;|D!v z>ti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jIxW+)Q}m)+HMJ;P%1TzZ9tDBb50 msxbKE|M;Hrza*+T1_rPC@5ahL+e6M~(KlFE??79;G diff --git a/docs/image/var_hist.png b/docs/image/var_hist.png index 97f7732e7f1d9693fcfae495a9d9f897b4fd1f43..574e7d7b5db2b04a40d17fe0620b8966bc488faf 100644 GIT binary patch literal 4149 zcmcgvc~DbXy3fL*jgUc6WQ`3`nidfavM(+{h^VxRKx7q20!knlgaiU4QiB0R+8|5V zGT11hECNCT1PG!c5I|sL5tK9xK@5;!gn$H?*fUi#HU0X%>Hg#0s&nsmzjNxIs{32M z@1*>2)>-u%?QZ}8fGW}jaUK8w66FK9MM<8y_N1js{!kzsN4js3U*s*pH2M2hybFo| z0H|#LI)DT35@hnEb(E7=)P)F4RLtdTXaMeV6h15>Dl9Z`Pc-@(Av7X<58Twu6mGI7 zBq|DTbMWB57MMm{!yYVDdHfRq0HGrh$J~hp^Y0R$OkelySe$8I^OoLV`zdYv(Rixx zknv8Jy&s_3JHD?y{NT0?IK-tl;HSE2ucKw_x}`@{_hL;_884u!w5K=HjV-_*f6PwZ zv2^>JQ|Q6M^gzwaiSNdsGjU7o>bO3U$U34ZLn}G1MH<(_9A00Lau%csz199Ha?gZ_{J!hI2(I8%g2Dm4z-Zu2@7?}%Ousfin4iYo@LPC&vW*EI zAAQEAySJ@!eVfZiPPU0a#1F;JUYD+jPGx)7hhh4P;w#c8GEiOL)MgErPr+SD*l&e0 znXXZRI5@=SsU}WCcA0Yj{r^G>JQ#WwnLolVF1-07Xbn;={n^=D%limQd_E^#XXsjgy|=ek+{|*t91b0P zaatoCwiDgvdj8xl&hHG~48DOGPO>PT7M2m+Jl4tQX_OdnJ|zPqcoWq19a5Y72rE8w z#~&cG!tWAisxMyQ#|G>doA3*0Y<$77y~y=hbSg&k$pJVdSa6Kbq`)a_hb0?4JB2xb z-=UWU^b&^(8>dXhCi~NMgv_k4Ebr>9#%8K7*Vxd_2&wJW$NZq7js>xRtxCH02)kMX z)x17p`3Jl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U&H{c diff --git a/docs/tutorial/bottom_up_parce.rst b/docs/tutorial/bottom_up_parce.rst index 673a7b9..6fa6483 100644 --- a/docs/tutorial/bottom_up_parce.rst +++ b/docs/tutorial/bottom_up_parce.rst @@ -22,8 +22,8 @@ In this example, we need to import ``numpy``, ``pandas``, and .. parsed-literal:: - ['1.19.2', '1.1.2', '0.14.1', '1.5.0'] - + ['1.16.2', '0.24.2', '0.11.1', '1.5.1'] + Test data --------- @@ -152,6 +152,7 @@ variable for x2 and x3. +
@@ -199,7 +200,7 @@ call the ``fit`` method. .. parsed-literal:: - + @@ -255,6 +256,30 @@ We can draw a causal graph by utility funciton. +Independence between error variables +------------------------------------ + +To check if the LiNGAM assumption is broken, we can get p-values of +independence between error variables. The value in the i-th row and j-th +column of the obtained matrix shows the p-value of the independence of +the error variables :math:`e_i` and :math:`e_j`. + +.. code-block:: python + + p_values = model.get_error_independence_p_values(X) + print(p_values) + + +.. parsed-literal:: + + [[0. 0.491 nan nan 0.763 0.2 ] + [0.491 0. nan nan 0.473 0.684] + [ nan nan 0. nan nan nan] + [ nan nan nan 0. nan nan] + [0.763 0.473 nan nan 0. 0.427] + [0.2 0.684 nan nan 0.427 0. ]] + + Bootstrapping ------------- @@ -265,7 +290,7 @@ argument specifies the number of bootstrap sampling. import warnings warnings.filterwarnings('ignore', category=UserWarning) - + model = lingam.BottomUpParceLiNGAM() result = model.bootstrap(X, n_sampling=100) @@ -300,7 +325,7 @@ We can check the result by utility function. x1 <--- x3 (b>0) (21.0%) x0 <--- x3 (b>0) (12.0%) x5 <--- x2 (b>0) (7.0%) - + Directed Acyclic Graphs ----------------------- @@ -331,7 +356,7 @@ We can check the result by utility function. DAG[2]: 7.0% x1 <--- x0 (b>0) x1 <--- x2 (b>0) - + Probability ----------- @@ -353,7 +378,7 @@ bootstrapping. [0. 0. 0. 0. 0. 0. ] [0.45 0.03 0.45 0.02 0. 0.07] [0.26 0.01 0.07 0.02 0. 0. ]] - + Causal Effects -------------- @@ -366,7 +391,7 @@ we have replaced the variable index with a label below. .. code-block:: python causal_effects = result.get_causal_effects(min_causal_effect=0.01) - + # Assign to pandas.DataFrame for pretty display df = pd.DataFrame(causal_effects) labels = [f'x{i}' for i in range(X.shape[1])] @@ -429,111 +454,69 @@ we have replaced the variable index with a label below. 0 - x1 - x4 - 0.045256 - 0.14 - - - 1 x0 x5 - 0.517290 + 0.515510 0.12 - 2 + 1 x0 x1 0.477885 0.11 - 3 - x4 - x1 - 0.044782 - 0.11 - - - 4 + 2 x0 x4 0.494946 0.11 - 5 - x5 - x1 - 0.025297 - 0.06 - - - 6 - x5 - x4 - -0.031346 - 0.06 - - - 7 + 3 x2 x1 0.482657 0.02 - 8 + 4 x2 x4 -0.490889 0.02 - 9 + 5 x3 x0 0.511008 0.01 - 10 + 6 x3 x1 0.653876 0.01 - 11 - x0 - x2 - -0.044259 - 0.01 - - - 12 + 7 x3 x2 0.790837 0.01 - 13 - x5 - x2 - 0.054423 - 0.01 - - - 14 + 8 x3 x4 -0.126227 0.01 - 15 + 9 x3 x5 0.265528 @@ -542,7 +525,7 @@ we have replaced the variable index with a label below. - +
We can easily perform sorting operations with pandas.DataFrame. @@ -605,35 +588,35 @@ We can easily perform sorting operations with pandas.DataFrame. - 12 + 7 x3 x2 0.790837 0.01 - 10 + 6 x3 x1 0.653876 0.01 - 1 + 0 x0 x5 - 0.517290 + 0.515510 0.12 - 9 + 5 x3 x0 0.511008 0.01 - 4 + 2 x0 x4 0.494946 @@ -642,7 +625,7 @@ We can easily perform sorting operations with pandas.DataFrame. - +
.. code-block:: python @@ -703,44 +686,44 @@ We can easily perform sorting operations with pandas.DataFrame. - 9 + 5 x3 x0 0.511008 0.01 - 10 + 6 x3 x1 0.653876 0.01 - 11 - x0 + 7 + x3 x2 - -0.044259 + 0.790837 0.01 - 12 + 8 x3 - x2 - 0.790837 + x4 + -0.126227 0.01 - 13 + 9 + x3 x5 - x2 - 0.054423 + 0.265528 0.01 - +
And with pandas.DataFrame, we can easily filter by keywords. The @@ -804,7 +787,7 @@ following code extracts the causal direction towards x1. - 2 + 1 x0 x1 0.477885 @@ -812,27 +795,13 @@ following code extracts the causal direction towards x1. 3 - x4 - x1 - 0.044782 - 0.11 - - - 5 - x5 - x1 - 0.025297 - 0.06 - - - 7 x2 x1 0.482657 0.02 - 10 + 6 x3 x1 0.653876 @@ -841,7 +810,7 @@ following code extracts the causal direction towards x1. - +
Because it holds the raw data of the causal effect (the original data @@ -854,9 +823,9 @@ values of the causal effect, as shown below. import seaborn as sns sns.set() %matplotlib inline - - from_index = 3 # index of x3 - to_index = 0 # index of x0 + + from_index = 0 # index of x0 + to_index = 5 # index of x5 plt.hist(result.total_effects_[:, to_index, from_index]) @@ -864,10 +833,10 @@ values of the causal effect, as shown below. .. parsed-literal:: - (array([88., 0., 0., 0., 0., 0., 0., 0., 0., 1.]), - array([0. , 0.051, 0.102, 0.153, 0.204, 0.256, 0.307, 0.358, 0.409, - 0.46 , 0.511]), - ) + (array([74., 0., 0., 0., 0., 0., 0., 0., 0., 12.]), + array([0. , 0.052, 0.103, 0.155, 0.206, 0.258, 0.309, 0.361, 0.412, + 0.464, 0.516]), +
) diff --git a/docs/tutorial/lingam.rst b/docs/tutorial/lingam.rst index eeba23c..5fe3c38 100644 --- a/docs/tutorial/lingam.rst +++ b/docs/tutorial/lingam.rst @@ -1,11 +1,183 @@ -LiNGAM algorithm -================ -First, we use lingam package: +DirectLiNGAM +============ + +Import and settings +------------------- + +In this example, we need to import ``numpy``, ``pandas``, and ``graphviz`` in addition to ``lingam``. .. code-block:: python + import numpy as np + import pandas as pd + import graphviz import lingam + from lingam.utils import make_dot + + print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__]) + + np.set_printoptions(precision=3, suppress=True) + np.random.seed(100) + + +.. parsed-literal:: + + ['1.16.2', '0.24.2', '0.11.1', '1.5.1'] + + +Test data +--------- + +We create test data consisting of 6 variables. + +.. code-block:: python + + x3 = np.random.uniform(size=1000) + x0 = 3.0*x3 + np.random.uniform(size=1000) + x2 = 6.0*x3 + np.random.uniform(size=1000) + x1 = 3.0*x0 + 2.0*x2 + np.random.uniform(size=1000) + x5 = 4.0*x0 + np.random.uniform(size=1000) + x4 = 8.0*x0 - 1.0*x2 + np.random.uniform(size=1000) + X = pd.DataFrame(np.array([x0, x1, x2, x3, x4, x5]).T ,columns=['x0', 'x1', 'x2', 'x3', 'x4', 'x5']) + X.head() + + + + +.. raw:: html + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
x0x1x2x3x4x5
01.65794712.0903233.5198730.54340510.1827857.401408
11.2173457.6073881.6932190.2783698.7589494.912979
22.22680413.4835553.2015130.42451815.3986269.098729
32.75652720.6542256.0378730.84477616.79515611.147294
40.3192833.3407820.7272650.0047192.3431002.037974
+
+
+ + + +.. code-block:: python + + m = np.array([[0.0, 0.0, 0.0, 3.0, 0.0, 0.0], + [3.0, 0.0, 2.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 6.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0, 0.0, 0.0], + [8.0, 0.0,-1.0, 0.0, 0.0, 0.0], + [4.0, 0.0, 0.0, 0.0, 0.0, 0.0]]) + + dot = make_dot(m) + + # Save pdf + dot.render('dag') + + # Save png + dot.format = 'png' + dot.render('dag') + + dot + + + + +.. image:: ../image/lingam1.svg + + + +Causal Discovery +---------------- Then, if we want to run DirectLiNGAM algorithm, we create a :class:`~lingam.DirectLiNGAM` object and call the :func:`~lingam.DirectLiNGAM.fit` method: @@ -14,42 +186,85 @@ Then, if we want to run DirectLiNGAM algorithm, we create a :class:`~lingam.Dire model = lingam.DirectLiNGAM() model.fit(X) + + + +.. parsed-literal:: + + + * If you want to use the ICA-LiNGAM algorithm, replace :class:`~lingam.DirectLiNGAM` above with :class:`~lingam.ICALiNGAM`. + Using the :attr:`~lingam.DirectLiNGAM.causal_order_` property, we can see the causal ordering as a result of the causal discovery. .. code-block:: python - print(model.causal_order_) + model.causal_order_ + -The output of the :attr:`~lingam.DirectLiNGAM.causal_order_` property is as follows: -.. code-block:: python - [3, 0, 2, 5, 1, 4] +.. parsed-literal:: + + [3, 0, 2, 1, 4, 5] + + Also, using the :attr:`~lingam.DirectLiNGAM.adjacency_matrix_` property, we can see the adjacency matrix as a result of the causal discovery. .. code-block:: python - print(model.adjacency_matrix_) + model.adjacency_matrix_ + + + + +.. parsed-literal:: + + array([[ 0. , 0. , 0. , 2.994, 0. , 0. ], + [ 2.995, 0. , 1.993, 0. , 0. , 0. ], + [ 0. , 0. , 0. , 5.586, 0. , 0. ], + [ 0. , 0. , 0. , 0. , 0. , 0. ], + [ 7.981, 0. , -0.996, 0. , 0. , 0. ], + [ 3.795, 0. , 0. , 0. , 0. , 0. ]]) + + + +We can draw a causal graph by utility funciton. + +.. code-block:: python + + make_dot(model.adjacency_matrix_) + + + + +.. image:: ../image/lingam2.svg + + + +Independence between error variables +------------------------------------ -The output of the :attr:`~lingam.DirectLiNGAM.adjacency_matrix_` property is as follows: +To check if the LiNGAM assumption is broken, we can get p-values of +independence between error variables. The value in the i-th row and j-th +column of the obtained matrix shows the p-value of the independence of +the error variables :math:`e_i` and :math:`e_j`. .. code-block:: python - [[ 0. 0. 0. 3.006 0. 0. ] - [ 3.002 0. 1.996 0. 0. 0. ] - [ 0. 0. 0. 6.001 0. 0. ] - [ 0. 0. 0. 0. 0. 0. ] - [ 7.978 0. -0.988 0. 0. 0. ] - [ 3.998 0. 0. 0. 0. 0. ]] + p_values = model.get_error_independence_p_values(X) + print(p_values) -For example, we can draw a causal graph by using graphviz as follows: -.. image:: ../image/dag.png +.. parsed-literal:: -For details, see also: + [[0. 0.925 0.443 0.978 0.834 0. ] + [0.925 0. 0.133 0.881 0.317 0.214] + [0.443 0.133 0. 0. 0.64 0.001] + [0.978 0.881 0. 0. 0.681 0. ] + [0.834 0.317 0.64 0.681 0. 0.742] + [0. 0.214 0.001 0. 0.742 0. ]] + -* https://github.com/cdt15/lingam/blob/master/examples/DirectLiNGAM.ipynb -* https://github.com/cdt15/lingam/blob/master/examples/DirectLiNGAM(Kernel).ipynb diff --git a/docs/tutorial/longitudinal.rst b/docs/tutorial/longitudinal.rst index 1678a05..49cb194 100644 --- a/docs/tutorial/longitudinal.rst +++ b/docs/tutorial/longitudinal.rst @@ -5,7 +5,8 @@ Longitudinal LiNGAM Import and settings ------------------- -In this example, we need to import ``numpy``, ``pandas``, and ``graphviz`` in addition to ``lingam``. +In this example, we need to import ``numpy``, ``pandas``, and +``graphviz`` in addition to ``lingam``. .. code-block:: python @@ -27,13 +28,14 @@ In this example, we need to import ``numpy``, ``pandas``, and ``graphviz`` in ad .. parsed-literal:: - ['1.16.2', '0.24.2', '0.11.1', '1.3.1'] + ['1.16.2', '0.24.2', '0.11.1', '1.5.1'] Test data --------- -We create test data consisting of 5 variables. The causal model at each timepoint is as follows. +We create test data consisting of 5 variables. The causal model at each +timepoint is as follows. .. code-block:: python @@ -256,6 +258,48 @@ Also, using the :attr:`~lingam.LongitudinalLiNGAM.adjacency_matrices_` property, .. image:: ../image/longitudinal_scatter2.png +Independence between error variables +------------------------------------ + +To check if the LiNGAM assumption is broken, we can get p-values of +independence between error variables. The value in the i-th row and j-th +column of the obtained matrix shows the p-value of the independence of +the error variables :math:`e_i` and :math:`e_j`. + +.. code-block:: python + + p_values_list = model.get_error_independence_p_values() + +.. code-block:: python + + t = 1 + print(p_values_list[t]) + + +.. parsed-literal:: + + [[0. 0.167 0.107 0.534 0.313] + [0.167 0. 0.195 0.821 0.204] + [0.107 0.195 0. 0.005 0.105] + [0.534 0.821 0.005 0. 0.049] + [0.313 0.204 0.105 0.049 0. ]] + + +.. code-block:: python + + t = 2 + print(p_values_list[2]) + + +.. parsed-literal:: + + [[0. 0.723 0.596 0.579 0.564] + [0.723 0. 0.612 0.688 0.412] + [0.596 0.612 0. 0.267 0.636] + [0.579 0.688 0.267 0. 0.421] + [0.564 0.412 0.636 0.421 0. ]] + + Bootstrapping ------------- @@ -679,343 +723,273 @@ Using the :func:`~lingam.LongitudinalBootstrapResult.get_causal_effects` method, 0 x1(1) x0(1) - 0.338725 + 0.269441 1.00 1 - x0(1) - x2(2) - 0.222189 + x0(2) + x4(2) + 0.119620 1.00 2 - x1(1) - x2(2) - 0.334539 + x4(1) + x4(2) + -0.109855 1.00 3 x3(1) - x2(2) - 0.627104 + x4(2) + 0.260481 1.00 4 - x4(1) - x2(2) - -0.192083 + x1(1) + x4(2) + 0.297682 1.00 5 - x0(2) x2(2) - 0.231114 + x3(2) + -0.394208 1.00 6 - x0(1) + x4(1) x3(2) - 0.148424 + -0.152984 1.00 7 - x1(1) + x3(1) x3(2) - -0.288648 + -0.284373 1.00 8 x2(1) x3(2) - 0.464517 + 0.425542 1.00 9 - x2(2) - x1(2) - -0.684859 + x1(1) + x3(2) + -0.263069 1.00 10 - x3(1) - x3(2) - -0.335765 + x0(2) + x2(2) + 0.177046 1.00 11 - x0(2) - x3(2) - -0.126437 + x4(1) + x2(2) + -0.110188 1.00 12 + x3(1) x2(2) - x3(2) - -0.401410 + 0.524608 1.00 13 - x0(1) - x4(2) - -0.110202 + x1(1) + x2(2) + 0.329232 1.00 14 - x1(1) x4(2) - 0.419646 + x1(2) + 0.113916 1.00 15 - x2(1) - x4(2) - -0.075903 + x2(2) + x1(2) + -0.429614 1.00 16 - x3(1) - x4(2) - 0.316278 + x0(1) + x2(2) + 0.202225 1.00 17 - x4(1) - x4(2) - -0.210909 + x1(1) + x0(2) + 0.154852 1.00 18 - x0(2) - x4(2) - 0.250131 + x1(1) + x1(2) + -0.145485 1.00 19 - x4(1) - x3(2) - -0.315993 + x3(1) + x0(1) + 0.116298 1.00 20 - x0(2) + x0(1) x1(2) - -0.014613 + -0.462228 1.00 21 - x4(2) - x1(2) - 0.457002 + x4(1) + x0(1) + -0.562721 1.00 22 x3(1) - x1(2) - -0.107434 + x0(2) + -0.238794 1.00 23 x3(1) - x0(1) - 0.116298 + x1(1) + 0.317693 1.00 24 x4(1) - x0(1) - -0.562715 + x1(2) + 0.222208 1.00 25 - x3(1) x1(1) - 0.397728 + x2(1) + 0.187445 1.00 26 x1(1) - x2(1) - 0.384131 + x4(1) + -0.280015 1.00 27 - x1(1) - x4(1) - -0.379965 - 1.00 + x4(2) + x3(2) + -0.059277 + 0.92 28 x4(1) - x1(2) - 0.276994 - 1.00 + x0(2) + -0.139972 + 0.91 29 - x0(1) - x0(2) - 0.195237 - 1.00 + x4(2) + x2(2) + 0.033740 + 0.69 30 - x1(1) - x0(2) - 0.289916 - 1.00 + x4(1) + x2(1) + -0.050954 + 0.54 31 x2(1) - x0(2) - 0.035207 - 1.00 - - - 32 - x3(1) x4(1) - -0.028890 - 1.00 - - - 33 - x3(1) - x0(2) - -0.318041 - 1.00 + -0.102010 + 0.46 - 34 - x4(1) + 32 + x2(1) x0(2) - -0.257058 - 1.00 - - - 35 - x0(1) - x1(2) - -0.575730 - 1.00 - - - 36 - x1(1) - x1(2) - -0.153895 - 1.00 + 0.034217 + 0.35 - 37 + 33 x2(1) x1(2) - 0.196489 - 1.00 + 0.161172 + 0.34 - 38 - x2(1) + 34 x2(2) - -0.062109 - 0.99 - - - 39 - x4(2) - x3(2) - -0.070714 - 0.92 - - - 40 x4(2) - x2(2) - 0.033930 - 0.69 + 0.029630 + 0.31 - 41 + 35 + x0(1) x3(2) - x1(2) - -0.063276 - 0.63 + 0.106614 + 0.19 - 42 - x2(1) + 36 x0(1) - -0.011222 - 0.58 - - - 43 - x4(1) - x2(1) - -0.121987 - 0.54 + x0(2) + 0.136141 + 0.15 - 44 + 37 x2(1) - x4(1) - -0.108512 - 0.46 - - - 45 - x1(2) - x3(2) - -0.030521 - 0.37 - - - 46 x2(2) - x4(2) - 0.035184 - 0.31 - - - 47 - x0(1) - x2(1) - -0.071555 - 0.10 + -0.089162 + 0.12 - 48 + 38 x3(2) x4(2) - -0.066850 + -0.081235 0.08 @@ -1085,38 +1059,38 @@ We can easily perform sorting operations with pandas.DataFrame. - 3 + 12 x3(1) x2(2) - 0.627104 + 0.524608 1.0 8 x2(1) x3(2) - 0.464517 + 0.425542 1.0 - 21 - x4(2) - x1(2) - 0.457002 + 13 + x1(1) + x2(2) + 0.329232 1.0 - 14 + 23 + x3(1) x1(1) - x4(2) - 0.419646 + 0.317693 1.0 - 25 - x3(1) + 4 x1(1) - 0.397728 + x4(2) + 0.297682 1.0 @@ -1126,7 +1100,8 @@ We can easily perform sorting operations with pandas.DataFrame. -And with pandas.DataFrame, we can easily filter by keywords. The following code extracts the causal direction towards x0(2). +And with pandas.DataFrame, we can easily filter by keywords. The +following code extracts the causal direction towards x0(2). .. code-block:: python @@ -1186,48 +1161,49 @@ And with pandas.DataFrame, we can easily filter by keywords. The following code - 29 - x0(1) + 17 + x1(1) x0(2) - 0.195237 - 1.0 + 0.154852 + 1.00 - 30 - x1(1) + 22 + x3(1) x0(2) - 0.289916 - 1.0 + -0.238794 + 1.00 - 31 - x2(1) + 28 + x4(1) x0(2) - 0.035207 - 1.0 + -0.139972 + 0.91 - 33 - x3(1) + 32 + x2(1) x0(2) - -0.318041 - 1.0 + 0.034217 + 0.35 - 34 - x4(1) + 36 + x0(1) x0(2) - -0.257058 - 1.0 + 0.136141 + 0.15 -
-Because it holds the raw data of the causal effect (the original data for calculating the median), it is possible to draw a histogram of the values of the causal effect, as shown below. +Because it holds the raw data of the causal effect (the original data +for calculating the median), it is possible to draw a histogram of the +values of the causal effect, as shown below. .. code-block:: python diff --git a/docs/tutorial/multiple_dataset.rst b/docs/tutorial/multiple_dataset.rst index b934de0..6f6bd57 100644 --- a/docs/tutorial/multiple_dataset.rst +++ b/docs/tutorial/multiple_dataset.rst @@ -5,7 +5,8 @@ MultiGroupDirectLiNGAM Import and settings ------------------- -In this example, we need to import ``numpy``, ``pandas``, and ``graphviz`` in addition to ``lingam``. +In this example, we need to import ``numpy``, ``pandas``, and +``graphviz`` in addition to ``lingam``. .. code-block:: python @@ -23,7 +24,7 @@ In this example, we need to import ``numpy``, ``pandas``, and ``graphviz`` in ad .. parsed-literal:: - ['1.16.2', '0.24.2', '0.11.1', '1.3.1'] + ['1.16.2', '0.24.2', '0.11.1', '1.5.1'] Test data @@ -33,12 +34,12 @@ We generate two datasets consisting of 6 variables. .. code-block:: python - x3 = np.random.uniform(size=10000) - x0 = 3.0*x3 + np.random.uniform(size=10000) - x2 = 6.0*x3 + np.random.uniform(size=10000) - x1 = 3.0*x0 + 2.0*x2 + np.random.uniform(size=10000) - x5 = 4.0*x0 + np.random.uniform(size=10000) - x4 = 8.0*x0 - 1.0*x2 + np.random.uniform(size=10000) + x3 = np.random.uniform(size=1000) + x0 = 3.0*x3 + np.random.uniform(size=1000) + x2 = 6.0*x3 + np.random.uniform(size=1000) + x1 = 3.0*x0 + 2.0*x2 + np.random.uniform(size=1000) + x5 = 4.0*x0 + np.random.uniform(size=1000) + x4 = 8.0*x0 - 1.0*x2 + np.random.uniform(size=1000) X1 = pd.DataFrame(np.array([x0, x1, x2, x3, x4, x5]).T ,columns=['x0', 'x1', 'x2', 'x3', 'x4', 'x5']) X1.head() @@ -99,53 +100,52 @@ We generate two datasets consisting of 6 variables. 0 - 2.394708 - 15.312359 - 3.685054 + 2.239321 + 15.340724 + 4.104399 0.548814 - 15.780259 - 9.948090 + 14.176947 + 9.249925 1 - 2.325771 - 16.145216 - 4.332293 + 2.155632 + 16.630954 + 4.767220 0.715189 - 14.335879 - 9.514409 + 12.775458 + 9.189045 2 - 2.197313 - 15.848718 - 4.539881 + 2.284116 + 15.910406 + 4.139736 0.602763 - 14.027410 - 9.266158 + 14.201794 + 9.273880 3 - 1.672250 - 13.200354 - 3.675534 + 2.343420 + 14.921457 + 3.519820 0.544883 - 10.421554 - 6.771233 + 15.580067 + 9.723392 4 - 1.282752 - 11.337503 - 3.486211 + 1.314940 + 11.055176 + 3.146972 0.423655 - 7.533376 - 5.368668 + 7.604743 + 5.312976 -
@@ -235,48 +235,48 @@ We generate two datasets consisting of 6 variables. 0 - 3.848617 - 29.790327 - 6.151635 - 0.927955 - 23.683228 - 17.497765 + 1.913337 + 14.568170 + 2.893918 + 0.374794 + 12.115455 + 9.358286 1 - 3.765482 - 28.839731 - 5.981344 - 0.902937 - 23.362070 - 17.126491 + 2.013935 + 15.857260 + 3.163377 + 0.428686 + 12.657021 + 9.242911 2 - 1.613042 - 13.637872 - 2.930467 - 0.427617 - 9.871720 - 7.578267 + 3.172835 + 24.734385 + 5.142203 + 0.683057 + 19.605722 + 14.666783 3 - 1.838085 - 16.640591 - 3.715235 - 0.510806 - 10.427863 - 9.068131 + 2.990395 + 20.878961 + 4.113485 + 0.600948 + 19.452091 + 13.494380 4 - 2.321607 - 19.614986 - 4.540952 - 0.583200 - 13.276292 - 11.184535 + 0.248702 + 2.268163 + 0.532419 + 0.070483 + 1.854870 + 1.130948 @@ -324,7 +324,7 @@ To run causal discovery for multiple datasets, we create a :class:`~lingam.Multi .. parsed-literal:: - + @@ -339,7 +339,7 @@ Using the :attr:`~lingam.MultiGroupDirectLiNGAM.causal_order_` properties, we ca .. parsed-literal:: - [3, 2, 0, 1, 5, 4] + [3, 0, 5, 2, 1, 4] @@ -353,12 +353,12 @@ Also, using the :attr:`~lingam.MultiGroupDirectLiNGAM.adjacency_matrix_` propert .. parsed-literal:: - [[ 0. 0. 0. 3.006 0. 0. ] - [ 3.002 0. 1.996 0. 0. 0. ] - [ 0. 0. 0. 6.001 0. 0. ] - [ 0. 0. 0. 0. 0. 0. ] - [ 7.978 0. -0.988 0. 0. 0. ] - [ 3.998 0. 0. 0. 0. 0. ]] + [[0. 0. 0. 3.006 0. 0. ] + [2.873 0. 1.969 0. 0. 0. ] + [0. 0. 0. 5.882 0. 0. ] + [0. 0. 0. 0. 0. 0. ] + [6.095 0. 0. 0. 0. 0. ] + [3.967 0. 0. 0. 0. 0. ]] @@ -375,12 +375,12 @@ Also, using the :attr:`~lingam.MultiGroupDirectLiNGAM.adjacency_matrix_` propert .. parsed-literal:: - [[ 0. 0. 0.043 3.245 0. 0. ] - [ 3.508 0. 2.491 0. 0. 0. ] - [ 0. 0. 0. 6.481 0. 0. ] + [[ 0. 0. 0. 3.483 0. 0. ] + [ 3.516 0. 2.466 0.165 0. 0. ] + [ 0. 0. 0. 6.383 0. 0. ] [ 0. 0. 0. 0. 0. 0. ] - [ 7.519 0. -0.942 0. 0. 0. ] - [ 4.422 0. 0. 0. 0. 0. ]] + [ 8.456 0. -1.471 0. 0. 0. ] + [ 4.446 0. 0. 0. 0. 0. ]] @@ -400,7 +400,7 @@ datasets. .. parsed-literal:: - (11000, 6) + (2000, 6) .. code-block:: python @@ -415,7 +415,7 @@ datasets. .. parsed-literal:: - [3, 4, 5, 2, 1, 0] + [1, 5, 2, 3, 0, 4] @@ -433,6 +433,45 @@ a single dataset. +Independence between error variables +------------------------------------ + +To check if the LiNGAM assumption is broken, we can get p-values of +independence between error variables. The value in the i-th row and j-th +column of the obtained matrix shows the p-value of the independence of +the error variables :math:`e_i` and :math:`e_j`. + +.. code-block:: python + + p_values = model.get_error_independence_p_values(X_list) + print(p_values[0]) + + +.. parsed-literal:: + + [[0. 0.136 0.075 0.838 0. 0.832] + [0.136 0. 0.008 0. 0.544 0.403] + [0.075 0.008 0. 0.11 0. 0.511] + [0.838 0. 0.11 0. 0.039 0.049] + [0. 0.544 0. 0.039 0. 0.101] + [0.832 0.403 0.511 0.049 0.101 0. ]] + + +.. code-block:: python + + print(p_values[1]) + + +.. parsed-literal:: + + [[0. 0.545 0.908 0.285 0.525 0.728] + [0.545 0. 0.84 0.814 0.086 0.297] + [0.908 0.84 0. 0.032 0.328 0.026] + [0.285 0.814 0.032 0. 0.904 0. ] + [0.525 0.086 0.328 0.904 0. 0.237] + [0.728 0.297 0.026 0. 0.237 0. ]] + + Bootstrapping ------------- @@ -442,7 +481,6 @@ In :class:`~lingam.MultiGroupDirectLiNGAM`, bootstrap can be executed in the sam results = model.bootstrap(X_list, n_sampling=100) - Causal Directions ----------------- @@ -461,9 +499,9 @@ The :func:`~lingam.MultiGroupDirectLiNGAM.bootstrap` method returns a list of mu x1 <--- x2 (100.0%) x2 <--- x3 (100.0%) x4 <--- x0 (100.0%) - x4 <--- x2 (100.0%) x5 <--- x0 (100.0%) - x0 <--- x2 (14.0%) + x4 <--- x2 (94.0%) + x4 <--- x5 (20.0%) .. code-block:: python @@ -481,7 +519,7 @@ The :func:`~lingam.MultiGroupDirectLiNGAM.bootstrap` method returns a list of mu x4 <--- x0 (100.0%) x4 <--- x2 (100.0%) x5 <--- x0 (100.0%) - x0 <--- x2 (45.0%) + x1 <--- x3 (72.0%) Directed Acyclic Graphs @@ -497,7 +535,7 @@ Also, using the :func:`~lingam.BootstrapResult.get_directed_acyclic_graph_counts .. parsed-literal:: - DAG[0]: 75.0% + DAG[0]: 61.0% x0 <--- x3 x1 <--- x0 x1 <--- x2 @@ -505,23 +543,21 @@ Also, using the :func:`~lingam.BootstrapResult.get_directed_acyclic_graph_counts x4 <--- x0 x4 <--- x2 x5 <--- x0 - DAG[1]: 14.0% - x0 <--- x2 + DAG[1]: 13.0% x0 <--- x3 x1 <--- x0 x1 <--- x2 x2 <--- x3 x4 <--- x0 x4 <--- x2 + x4 <--- x5 x5 <--- x0 DAG[2]: 6.0% x0 <--- x3 x1 <--- x0 x1 <--- x2 - x1 <--- x3 x2 <--- x3 x4 <--- x0 - x4 <--- x2 x5 <--- x0 @@ -533,16 +569,16 @@ Also, using the :func:`~lingam.BootstrapResult.get_directed_acyclic_graph_counts .. parsed-literal:: - DAG[0]: 26.0% - x0 <--- x2 + DAG[0]: 59.0% x0 <--- x3 x1 <--- x0 x1 <--- x2 + x1 <--- x3 x2 <--- x3 x4 <--- x0 x4 <--- x2 x5 <--- x0 - DAG[1]: 22.0% + DAG[1]: 17.0% x0 <--- x3 x1 <--- x0 x1 <--- x2 @@ -550,15 +586,15 @@ Also, using the :func:`~lingam.BootstrapResult.get_directed_acyclic_graph_counts x4 <--- x0 x4 <--- x2 x5 <--- x0 - DAG[2]: 13.0% + DAG[2]: 10.0% x0 <--- x2 x0 <--- x3 x1 <--- x0 x1 <--- x2 + x1 <--- x3 x2 <--- x3 x4 <--- x0 x4 <--- x2 - x4 <--- x5 x5 <--- x0 @@ -575,12 +611,12 @@ Using the :func:`~lingam.BootstrapResult.get_probabilities` method, we can get t .. parsed-literal:: - [[0. 0. 0.14 1. 0. 0. ] - [1. 0. 1. 0.06 0. 0. ] + [[0. 0. 0.08 1. 0. 0. ] + [1. 0. 1. 0.08 0. 0.05] [0. 0. 0. 1. 0. 0. ] [0. 0. 0. 0. 0. 0. ] - [1. 0. 1. 0. 0. 0.05] - [1. 0. 0. 0. 0. 0. ]] + [1. 0. 0.94 0. 0. 0.2 ] + [1. 0. 0. 0. 0.01 0. ]] Causal Effects @@ -658,141 +694,113 @@ we have replaced the variable index with a label below. 0 x3 x0 - 3.006408 + 3.005604 1.00 1 x0 x1 - 3.003440 + 2.990264 1.00 2 x2 x1 - 2.003336 + 2.091170 1.00 3 x3 x1 - 21.001464 + 20.937520 1.00 4 - x0 - x5 - 4.008386 + x3 + x2 + 5.969457 1.00 5 - x3 - x2 - 6.002202 + x0 + x4 + 7.992477 1.00 6 x3 - x5 - 12.019234 + x4 + 18.058717 1.00 7 x0 - x4 - 7.997816 + x5 + 3.970275 1.00 8 - x2 - x4 - -0.998284 + x3 + x5 + 12.028240 1.00 9 - x3 - x4 - 18.054079 - 1.00 + x5 + x1 + 0.148078 + 0.29 10 x5 - x1 - -0.053881 - 0.69 + x4 + 0.104561 + 0.21 11 x2 x5 - -0.005313 - 0.62 + 0.152502 + 0.15 12 x5 - x4 - 0.014208 - 0.61 + x2 + 0.078391 + 0.09 13 x2 x0 - 0.001579 - 0.21 + 0.035852 + 0.08 14 - x5 - x2 - -0.018982 - 0.19 - - - 15 - x1 - x5 - -0.011613 - 0.18 - - - 16 - x1 - x4 - 0.005833 - 0.17 - - - 17 - x0 - x2 - -0.004417 - 0.15 - - - 18 x4 x1 - 0.001461 - 0.12 + -1.623188 + 0.03 - 19 + 15 x4 x5 - -0.004811 - 0.08 + 0.027130 + 0.01 @@ -864,35 +872,35 @@ We can easily perform sorting operations with pandas.DataFrame. 3 x3 x1 - 21.001464 + 20.937520 1.0 - 9 + 6 x3 x4 - 18.054079 + 18.058717 1.0 - 6 + 8 x3 x5 - 12.019234 + 12.028240 1.0 - 7 + 5 x0 x4 - 7.997816 + 7.992477 1.0 - 5 + 4 x3 x2 - 6.002202 + 5.969457 1.0 @@ -966,36 +974,36 @@ following code extracts the causal direction towards x1. 1 x0 x1 - 3.003440 + 2.990264 1.00 2 x2 x1 - 2.003336 + 2.091170 1.00 3 x3 x1 - 21.001464 + 20.937520 1.00 - 10 + 9 x5 x1 - -0.053881 - 0.69 + 0.148078 + 0.29 - 18 + 14 x4 x1 - 0.001461 - 0.12 + -1.623188 + 0.03 diff --git a/docs/tutorial/rcd.rst b/docs/tutorial/rcd.rst index e9a76c3..5640e3f 100644 --- a/docs/tutorial/rcd.rst +++ b/docs/tutorial/rcd.rst @@ -1,3 +1,4 @@ + RCD === @@ -14,16 +15,16 @@ In this example, we need to import ``numpy``, ``pandas``, and import graphviz import lingam from lingam.utils import print_causal_directions, print_dagc, make_dot - + print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__]) - + np.set_printoptions(precision=3, suppress=True) .. parsed-literal:: - ['1.19.2', '1.1.2', '0.14.1', '1.5.0'] - + ['1.16.2', '0.24.2', '0.11.1', '1.5.1'] + Test data --------- @@ -35,10 +36,10 @@ variables. .. code-block:: python np.random.seed(0) - + get_external_effect = lambda n: np.random.normal(0.0, 0.5, n) ** 3 n_samples = 300 - + x5 = get_external_effect(n_samples) x6 = get_external_effect(n_samples) x1 = 0.6*x5 + get_external_effect(n_samples) @@ -46,10 +47,10 @@ variables. x0 = 1.0*x1 + 1.0*x3 + get_external_effect(n_samples) x2 = 0.8*x0 - 0.6*x6 + get_external_effect(n_samples) x4 = 1.0*x0 - 0.5*x6 + get_external_effect(n_samples) - - # The latent variables x5 and x6 are not included. - X = pd.DataFrame(np.array([x0, x1, x2, x3, x4]).T, columns=['x0', 'x1', 'x2', 'x3', 'x4']) - + + # The latent variable x6 is not included. + X = pd.DataFrame(np.array([x0, x1, x2, x3, x4, x5]).T, columns=['x0', 'x1', 'x2', 'x3', 'x4', 'x5']) + X.head() @@ -103,6 +104,7 @@ variables. x2 x3 x4 + x5 @@ -113,6 +115,7 @@ variables. 0.014075 -0.047309 0.016311 + 0.686190 1 @@ -121,6 +124,7 @@ variables. -1.115854 -0.035899 -1.254783 + 0.008009 2 @@ -129,6 +133,7 @@ variables. 0.426923 0.064804 0.894242 + 0.117195 3 @@ -137,6 +142,7 @@ variables. 1.265038 0.704166 1.994283 + 1.406609 4 @@ -145,10 +151,12 @@ variables. 0.116967 0.329866 0.257932 + 0.814202 +
@@ -161,15 +169,15 @@ variables. [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,-0.5], [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]) - dot = make_dot(m, labels=['x0', 'x1', 'x2', 'x3', 'x4', 'f0(x5)', 'f1(x6)']) - + dot = make_dot(m, labels=['x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'f1(x6)']) + # Save pdf dot.render('dag') - + # Save png dot.format = 'png' dot.render('dag') - + dot @@ -195,7 +203,7 @@ method. .. parsed-literal:: - + @@ -205,19 +213,20 @@ ancestors sets as a result of the causal discovery. .. code-block:: python ancestors_list = model.ancestors_list_ - + for i, ancestors in enumerate(ancestors_list): print(f'M{i}={ancestors}') .. parsed-literal:: - M0=set() - M1=set() - M2={0, 1, 3} - M3=set() - M4={0, 1, 3} - + M0={1, 3, 5} + M1={5} + M2={0, 1, 3, 5} + M3={5} + M4={0, 1, 3, 5} + M5=set() + Also, using the ``adjacency_matrix_`` properties, we can see the adjacency matrix as a result of the causal discovery. The coefficients @@ -232,11 +241,12 @@ between variables with latent confounders are np.nan. .. parsed-literal:: - array([[0. , nan, 0. , nan, 0. ], - [ nan, 0. , 0. , nan, 0. ], - [0.751, 0. , 0. , 0. , nan], - [ nan, nan, 0. , 0. , 0. ], - [1.016, 0. , nan, 0. , 0. ]]) + array([[0. , 0.939, 0. , 0.994, 0. , 0. ], + [0. , 0. , 0. , 0. , 0. , 0.556], + [0.751, 0. , 0. , 0. , nan, 0. ], + [0. , 0. , 0. , 0. , 0. , 0.563], + [1.016, 0. , nan, 0. , 0. , 0. ], + [0. , 0. , 0. , 0. , 0. , 0. ]]) @@ -249,8 +259,30 @@ between variables with latent confounders are np.nan. .. image:: ../image/rcd_dag2.svg +Independence between error variables +------------------------------------ + +To check if the LiNGAM assumption is broken, we can get p-values of +independence between error variables. The value in the i-th row and j-th +column of the obtained matrix shows the p-value of the independence of +the error variables :math:`e_i` and :math:`e_j`. + +.. code-block:: python + + p_values = model.get_error_independence_p_values(X) + print(p_values) +.. parsed-literal:: + + [[0. 0. nan 0.413 nan 0.68 ] + [0. 0. nan 0.732 nan 0.382] + [ nan nan 0. nan nan nan] + [0.413 0.732 nan 0. nan 0.054] + [ nan nan nan nan 0. nan] + [0.68 0.382 nan 0.054 nan 0. ]] + + Bootstrapping ------------- @@ -261,7 +293,7 @@ argument specifies the number of bootstrap sampling. import warnings warnings.filterwarnings('ignore', category=UserWarning) - + model = lingam.RCD() result = model.bootstrap(X, n_sampling=100) @@ -288,15 +320,15 @@ We can check the result by utility function. .. parsed-literal:: - x4 <--- x0 (b>0) (98.0%) - x2 <--- x0 (b>0) (44.0%) - x2 <--- x4 (b>0) (36.0%) - x0 <--- x1 (b>0) (25.0%) - x0 <--- x3 (b>0) (22.0%) - x4 <--- x3 (b<0) (19.0%) - x2 <--- x1 (b>0) (6.0%) - x2 <--- x3 (b>0) (6.0%) - + x0 <--- x1 (b>0) (100.0%) + x4 <--- x0 (b>0) (99.0%) + x1 <--- x5 (b>0) (97.0%) + x2 <--- x0 (b>0) (96.0%) + x0 <--- x3 (b>0) (92.0%) + x3 <--- x5 (b>0) (67.0%) + x2 <--- x4 (b>0) (13.0%) + x4 <--- x3 (b<0) (11.0%) + Directed Acyclic Graphs ----------------------- @@ -320,18 +352,28 @@ We can check the result by utility function. .. parsed-literal:: - DAG[0]: 21.0% - x2 <--- x4 (b>0) + DAG[0]: 47.0% + x0 <--- x1 (b>0) + x0 <--- x3 (b>0) + x1 <--- x5 (b>0) + x2 <--- x0 (b>0) + x3 <--- x5 (b>0) x4 <--- x0 (b>0) - DAG[1]: 19.0% + DAG[1]: 20.0% x0 <--- x1 (b>0) x0 <--- x3 (b>0) + x1 <--- x5 (b>0) x2 <--- x0 (b>0) x4 <--- x0 (b>0) - DAG[2]: 18.0% + DAG[2]: 10.0% + x0 <--- x1 (b>0) + x0 <--- x3 (b>0) + x1 <--- x5 (b>0) x2 <--- x0 (b>0) + x3 <--- x5 (b>0) x4 <--- x0 (b>0) - + x4 <--- x3 (b<0) + Probability ----------- @@ -347,12 +389,13 @@ bootstrapping. .. parsed-literal:: - [[0. 0.25 0. 0.22 0. ] - [0. 0. 0. 0. 0. ] - [0.44 0.06 0. 0.06 0.36] - [0. 0. 0. 0. 0. ] - [0.98 0.03 0.01 0.21 0. ]] - + [[0. 1. 0. 0.92 0. 0.08] + [0. 0. 0. 0. 0. 0.97] + [0.96 0. 0. 0. 0.13 0. ] + [0. 0. 0. 0. 0. 0.67] + [0.99 0.01 0.02 0.12 0. 0. ] + [0. 0. 0. 0. 0. 0. ]] + Causal Effects -------------- @@ -365,7 +408,7 @@ we have replaced the variable index with a label below. .. code-block:: python causal_effects = result.get_causal_effects(min_causal_effect=0.01) - + # Assign to pandas.DataFrame for pretty display df = pd.DataFrame(causal_effects) labels = [f'x{i}' for i in range(X.shape[1])] @@ -428,78 +471,113 @@ we have replaced the variable index with a label below. 0 - x4 - x2 - 0.225102 - 0.51 + x1 + x0 + 0.929241 + 0.97 1 - x0 + x1 x2 - 0.814519 - 0.20 + 0.642897 + 0.97 2 - x0 + x1 x4 - 1.164953 - 0.20 + 0.940142 + 0.96 3 + x0 x2 - x4 - 0.243174 - 0.04 + 0.733251 + 0.91 4 - x1 x0 - 1.140202 - 0.02 + x4 + 0.976640 + 0.91 5 - x1 - x2 - 0.803256 - 0.02 + x3 + x0 + 0.986875 + 0.66 6 - x1 - x4 - 1.115286 - 0.02 + x3 + x2 + 0.732515 + 0.66 7 x3 - x0 - 1.184964 - 0.01 + x4 + 0.899673 + 0.65 8 - x3 - x2 - 0.872317 - 0.01 + x5 + x0 + 1.021466 + 0.63 9 + x5 + x1 + 0.555707 + 0.63 + + + 10 + x5 + x2 + 0.741192 + 0.63 + + + 11 + x5 x3 + 0.563175 + 0.63 + + + 12 + x5 x4 - 1.084753 - 0.01 + 0.941773 + 0.61 + + + 13 + x4 + x2 + 0.225102 + 0.13 + + + 14 + x2 + x4 + 0.243174 + 0.03 - +
We can easily perform sorting operations with pandas.DataFrame. @@ -562,44 +640,44 @@ We can easily perform sorting operations with pandas.DataFrame. - 7 - x3 + 8 + x5 x0 - 1.184964 - 0.01 + 1.021466 + 0.63 - 2 + 5 + x3 x0 - x4 - 1.164953 - 0.20 + 0.986875 + 0.66 4 - x1 x0 - 1.140202 - 0.02 + x4 + 0.976640 + 0.91 - 6 - x1 + 12 + x5 x4 - 1.115286 - 0.02 + 0.941773 + 0.61 - 9 - x3 + 2 + x1 x4 - 1.084753 - 0.01 + 0.940142 + 0.96 - +
.. code-block:: python @@ -660,107 +738,44 @@ We can easily perform sorting operations with pandas.DataFrame. - 7 - x3 - x0 - 1.184964 - 0.01 + 14 + x2 + x4 + 0.243174 + 0.03 - 8 - x3 + 13 + x4 x2 - 0.872317 - 0.01 + 0.225102 + 0.13 - 9 - x3 + 12 + x5 x4 - 1.084753 - 0.01 + 0.941773 + 0.61 - 4 - x1 + 8 + x5 x0 - 1.140202 - 0.02 + 1.021466 + 0.63 - 5 + 9 + x5 x1 - x2 - 0.803256 - 0.02 - - - - - - - -.. code-block:: python - - df[df['to']=='x1'].head() - - - - -.. raw:: html - -
- - - - - - - - - + + - -
fromtoeffectprobability0.5557070.63
- +
Because it holds the raw data of the causal effect (the original data @@ -773,24 +788,13 @@ values of the causal effect, as shown below. import seaborn as sns sns.set() %matplotlib inline - - from_index = 3 # index of x3 + + from_index = 5 # index of x5 to_index = 0 # index of x0 plt.hist(result.total_effects_[:, to_index, from_index]) - -.. parsed-literal:: - - (array([78., 0., 0., 0., 0., 0., 0., 0., 0., 1.]), - array([0. , 0.118, 0.237, 0.355, 0.474, 0.592, 0.711, 0.829, 0.948, - 1.066, 1.185]), - ) - - - - .. image:: ../image/rcd_hist.png diff --git a/docs/tutorial/var.rst b/docs/tutorial/var.rst index cf9c2ea..ffcdce5 100644 --- a/docs/tutorial/var.rst +++ b/docs/tutorial/var.rst @@ -5,7 +5,8 @@ VARLiNGAM Import and settings ------------------- -In this example, we need to import ``numpy``, ``pandas``, and ``graphviz`` in addition to ``lingam``. +In this example, we need to import ``numpy``, ``pandas``, and +``graphviz`` in addition to ``lingam``. .. code-block:: python @@ -23,7 +24,7 @@ In this example, we need to import ``numpy``, ``pandas``, and ``graphviz`` in ad .. parsed-literal:: - ['1.16.2', '0.24.2', '0.11.1', '1.3.1'] + ['1.16.2', '0.24.2', '0.11.1', '1.5.1'] Test data @@ -67,7 +68,7 @@ To run causal discovery, we create a :class:`~lingam.VARLiNGAM` object and call .. parsed-literal:: - + @@ -124,6 +125,47 @@ Also, using the :attr:`~lingam.VARLiNGAM.adjacency_matrices_` properties, we can +.. code-block:: python + + model.residuals_ + + + + +.. parsed-literal:: + + array([[-0.308, 0.911, -1.152, -1.159, 0.179], + [ 1.364, 1.713, -1.389, -0.265, -0.192], + [-0.861, 0.249, 0.479, -1.557, -0.462], + ..., + [-1.202, 1.819, 0.99 , -0.855, -0.127], + [-0.133, 1.23 , -0.445, -0.753, 1.096], + [-0.069, 0.558, 0.21 , -0.863, -0.189]]) + + + +Using ``DirectLiNGAM`` for the ``residuals_`` properties, we can +calculate B0 matrix. + +.. code-block:: python + + dlingam = lingam.DirectLiNGAM() + dlingam.fit(model.residuals_) + dlingam.adjacency_matrix_ + + + + +.. parsed-literal:: + + array([[ 0. , -0.144, 0. , 0. , 0. ], + [ 0. , 0. , 0. , 0. , 0. ], + [-0.372, 0. , 0. , 0. , 0. ], + [ 0.069, -0.21 , 0. , 0. , 0. ], + [ 0.083, 0. , -0.033, 0. , 0. ]]) + + + We can draw a causal graph by utility funciton. .. code-block:: python @@ -138,6 +180,29 @@ We can draw a causal graph by utility funciton. +Independence between error variables +------------------------------------ + +To check if the LiNGAM assumption is broken, we can get p-values of +independence between error variables. The value in the i-th row and j-th +column of the obtained matrix shows the p-value of the independence of +the error variables :math:`e_i` and :math:`e_j`. + +.. code-block:: python + + p_values = model.get_error_independence_p_values() + print(p_values) + + +.. parsed-literal:: + + [[0. 0.065 0.068 0.038 0.249] + [0.065 0. 0.13 0.88 0.57 ] + [0.068 0.13 0. 0.321 0.231] + [0.038 0.88 0.321 0. 0.839] + [0.249 0.57 0.231 0.839 0. ]] + + Bootstrap --------- @@ -334,280 +399,266 @@ Using the :func:`~lingam.BootstrapResult.get_causal_effects` method, we can get 0 x1(t) x0(t) - -0.142773 + -0.131094 1.00 1 x4(t-1) - x3(t) - -0.245236 + x2(t) + 0.463646 1.00 2 - x3(t-1) + x4(t-1) x3(t) - 0.114877 + -0.224349 1.00 3 - x2(t-1) - x3(t) - -0.203598 + x0(t-1) + x0(t) + -0.297905 1.00 4 - x0(t-1) + x1(t) x3(t) - -0.324941 + -0.217983 1.00 5 - x1(t) - x3(t) - -0.218320 + x3(t-1) + x0(t) + 0.273013 1.00 6 - x4(t-1) - x2(t) - 0.496761 + x2(t-1) + x3(t) + -0.177952 1.00 7 - x1(t) - x2(t) - 0.099477 + x0(t-1) + x3(t) + -0.269388 1.00 8 - x0(t) - x2(t) - -0.439085 + x1(t-1) + x1(t) + -0.260914 1.00 9 - x4(t-1) - x1(t) - 0.454093 + x2(t-1) + x2(t) + 0.310371 1.00 10 - x3(t-1) + x4(t-1) x1(t) - -0.353886 + 0.397907 1.00 11 - x2(t-1) + x0(t) x2(t) - 0.354316 + -0.404106 1.00 12 - x1(t-1) x1(t) - -0.294882 + x2(t) + 0.090684 1.00 13 x3(t-1) - x0(t) - 0.339193 - 1.00 + x1(t) + -0.206743 + 0.99 14 - x2(t-1) - x0(t) - 0.107363 - 1.00 + x3(t-1) + x3(t) + 0.091307 + 0.93 15 x2(t-1) x1(t) - -0.192527 - 1.00 + -0.121280 + 0.86 16 - x0(t-1) x0(t) - -0.381328 - 1.00 + x4(t) + 0.106232 + 0.86 17 - x3(t-1) - x4(t) - 0.099357 - 0.99 + x0(t-1) + x2(t) + 0.083258 + 0.79 18 - x0(t) - x4(t) - 0.145934 - 0.99 + x3(t-1) + x2(t) + -0.085736 + 0.73 19 - x0(t-1) - x2(t) - 0.109297 - 0.98 + x0(t) + x3(t) + 0.075516 + 0.68 20 - x3(t-1) - x2(t) - -0.113304 - 0.98 + x2(t-1) + x0(t) + 0.070990 + 0.58 21 - x4(t-1) - x0(t) - -0.055275 - 0.95 + x1(t-1) + x2(t) + -0.043181 + 0.55 22 - x1(t-1) - x2(t) - -0.048436 - 0.95 + x4(t-1) + x0(t) + -0.047978 + 0.50 23 - x0(t-1) - x4(t) - -0.052491 - 0.93 + x1(t-1) + x0(t) + 0.026918 + 0.32 24 - x1(t) + x2(t) x4(t) - -0.038710 - 0.92 + -0.049998 + 0.29 25 - x0(t-1) - x1(t) - 0.032712 - 0.90 + x3(t) + x0(t) + 0.053440 + 0.23 26 - x1(t-1) - x0(t) - 0.026323 - 0.83 + x4(t) + x2(t) + -0.053585 + 0.22 27 - x2(t-1) - x4(t) - -0.003520 - 0.81 + x3(t) + x2(t) + -0.034164 + 0.22 28 - x4(t-1) + x3(t-1) x4(t) - -0.020322 - 0.78 + 0.069278 + 0.20 29 - x3(t) + x1(t) x4(t) - -0.074582 - 0.70 + -0.032277 + 0.17 30 - x0(t) + x4(t) x3(t) - 0.077178 - 0.69 + -0.041963 + 0.16 31 - x2(t) - x4(t) - -0.064105 - 0.67 + x1(t-1) + x3(t) + 0.018327 + 0.14 32 - x1(t-1) + x2(t) x3(t) - -0.000250 - 0.59 + -0.017783 + 0.13 33 - x1(t-1) - x4(t) - 0.002664 - 0.56 + x0(t-1) + x1(t) + 0.084306 + 0.04 34 x3(t) - x2(t) - 0.008626 - 0.50 + x4(t) + -0.117271 + 0.02 35 x4(t) - x2(t) - -0.062254 - 0.33 - - - 36 - x2(t) - x3(t) - 0.006647 - 0.32 - - - 37 - x3(t) x0(t) - 0.057305 - 0.29 + 0.081813 + 0.01 - 38 + 36 + x0(t-1) x4(t) - x3(t) - -0.040263 - 0.27 + -0.085855 + 0.01 - 39 + 37 + x1(t-1) x4(t) - x0(t) - 0.081813 + 0.036685 0.01 @@ -677,39 +728,39 @@ We can easily perform sorting operations with pandas.DataFrame. - 6 + 1 x4(t-1) x2(t) - 0.496761 + 0.463646 1.00 - 9 + 10 x4(t-1) x1(t) - 0.454093 + 0.397907 1.00 - 11 + 9 x2(t-1) x2(t) - 0.354316 + 0.310371 1.00 - 13 + 5 x3(t-1) x0(t) - 0.339193 + 0.273013 1.00 - 18 + 16 x0(t) x4(t) - 0.145934 - 0.99 + 0.106232 + 0.86 @@ -778,39 +829,39 @@ And with pandas.DataFrame, we can easily filter by keywords. The following code - 9 - x4(t-1) + 8 + x1(t-1) x1(t) - 0.454093 - 1.0 + -0.260914 + 1.00 10 - x3(t-1) + x4(t-1) x1(t) - -0.353886 - 1.0 + 0.397907 + 1.00 - 12 - x1(t-1) + 13 + x3(t-1) x1(t) - -0.294882 - 1.0 + -0.206743 + 0.99 15 x2(t-1) x1(t) - -0.192527 - 1.0 + -0.121280 + 0.86 - 25 + 33 x0(t-1) x1(t) - 0.032712 - 0.9 + 0.084306 + 0.04 @@ -819,7 +870,9 @@ And with pandas.DataFrame, we can easily filter by keywords. The following code -Because it holds the raw data of the causal effect (the original data for calculating the median), it is possible to draw a histogram of the values of the causal effect, as shown below. +Because it holds the raw data of the causal effect (the original data +for calculating the median), it is possible to draw a histogram of the +values of the causal effect, as shown below. .. code-block:: python diff --git a/docs/tutorial/varma.rst b/docs/tutorial/varma.rst index a723498..11d3016 100644 --- a/docs/tutorial/varma.rst +++ b/docs/tutorial/varma.rst @@ -5,7 +5,8 @@ VARMALiNGAM Import and settings ------------------- -In this example, we need to import ``numpy``, ``pandas``, and ``graphviz`` in addition to ``lingam``. +In this example, we need to import ``numpy``, ``pandas``, and +``graphviz`` in addition to ``lingam``. .. code-block:: python @@ -26,7 +27,7 @@ In this example, we need to import ``numpy``, ``pandas``, and ``graphviz`` in ad .. parsed-literal:: - ['1.16.2', '0.24.2', '0.11.1', '1.3.1'] + ['1.16.2', '0.24.2', '0.11.1', '1.5.1'] Test data @@ -77,7 +78,7 @@ To run causal discovery, we create a :class:`~lingam.VARMALiNGAM` object and cal .. parsed-literal:: - + @@ -152,6 +153,28 @@ Also, using the :attr:`~lingam.VARMALiNGAM.adjacency_matrices_` properties, we c +Using ``DirectLiNGAM`` for the ``residuals_`` properties, we can +calculate psi0 matrix. + +.. code-block:: python + + dlingam = lingam.DirectLiNGAM() + dlingam.fit(model.residuals_) + dlingam.adjacency_matrix_ + + + + +.. parsed-literal:: + + array([[ 0. , 0. , -0.238, 0. , 0. ], + [-0.392, 0. , 0.182, 0. , 0. ], + [ 0. , 0. , 0. , 0. , 0. ], + [ 0.523, -0.149, 0. , 0. , 0. ], + [ 0. , 0. , 0. , 0. , 0. ]]) + + + We can draw a causal graph by utility funciton .. code-block:: python @@ -165,6 +188,28 @@ We can draw a causal graph by utility funciton .. image:: ../image/varma_dag.svg +Independence between error variables +------------------------------------ + +To check if the LiNGAM assumption is broken, we can get p-values of +independence between error variables. The value in the i-th row and j-th +column of the obtained matrix shows the p-value of the independence of +the error variables :math:`e_i` and :math:`e_j`. + +.. code-block:: python + + p_values = model.get_error_independence_p_values() + print(p_values) + + +.. parsed-literal:: + + [[0. 0.517 0.793 0.004 0.001] + [0.517 0. 0.09 0.312 0.071] + [0.793 0.09 0. 0.058 0.075] + [0.004 0.312 0.058 0. 0.011] + [0.001 0.071 0.075 0.011 0. ]] + Bootstrap --------- @@ -386,262 +431,262 @@ Using the :func:`~lingam.BootstrapResult.get_causal_effects` method, we can get 0 + y4(t-1) y2(t) - y0(t) - -0.239746 + 0.377029 1.00 1 - y2(t-1) - y4(t) - -0.400593 + y2(t) + y3(t) + -0.238642 1.00 2 - y1(t-1) - y4(t) - 0.260280 + y1(t) + y3(t) + -0.213468 1.00 3 - y0(t-1) - y4(t) - -0.562191 + y0(t) + y3(t) + 0.563522 1.00 4 - y0(t) + y3(t-1) y4(t) - 0.114686 + 0.343541 1.00 5 - y4(t-1) - y3(t) - -0.182899 + y0(t-1) + y2(t) + -0.254723 1.00 6 - y0(t-1) - y3(t) - 0.251303 + y4(t-1) + y1(t) + 0.438051 1.00 7 - y2(t) - y3(t) - -0.260720 + y3(t-1) + y1(t) + 0.266735 1.00 8 + y1(t-1) y1(t) - y3(t) - -0.212046 + 0.312631 1.00 9 - y0(t) - y3(t) - 0.647221 + y0(t-1) + y4(t) + -0.531720 1.00 10 - y3(t-1) + y1(t-1) y4(t) - 0.333874 + 0.226082 1.00 11 - y3(t-1) y2(t) - 0.282825 + y1(t) + 0.231064 1.00 12 - y1(t-1) - y2(t) - 0.378391 + y0(t) + y1(t) + -0.310366 1.00 13 - y0(t-1) - y2(t) - -0.306198 + y4(t-1) + y0(t) + 0.210816 1.00 14 - y4(t-1) - y2(t) - 0.421177 + y3(t-1) + y0(t) + 0.375119 1.00 15 - y3(t-1) - y1(t) - 0.314910 + y2(t-1) + y0(t) + -0.377158 1.00 16 - y0(t-1) - y0(t) - -0.227950 + y2(t-1) + y4(t) + -0.368007 1.00 17 - y2(t-1) - y0(t) - -0.385377 + y0(t-1) + y1(t) + -0.419723 1.00 18 - y3(t-1) - y0(t) - 0.441629 - 1.00 + y1(t-1) + y2(t) + 0.329416 + 0.99 19 - y4(t-1) + y0(t-1) y0(t) - 0.220811 - 1.00 + -0.188156 + 0.99 20 - y4(t-1) - y1(t) - 0.447219 - 1.00 + y1(t-1) + y3(t) + 0.120133 + 0.98 21 - y0(t) - y1(t) - -0.392861 - 1.00 + y0(t-1) + y3(t) + 0.217037 + 0.98 22 y4(t-1) - y4(t) - 0.295080 - 1.00 + y3(t) + -0.186410 + 0.97 23 + y3(t-1) y2(t) - y1(t) - 0.273604 - 1.00 + 0.184045 + 0.97 24 - y0(t-1) - y1(t) - -0.472803 - 1.00 + y4(t-1) + y4(t) + 0.287224 + 0.92 25 - y1(t-1) - y1(t) - 0.371311 - 1.00 + y2(t) + y0(t) + -0.147135 + 0.91 26 - y1(t-1) y3(t) - 0.115601 - 0.99 + y4(t) + 0.056672 + 0.73 27 - y2(t) - y4(t) - -0.103683 - 0.97 + y3(t-1) + y3(t) + -0.139039 + 0.63 28 - y3(t-1) - y3(t) - -0.156020 - 0.95 + y0(t) + y4(t) + 0.086335 + 0.46 29 y2(t-1) - y3(t) - -0.087312 - 0.93 + y1(t) + 0.081208 + 0.41 30 - y2(t-1) - y1(t) - 0.041698 - 0.88 + y1(t-1) + y0(t) + -0.040277 + 0.26 31 - y2(t-1) y2(t) - -0.013958 - 0.87 + y4(t) + -0.088182 + 0.20 32 - y1(t) - y4(t) - -0.047350 - 0.83 + y2(t-1) + y2(t) + -0.052064 + 0.19 33 - y1(t-1) - y0(t) - 0.026292 - 0.81 + y1(t) + y4(t) + -0.056033 + 0.05 34 - y3(t) y4(t) - 0.049731 - 0.70 + y3(t) + 0.057538 + 0.04 35 - y4(t) + y2(t-1) y3(t) - 0.006900 - 0.17 + -0.261473 + 0.02 36 y4(t) y1(t) - 0.008282 - 0.06 + 0.013746 + 0.01 @@ -710,38 +755,38 @@ We can easily perform sorting operations with pandas.DataFrame. - 9 + 3 y0(t) y3(t) - 0.647221 + 0.563522 1.0 - 20 + 6 y4(t-1) y1(t) - 0.447219 + 0.438051 1.0 - 18 - y3(t-1) - y0(t) - 0.441629 + 0 + y4(t-1) + y2(t) + 0.377029 1.0 14 - y4(t-1) - y2(t) - 0.421177 + y3(t-1) + y0(t) + 0.375119 1.0 - 12 - y1(t-1) - y2(t) - 0.378391 + 4 + y3(t-1) + y4(t) + 0.343541 1.0 @@ -751,7 +796,8 @@ We can easily perform sorting operations with pandas.DataFrame. -And with pandas.DataFrame, we can easily filter by keywords. The following code extracts the causal direction towards y2(t). +And with pandas.DataFrame, we can easily filter by keywords. The +following code extracts the causal direction towards y2(t). .. code-block:: python @@ -811,39 +857,39 @@ And with pandas.DataFrame, we can easily filter by keywords. The following code - 11 - y3(t-1) + 0 + y4(t-1) y2(t) - 0.282825 + 0.377029 1.00 - 12 - y1(t-1) + 5 + y0(t-1) y2(t) - 0.378391 + -0.254723 1.00 - 13 - y0(t-1) + 18 + y1(t-1) y2(t) - -0.306198 - 1.00 + 0.329416 + 0.99 - 14 - y4(t-1) + 23 + y3(t-1) y2(t) - 0.421177 - 1.00 + 0.184045 + 0.97 - 31 + 32 y2(t-1) y2(t) - -0.013958 - 0.87 + -0.052064 + 0.19 @@ -852,7 +898,9 @@ And with pandas.DataFrame, we can easily filter by keywords. The following code -Because it holds the raw data of the causal effect (the original data for calculating the median), it is possible to draw a histogram of the values of the causal effect, as shown below. +Because it holds the raw data of the causal effect (the original data +for calculating the median), it is possible to draw a histogram of the +values of the causal effect, as shown below. .. code-block:: python diff --git a/examples/BottomUpParceLiNGAM.ipynb b/examples/BottomUpParceLiNGAM.ipynb index 4cc785d..9473f03 100644 --- a/examples/BottomUpParceLiNGAM.ipynb +++ b/examples/BottomUpParceLiNGAM.ipynb @@ -29,7 +29,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['1.19.2', '1.1.2', '0.14.1', '1.5.0']\n" + "['1.16.2', '0.24.2', '0.11.1', '1.5.1']\n" ] } ], @@ -184,116 +184,102 @@ "\r\n", "\r\n", - "\r\n", - "\r\n", + "\r\n", "\r\n", "\r\n", - "\r\n", + "%3\r\n", + "\r\n", "\r\n", - "\r\n", - "x0\r\n", + "x0\r\n", "\r\n", "x0\r\n", "\r\n", "\r\n", - "\r\n", - "x1\r\n", + "x1\r\n", "\r\n", "x1\r\n", "\r\n", "\r\n", - "\r\n", - "x0->x1\r\n", - "\r\n", - "\r\n", + "x0->x1\r\n", + "\r\n", + "\r\n", "0.50\r\n", "\r\n", "\r\n", - "\r\n", - "x4\r\n", + "x4\r\n", "\r\n", "x4\r\n", "\r\n", "\r\n", - "\r\n", - "x0->x4\r\n", - "\r\n", - "\r\n", + "x0->x4\r\n", + "\r\n", + "\r\n", "0.50\r\n", "\r\n", "\r\n", - "\r\n", - "x5\r\n", + "x5\r\n", "\r\n", "x5\r\n", "\r\n", "\r\n", - "\r\n", - "x0->x5\r\n", - "\r\n", - "\r\n", + "x0->x5\r\n", + "\r\n", + "\r\n", "0.50\r\n", "\r\n", "\r\n", - "\r\n", - "x2\r\n", + "x2\r\n", "\r\n", "x2\r\n", "\r\n", "\r\n", - "\r\n", - "x2->x1\r\n", - "\r\n", - "\r\n", + "x2->x1\r\n", + "\r\n", + "\r\n", "0.50\r\n", "\r\n", "\r\n", - "\r\n", - "x2->x4\r\n", - "\r\n", - "\r\n", + "x2->x4\r\n", + "\r\n", + "\r\n", "-0.50\r\n", "\r\n", "\r\n", - "\r\n", - "x3\r\n", - "\r\n", - "x3\r\n", + "x3\r\n", + "\r\n", + "x3\r\n", "\r\n", "\r\n", - "\r\n", - "x3->x0\r\n", - "\r\n", - "\r\n", - "0.50\r\n", + "x3->x0\r\n", + "\r\n", + "\r\n", + "0.50\r\n", "\r\n", "\r\n", - "\r\n", - "x6\r\n", - "\r\n", - "x6\r\n", + "x6\r\n", + "\r\n", + "x6\r\n", "\r\n", "\r\n", - "\r\n", - "x6->x2\r\n", - "\r\n", - "\r\n", - "2.00\r\n", + "x6->x2\r\n", + "\r\n", + "\r\n", + "2.00\r\n", "\r\n", "\r\n", - "\r\n", - "x6->x3\r\n", - "\r\n", - "\r\n", - "2.00\r\n", + "x6->x3\r\n", + "\r\n", + "\r\n", + "2.00\r\n", "\r\n", "\r\n", "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 3, @@ -343,7 +329,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 4, @@ -453,103 +439,91 @@ "\r\n", "\r\n", - "\r\n", - "\r\n", - "\r\n", + "\r\n", + "\r\n", "\r\n", - "\r\n", + "%3\r\n", + "\r\n", "\r\n", - "\r\n", - "x0\r\n", - "\r\n", - "x0\r\n", + "x0\r\n", + "\r\n", + "x0\r\n", "\r\n", "\r\n", - "\r\n", - "x1\r\n", + "x1\r\n", "\r\n", "x1\r\n", "\r\n", "\r\n", - "\r\n", - "x0->x1\r\n", - "\r\n", - "\r\n", - "0.50\r\n", + "x0->x1\r\n", + "\r\n", + "\r\n", + "0.50\r\n", "\r\n", "\r\n", - "\r\n", - "x4\r\n", + "x4\r\n", "\r\n", "x4\r\n", "\r\n", "\r\n", - "\r\n", - "x0->x4\r\n", - "\r\n", - "\r\n", - "0.45\r\n", + "x0->x4\r\n", + "\r\n", + "\r\n", + "0.45\r\n", "\r\n", "\r\n", - "\r\n", - "x5\r\n", - "\r\n", - "x5\r\n", + "x5\r\n", + "\r\n", + "x5\r\n", "\r\n", "\r\n", - "\r\n", - "x0->x5\r\n", - "\r\n", - "\r\n", - "0.48\r\n", + "x0->x5\r\n", + "\r\n", + "\r\n", + "0.48\r\n", "\r\n", "\r\n", - "\r\n", - "x2\r\n", - "\r\n", - "x2\r\n", + "x2\r\n", + "\r\n", + "x2\r\n", "\r\n", "\r\n", - "\r\n", - "x2->x1\r\n", - "\r\n", - "\r\n", - "0.49\r\n", + "x2->x1\r\n", + "\r\n", + "\r\n", + "0.49\r\n", "\r\n", "\r\n", - "\r\n", - "x3\r\n", - "\r\n", - "x3\r\n", + "x3\r\n", + "\r\n", + "x3\r\n", "\r\n", "\r\n", - "\r\n", - "x2->x3\r\n", - "\r\n", - "\r\n", - "\r\n", + "x2->x3\r\n", + "\r\n", + "\r\n", + "\r\n", "\r\n", "\r\n", - "\r\n", - "x2->x4\r\n", - "\r\n", - "\r\n", - "-0.45\r\n", + "x2->x4\r\n", + "\r\n", + "\r\n", + "-0.45\r\n", "\r\n", "\r\n", - "\r\n", - "x3->x0\r\n", - "\r\n", - "\r\n", - "0.51\r\n", + "x3->x0\r\n", + "\r\n", + "\r\n", + "0.51\r\n", "\r\n", "\r\n", "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 7, @@ -561,6 +535,37 @@ "make_dot(model.adjacency_matrix_)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Independence between error variables\n", + "To check if the LiNGAM assumption is broken, we can get p-values of independence between error variables. The value in the i-th row and j-th column of the obtained matrix shows the p-value of the independence of the error variables $e_i$ and $e_j$." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0.491 nan nan 0.763 0.2 ]\n", + " [0.491 0. nan nan 0.473 0.684]\n", + " [ nan nan 0. nan nan nan]\n", + " [ nan nan nan 0. nan nan]\n", + " [0.763 0.473 nan nan 0. 0.427]\n", + " [0.2 0.684 nan nan 0.427 0. ]]\n" + ] + } + ], + "source": [ + "p_values = model.get_error_independence_p_values(X)\n", + "print(p_values)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -571,7 +576,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": { "scrolled": true }, @@ -594,7 +599,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -610,7 +615,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -642,7 +647,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -658,7 +663,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -689,7 +694,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -721,9 +726,19 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\AA005431\\OneDrive - SCREEN Holdings Co., Ltd\\code\\as\\lingam\\v1.5.1\\lingam\\bootstrap.py:305: RuntimeWarning: invalid value encountered in greater\n", + " min_causal_effect, 1, 0), axis=0, keepdims=True)[0]\n", + "C:\\Users\\AA005431\\OneDrive - SCREEN Holdings Co., Ltd\\code\\as\\lingam\\v1.5.1\\lingam\\bootstrap.py:315: RuntimeWarning: invalid value encountered in greater\n", + " idx = np.where(np.abs(self._total_effects[:, to, from_]) > 0)\n" + ] + }, { "data": { "text/html": [ @@ -754,111 +769,69 @@ " \n", "
\n", " 0\n", - " x1\n", - " x4\n", - " 0.045256\n", - " 0.14\n", - "
\n", - "
\n", - " 1\n", " x0\n", " x5\n", - " 0.517290\n", + " 0.515510\n", " 0.12\n", "
\n", "
\n", - " 2\n", + " 1\n", " x0\n", " x1\n", " 0.477885\n", " 0.11\n", "
\n", "
\n", - " 3\n", - " x4\n", - " x1\n", - " 0.044782\n", - " 0.11\n", - "
\n", - "
\n", - " 4\n", + " 2\n", " x0\n", " x4\n", " 0.494946\n", " 0.11\n", "
\n", "
\n", - " 5\n", - " x5\n", - " x1\n", - " 0.025297\n", - " 0.06\n", - "
\n", - "
\n", - " 6\n", - " x5\n", - " x4\n", - " -0.031346\n", - " 0.06\n", - "
\n", - "
\n", - " 7\n", + " 3\n", " x2\n", " x1\n", " 0.482657\n", " 0.02\n", "
\n", "
\n", - " 8\n", + " 4\n", " x2\n", " x4\n", " -0.490889\n", " 0.02\n", "
\n", "
\n", - " 9\n", + " 5\n", " x3\n", " x0\n", " 0.511008\n", " 0.01\n", "
\n", "
\n", - " 10\n", + " 6\n", " x3\n", " x1\n", " 0.653876\n", " 0.01\n", "
\n", "
\n", - " 11\n", - " x0\n", - " x2\n", - " -0.044259\n", - " 0.01\n", - "
\n", - "
\n", - " 12\n", + " 7\n", " x3\n", " x2\n", " 0.790837\n", " 0.01\n", "
\n", "
\n", - " 13\n", - " x5\n", - " x2\n", - " 0.054423\n", - " 0.01\n", - "
\n", - "
\n", - " 14\n", + " 8\n", " x3\n", " x4\n", " -0.126227\n", " 0.01\n", "
\n", "
\n", - " 15\n", + " 9\n", " x3\n", " x5\n", " 0.265528\n", @@ -869,26 +842,20 @@ "" ], "text/plain": [ - " from to effect probability\n", - "0 x1 x4 0.045256 0.14\n", - "1 x0 x5 0.517290 0.12\n", - "2 x0 x1 0.477885 0.11\n", - "3 x4 x1 0.044782 0.11\n", - "4 x0 x4 0.494946 0.11\n", - "5 x5 x1 0.025297 0.06\n", - "6 x5 x4 -0.031346 0.06\n", - "7 x2 x1 0.482657 0.02\n", - "8 x2 x4 -0.490889 0.02\n", - "9 x3 x0 0.511008 0.01\n", - "10 x3 x1 0.653876 0.01\n", - "11 x0 x2 -0.044259 0.01\n", - "12 x3 x2 0.790837 0.01\n", - "13 x5 x2 0.054423 0.01\n", - "14 x3 x4 -0.126227 0.01\n", - "15 x3 x5 0.265528 0.01" + " from to effect probability\n", + "0 x0 x5 0.515510 0.12\n", + "1 x0 x1 0.477885 0.11\n", + "2 x0 x4 0.494946 0.11\n", + "3 x2 x1 0.482657 0.02\n", + "4 x2 x4 -0.490889 0.02\n", + "5 x3 x0 0.511008 0.01\n", + "6 x3 x1 0.653876 0.01\n", + "7 x3 x2 0.790837 0.01\n", + "8 x3 x4 -0.126227 0.01\n", + "9 x3 x5 0.265528 0.01" ] }, - "execution_count": 14, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -913,7 +880,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -945,35 +912,35 @@ " \n", " \n", "
\n", - " 12\n", + " 7\n", " x3\n", " x2\n", " 0.790837\n", " 0.01\n", "
\n", "
\n", - " 10\n", + " 6\n", " x3\n", " x1\n", " 0.653876\n", " 0.01\n", "
\n", "
\n", - " 1\n", + " 0\n", " x0\n", " x5\n", - " 0.517290\n", + " 0.515510\n", " 0.12\n", "
\n", "
\n", - " 9\n", + " 5\n", " x3\n", " x0\n", " 0.511008\n", " 0.01\n", "
\n", "
\n", - " 4\n", + " 2\n", " x0\n", " x4\n", " 0.494946\n", @@ -984,15 +951,15 @@ "" ], "text/plain": [ - " from to effect probability\n", - "12 x3 x2 0.790837 0.01\n", - "10 x3 x1 0.653876 0.01\n", - "1 x0 x5 0.517290 0.12\n", - "9 x3 x0 0.511008 0.01\n", - "4 x0 x4 0.494946 0.11" + " from to effect probability\n", + "7 x3 x2 0.790837 0.01\n", + "6 x3 x1 0.653876 0.01\n", + "0 x0 x5 0.515510 0.12\n", + "5 x3 x0 0.511008 0.01\n", + "2 x0 x4 0.494946 0.11" ] }, - "execution_count": 15, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -1003,7 +970,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -1035,38 +1002,38 @@ " \n", " \n", "
\n", - " 9\n", + " 5\n", " x3\n", " x0\n", " 0.511008\n", " 0.01\n", "
\n", "
\n", - " 10\n", + " 6\n", " x3\n", " x1\n", " 0.653876\n", " 0.01\n", "
\n", "
\n", - " 11\n", - " x0\n", + " 7\n", + " x3\n", " x2\n", - " -0.044259\n", + " 0.790837\n", " 0.01\n", "
\n", "
\n", - " 12\n", + " 8\n", " x3\n", - " x2\n", - " 0.790837\n", + " x4\n", + " -0.126227\n", " 0.01\n", "
\n", "
\n", - " 13\n", + " 9\n", + " x3\n", " x5\n", - " x2\n", - " 0.054423\n", + " 0.265528\n", " 0.01\n", "
\n", "
\n", @@ -1074,15 +1041,15 @@ "" ], "text/plain": [ - " from to effect probability\n", - "9 x3 x0 0.511008 0.01\n", - "10 x3 x1 0.653876 0.01\n", - "11 x0 x2 -0.044259 0.01\n", - "12 x3 x2 0.790837 0.01\n", - "13 x5 x2 0.054423 0.01" + " from to effect probability\n", + "5 x3 x0 0.511008 0.01\n", + "6 x3 x1 0.653876 0.01\n", + "7 x3 x2 0.790837 0.01\n", + "8 x3 x4 -0.126227 0.01\n", + "9 x3 x5 0.265528 0.01" ] }, - "execution_count": 16, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -1100,7 +1067,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -1132,7 +1099,7 @@ " \n", " \n", "
\n", - " 2\n", + " 1\n", " x0\n", " x1\n", " 0.477885\n", @@ -1140,27 +1107,13 @@ "
\n", "
\n", " 3\n", - " x4\n", - " x1\n", - " 0.044782\n", - " 0.11\n", - "
\n", - "
\n", - " 5\n", - " x5\n", - " x1\n", - " 0.025297\n", - " 0.06\n", - "
\n", - "
\n", - " 7\n", " x2\n", " x1\n", " 0.482657\n", " 0.02\n", "
\n", "
\n", - " 10\n", + " 6\n", " x3\n", " x1\n", " 0.653876\n", @@ -1171,15 +1124,13 @@ "" ], "text/plain": [ - " from to effect probability\n", - "2 x0 x1 0.477885 0.11\n", - "3 x4 x1 0.044782 0.11\n", - "5 x5 x1 0.025297 0.06\n", - "7 x2 x1 0.482657 0.02\n", - "10 x3 x1 0.653876 0.01" + " from to effect probability\n", + "1 x0 x1 0.477885 0.11\n", + "3 x2 x1 0.482657 0.02\n", + "6 x3 x1 0.653876 0.01" ] }, - "execution_count": 17, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -1197,25 +1148,35 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\lib\\histograms.py:824: RuntimeWarning: invalid value encountered in greater_equal\n", + " keep = (tmp_a >= first_edge)\n", + "C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\lib\\histograms.py:825: RuntimeWarning: invalid value encountered in less_equal\n", + " keep &= (tmp_a <= last_edge)\n" + ] + }, { "data": { "text/plain": [ - "(array([88., 0., 0., 0., 0., 0., 0., 0., 0., 1.]),\n", - " array([0. , 0.051, 0.102, 0.153, 0.204, 0.256, 0.307, 0.358, 0.409,\n", - " 0.46 , 0.511]),\n", - " )" + "(array([74., 0., 0., 0., 0., 0., 0., 0., 0., 12.]),\n", + " array([0. , 0.052, 0.103, 0.155, 0.206, 0.258, 0.309, 0.361, 0.412,\n", + " 0.464, 0.516]),\n", + " )" ] }, - "execution_count": 18, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" }, { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXMAAAD7CAYAAACYLnSTAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAANvElEQVR4nO3df4yk9V3A8ffuHYXr3ZbCOpVDWqzB+6S2lusP+AdREygGGySNvaJgyPUHSDSISYnFlLZobGNbgYRg2oaWHMmpaUMjCAXbQIlADBW1HElLP2kMVuVWvazE3iE/7tj1j5nVzfWYeWbn1+5n3q/kEnbmGZ7vh5l738MzM8/NLC8vI0na2GYnvQBJ0uCMuSQVYMwlqQBjLkkFGHNJKmDzBPZ5PHAWsAC8PIH9S9JGtAnYDjwOvHj0nZOI+VnAIxPYryRVcC7w6NE3TiLmCwDPPvscS0v9f8Z9fn4bi4uHhr6o9Wqa5p2mWcF5KxvFrLOzM5x00lboNPRok4j5ywBLS8trivnKY6fJNM07TbOC81Y2wlmPeXraN0AlqQBjLkkFGHNJKsCYS1IBxlySCjDmklSAMZekAibxOfOBvHT4ZVqtuYns+4UXj3Dwh89PZN+S1M2Gi/mrjtvERR++eyL7vufGizk4kT1LUneeZpGkAoy5JBVgzCWpAGMuSQU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j4/aXbEXEVsJvO7gCNmNSV/AN0tyTuOnrzs373ryQl9dJP314jYh3wFTqnai4ZX2m1O2avEfGUiOjd6/bvgXPGVFvd+r2u27r3/ytwB3BaRHxlfOXVqt/r+oyIeG3P/S3g8Jhq+4UmNeS/CJwfEe3u+coLgX9cujMzfwA8HBHP6x56FfD58ZdZi2P2Wphj9hoRq4BbgRsz888zcyXvudHvdW0BeyJi6ZrDNlbu7qz9/rxelpkbMnMTnVXugcx8weP8XpOu3+v6EPD+iDgjIlrAG+n8q7QxExnyj7f5WUTcERHndoddDHwoIu4D1gAfaaba5anYaxEq9PqHdM5jXhQR93T/W5HXIvr1mpnzdHZtvS0ivgME8JfNVTw8f4Z/7nWdA15PZ7GSdP4yv6qxgnGDMkkq2kSu5CVJ9TDkJalghrwkFcyQl6SCGfKSVDBDXpIKZshLUsEMeUkq2P8BYNuyFYDIVngAAAAASUVORK5CYII=\n", "text/plain": [ "
" ] @@ -1232,8 +1193,8 @@ "sns.set()\n", "%matplotlib inline\n", "\n", - "from_index = 3 # index of x3\n", - "to_index = 0 # index of x0\n", + "from_index = 0 # index of x0\n", + "to_index = 5 # index of x5\n", "plt.hist(result.total_effects_[:, to_index, from_index])" ] }, @@ -1261,7 +1222,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.3" }, "toc": { "base_numbering": 1, diff --git a/examples/DirectLiNGAM.ipynb b/examples/DirectLiNGAM.ipynb index 31b76ba..a2247e9 100644 --- a/examples/DirectLiNGAM.ipynb +++ b/examples/DirectLiNGAM.ipynb @@ -29,7 +29,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['1.16.2', '0.24.2', '0.11.1', '1.3.1']\n" + "['1.16.2', '0.24.2', '0.11.1', '1.5.1']\n" ] } ], @@ -43,7 +43,7 @@ "print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__])\n", "\n", "np.set_printoptions(precision=3, suppress=True)\n", - "np.random.seed(0)" + "np.random.seed(100)" ] }, { @@ -96,60 +96,60 @@ " \n", "
\n", " 0\n", - " 2.394708\n", - " 15.312359\n", - " 3.685054\n", - " 0.548814\n", - " 15.780259\n", - " 9.948090\n", + " 1.657947\n", + " 12.090323\n", + " 3.519873\n", + " 0.543405\n", + " 10.182785\n", + " 7.401408\n", "
\n", "
\n", " 1\n", - " 2.325771\n", - " 16.145216\n", - " 4.332293\n", - " 0.715189\n", - " 14.335879\n", - " 9.514409\n", + " 1.217345\n", + " 7.607388\n", + " 1.693219\n", + " 0.278369\n", + " 8.758949\n", + " 4.912979\n", "
\n", "
\n", " 2\n", - " 2.197313\n", - " 15.848718\n", - " 4.539881\n", - " 0.602763\n", - " 14.027410\n", - " 9.266158\n", + " 2.226804\n", + " 13.483555\n", + " 3.201513\n", + " 0.424518\n", + " 15.398626\n", + " 9.098729\n", "
\n", "
\n", " 3\n", - " 1.672250\n", - " 13.200354\n", - " 3.675534\n", - " 0.544883\n", - " 10.421554\n", - " 6.771233\n", + " 2.756527\n", + " 20.654225\n", + " 6.037873\n", + " 0.844776\n", + " 16.795156\n", + " 11.147294\n", "
\n", "
\n", " 4\n", - " 1.282752\n", - " 11.337503\n", - " 3.486211\n", - " 0.423655\n", - " 7.533376\n", - " 5.368668\n", + " 0.319283\n", + " 3.340782\n", + " 0.727265\n", + " 0.004719\n", + " 2.343100\n", + " 2.037974\n", "
\n", "
\n", "\n", "" ], "text/plain": [ - " x0 x1 x2 x3 x4 x5\n", - "0 2.394708 15.312359 3.685054 0.548814 15.780259 9.948090\n", - "1 2.325771 16.145216 4.332293 0.715189 14.335879 9.514409\n", - "2 2.197313 15.848718 4.539881 0.602763 14.027410 9.266158\n", - "3 1.672250 13.200354 3.675534 0.544883 10.421554 6.771233\n", - "4 1.282752 11.337503 3.486211 0.423655 7.533376 5.368668" + " x0 x1 x2 x3 x4 x5\n", + "0 1.657947 12.090323 3.519873 0.543405 10.182785 7.401408\n", + "1 1.217345 7.607388 1.693219 0.278369 8.758949 4.912979\n", + "2 2.226804 13.483555 3.201513 0.424518 15.398626 9.098729\n", + "3 2.756527 20.654225 6.037873 0.844776 16.795156 11.147294\n", + "4 0.319283 3.340782 0.727265 0.004719 2.343100 2.037974" ] }, "execution_count": 2, @@ -158,12 +158,12 @@ } ], "source": [ - "x3 = np.random.uniform(size=10000)\n", - "x0 = 3.0*x3 + np.random.uniform(size=10000)\n", - "x2 = 6.0*x3 + np.random.uniform(size=10000)\n", - "x1 = 3.0*x0 + 2.0*x2 + np.random.uniform(size=10000)\n", - "x5 = 4.0*x0 + np.random.uniform(size=10000)\n", - "x4 = 8.0*x0 - 1.0*x2 + np.random.uniform(size=10000)\n", + "x3 = np.random.uniform(size=1000)\n", + "x0 = 3.0*x3 + np.random.uniform(size=1000)\n", + "x2 = 6.0*x3 + np.random.uniform(size=1000)\n", + "x1 = 3.0*x0 + 2.0*x2 + np.random.uniform(size=1000)\n", + "x5 = 4.0*x0 + np.random.uniform(size=1000)\n", + "x4 = 8.0*x0 - 1.0*x2 + np.random.uniform(size=1000)\n", "X = pd.DataFrame(np.array([x0, x1, x2, x3, x4, x5]).T ,columns=['x0', 'x1', 'x2', 'x3', 'x4', 'x5'])\n", "X.head()" ] @@ -268,7 +268,7 @@ "
\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 3, @@ -317,7 +317,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 4, @@ -350,7 +350,7 @@ { "data": { "text/plain": [ - "[3, 0, 2, 5, 1, 4]" + "[3, 0, 2, 1, 4, 5]" ] }, "execution_count": 5, @@ -387,12 +387,12 @@ { "data": { "text/plain": [ - "array([[ 0. , 0. , 0. , 3.006, 0. , 0. ],\n", - " [ 3.002, 0. , 1.996, 0. , 0. , 0. ],\n", - " [ 0. , 0. , 0. , 6.001, 0. , 0. ],\n", + "array([[ 0. , 0. , 0. , 2.994, 0. , 0. ],\n", + " [ 2.995, 0. , 1.993, 0. , 0. , 0. ],\n", + " [ 0. , 0. , 0. , 5.586, 0. , 0. ],\n", " [ 0. , 0. , 0. , 0. , 0. , 0. ],\n", - " [ 7.978, 0. , -0.988, 0. , 0. , 0. ],\n", - " [ 3.998, 0. , 0. , 0. , 0. , 0. ]])" + " [ 7.981, 0. , -0.996, 0. , 0. , 0. ],\n", + " [ 3.795, 0. , 0. , 0. , 0. , 0. ]])" ] }, "execution_count": 6, @@ -449,7 +449,7 @@ "x0->x1\r\n", "\r\n", "\r\n", - "3.00\r\n", + "2.99\r\n", "\r\n", "\r\n", "x4\r\n", @@ -471,7 +471,7 @@ "x0->x5\r\n", "\r\n", "\r\n", - "4.00\r\n", + "3.80\r\n", "\r\n", "\r\n", "x2\r\n", @@ -482,13 +482,13 @@ "x2->x1\r\n", "\r\n", "\r\n", - "2.00\r\n", + "1.99\r\n", "\r\n", "\r\n", "x2->x4\r\n", "\r\n", "\r\n", - "-0.99\r\n", + "-1.00\r\n", "\r\n", "\r\n", "x3\r\n", @@ -499,19 +499,19 @@ "x3->x0\r\n", "\r\n", "\r\n", - "3.01\r\n", + "2.99\r\n", "\r\n", "\r\n", "x3->x2\r\n", "\r\n", "\r\n", - "6.00\r\n", + "5.59\r\n", "\r\n", "\r\n", "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 7, @@ -523,6 +523,37 @@ "make_dot(model.adjacency_matrix_)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Independence between error variables\n", + "To check if the LiNGAM assumption is broken, we can get p-values of independence between error variables. The value in the i-th row and j-th column of the obtained matrix shows the p-value of the independence of the error variables $e_i$ and $e_j$." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0.925 0.443 0.978 0.834 0. ]\n", + " [0.925 0. 0.133 0.881 0.317 0.214]\n", + " [0.443 0.133 0. 0. 0.64 0.001]\n", + " [0.978 0.881 0. 0. 0.681 0. ]\n", + " [0.834 0.317 0.64 0.681 0. 0.742]\n", + " [0. 0.214 0.001 0. 0.742 0. ]]\n" + ] + } + ], + "source": [ + "p_values = model.get_error_independence_p_values(X)\n", + "print(p_values)" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/examples/LongitudinalLiNGAM.ipynb b/examples/LongitudinalLiNGAM.ipynb index ba5e828..7aeeb1b 100644 --- a/examples/LongitudinalLiNGAM.ipynb +++ b/examples/LongitudinalLiNGAM.ipynb @@ -24,7 +24,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['1.16.2', '0.24.2', '0.11.1', '1.3.1']\n" + "['1.16.2', '0.24.2', '0.11.1', '1.5.1']\n" ] } ], @@ -161,7 +161,7 @@ "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 3, @@ -264,7 +264,7 @@ "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 4, @@ -361,7 +361,7 @@ "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 5, @@ -597,6 +597,67 @@ " plt.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Independence between error variables\n", + "To check if the LiNGAM assumption is broken, we can get p-values of independence between error variables. The value in the i-th row and j-th column of the obtained matrix shows the p-value of the independence of the error variables $e_i$ and $e_j$." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "p_values_list = model.get_error_independence_p_values()" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0.167 0.107 0.534 0.313]\n", + " [0.167 0. 0.195 0.821 0.204]\n", + " [0.107 0.195 0. 0.005 0.105]\n", + " [0.534 0.821 0.005 0. 0.049]\n", + " [0.313 0.204 0.105 0.049 0. ]]\n" + ] + } + ], + "source": [ + "t = 1\n", + "print(p_values_list[t])" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0.723 0.596 0.579 0.564]\n", + " [0.723 0. 0.612 0.688 0.412]\n", + " [0.596 0.612 0. 0.267 0.636]\n", + " [0.579 0.688 0.267 0. 0.421]\n", + " [0.564 0.412 0.636 0.421 0. ]]\n" + ] + } + ], + "source": [ + "t = 2\n", + "print(p_values_list[2])" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -607,7 +668,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -625,7 +686,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -634,7 +695,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -664,7 +725,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -702,7 +763,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -711,7 +772,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -822,7 +883,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -940,7 +1001,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -968,7 +1029,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -1027,7 +1088,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -1062,343 +1123,273 @@ " 0\n", " x1(1)\n", " x0(1)\n", - " 0.338725\n", + " 0.269441\n", " 1.00\n", " \n", " \n", " 1\n", - " x0(1)\n", - " x2(2)\n", - " 0.222189\n", + " x0(2)\n", + " x4(2)\n", + " 0.119620\n", " 1.00\n", " \n", " \n", " 2\n", - " x1(1)\n", - " x2(2)\n", - " 0.334539\n", + " x4(1)\n", + " x4(2)\n", + " -0.109855\n", " 1.00\n", " \n", " \n", " 3\n", " x3(1)\n", - " x2(2)\n", - " 0.627104\n", + " x4(2)\n", + " 0.260481\n", " 1.00\n", " \n", " \n", " 4\n", - " x4(1)\n", - " x2(2)\n", - " -0.192083\n", + " x1(1)\n", + " x4(2)\n", + " 0.297682\n", " 1.00\n", " \n", " \n", " 5\n", - " x0(2)\n", " x2(2)\n", - " 0.231114\n", + " x3(2)\n", + " -0.394208\n", " 1.00\n", " \n", " \n", " 6\n", - " x0(1)\n", + " x4(1)\n", " x3(2)\n", - " 0.148424\n", + " -0.152984\n", " 1.00\n", " \n", " \n", " 7\n", - " x1(1)\n", + " x3(1)\n", " x3(2)\n", - " -0.288648\n", + " -0.284373\n", " 1.00\n", " \n", " \n", " 8\n", " x2(1)\n", " x3(2)\n", - " 0.464517\n", + " 0.425542\n", " 1.00\n", " \n", " \n", " 9\n", - " x2(2)\n", - " x1(2)\n", - " -0.684859\n", + " x1(1)\n", + " x3(2)\n", + " -0.263069\n", " 1.00\n", " \n", " \n", " 10\n", - " x3(1)\n", - " x3(2)\n", - " -0.335765\n", + " x0(2)\n", + " x2(2)\n", + " 0.177046\n", " 1.00\n", " \n", " \n", " 11\n", - " x0(2)\n", - " x3(2)\n", - " -0.126437\n", + " x4(1)\n", + " x2(2)\n", + " -0.110188\n", " 1.00\n", " \n", " \n", " 12\n", + " x3(1)\n", " x2(2)\n", - " x3(2)\n", - " -0.401410\n", + " 0.524608\n", " 1.00\n", " \n", " \n", " 13\n", - " x0(1)\n", - " x4(2)\n", - " -0.110202\n", + " x1(1)\n", + " x2(2)\n", + " 0.329232\n", " 1.00\n", " \n", " \n", " 14\n", - " x1(1)\n", " x4(2)\n", - " 0.419646\n", + " x1(2)\n", + " 0.113916\n", " 1.00\n", " \n", " \n", " 15\n", - " x2(1)\n", - " x4(2)\n", - " -0.075903\n", + " x2(2)\n", + " x1(2)\n", + " -0.429614\n", " 1.00\n", " \n", " \n", " 16\n", - " x3(1)\n", - " x4(2)\n", - " 0.316278\n", + " x0(1)\n", + " x2(2)\n", + " 0.202225\n", " 1.00\n", " \n", " \n", " 17\n", - " x4(1)\n", - " x4(2)\n", - " -0.210909\n", + " x1(1)\n", + " x0(2)\n", + " 0.154852\n", " 1.00\n", " \n", " \n", " 18\n", - " x0(2)\n", - " x4(2)\n", - " 0.250131\n", + " x1(1)\n", + " x1(2)\n", + " -0.145485\n", " 1.00\n", " \n", " \n", " 19\n", - " x4(1)\n", - " x3(2)\n", - " -0.315993\n", + " x3(1)\n", + " x0(1)\n", + " 0.116298\n", " 1.00\n", " \n", " \n", " 20\n", - " x0(2)\n", + " x0(1)\n", " x1(2)\n", - " -0.014613\n", + " -0.462228\n", " 1.00\n", " \n", " \n", " 21\n", - " x4(2)\n", - " x1(2)\n", - " 0.457002\n", + " x4(1)\n", + " x0(1)\n", + " -0.562721\n", " 1.00\n", " \n", " \n", " 22\n", " x3(1)\n", - " x1(2)\n", - " -0.107434\n", + " x0(2)\n", + " -0.238794\n", " 1.00\n", " \n", " \n", " 23\n", " x3(1)\n", - " x0(1)\n", - " 0.116298\n", + " x1(1)\n", + " 0.317693\n", " 1.00\n", " \n", " \n", " 24\n", " x4(1)\n", - " x0(1)\n", - " -0.562715\n", + " x1(2)\n", + " 0.222208\n", " 1.00\n", " \n", " \n", " 25\n", - " x3(1)\n", " x1(1)\n", - " 0.397728\n", + " x2(1)\n", + " 0.187445\n", " 1.00\n", " \n", " \n", " 26\n", " x1(1)\n", - " x2(1)\n", - " 0.384131\n", + " x4(1)\n", + " -0.280015\n", " 1.00\n", " \n", " \n", " 27\n", - " x1(1)\n", - " x4(1)\n", - " -0.379965\n", - " 1.00\n", + " x4(2)\n", + " x3(2)\n", + " -0.059277\n", + " 0.92\n", " \n", " \n", " 28\n", " x4(1)\n", - " x1(2)\n", - " 0.276994\n", - " 1.00\n", + " x0(2)\n", + " -0.139972\n", + " 0.91\n", " \n", " \n", " 29\n", - " x0(1)\n", - " x0(2)\n", - " 0.195237\n", - " 1.00\n", + " x4(2)\n", + " x2(2)\n", + " 0.033740\n", + " 0.69\n", " \n", " \n", " 30\n", - " x1(1)\n", - " x0(2)\n", - " 0.289916\n", - " 1.00\n", + " x4(1)\n", + " x2(1)\n", + " -0.050954\n", + " 0.54\n", " \n", " \n", " 31\n", " x2(1)\n", - " x0(2)\n", - " 0.035207\n", - " 1.00\n", - " \n", - " \n", - " 32\n", - " x3(1)\n", " x4(1)\n", - " -0.028890\n", - " 1.00\n", - " \n", - " \n", - " 33\n", - " x3(1)\n", - " x0(2)\n", - " -0.318041\n", - " 1.00\n", + " -0.102010\n", + " 0.46\n", " \n", " \n", - " 34\n", - " x4(1)\n", + " 32\n", + " x2(1)\n", " x0(2)\n", - " -0.257058\n", - " 1.00\n", - " \n", - " \n", - " 35\n", - " x0(1)\n", - " x1(2)\n", - " -0.575730\n", - " 1.00\n", + " 0.034217\n", + " 0.35\n", " \n", " \n", - " 36\n", - " x1(1)\n", - " x1(2)\n", - " -0.153895\n", - " 1.00\n", - " \n", - " \n", - " 37\n", + " 33\n", " x2(1)\n", " x1(2)\n", - " 0.196489\n", - " 1.00\n", + " 0.161172\n", + " 0.34\n", " \n", " \n", - " 38\n", - " x2(1)\n", + " 34\n", " x2(2)\n", - " -0.062109\n", - " 0.99\n", - " \n", - " \n", - " 39\n", - " x4(2)\n", - " x3(2)\n", - " -0.070714\n", - " 0.92\n", - " \n", - " \n", - " 40\n", " x4(2)\n", - " x2(2)\n", - " 0.033930\n", - " 0.69\n", + " 0.029630\n", + " 0.31\n", " \n", " \n", - " 41\n", + " 35\n", + " x0(1)\n", " x3(2)\n", - " x1(2)\n", - " -0.063276\n", - " 0.63\n", + " 0.106614\n", + " 0.19\n", " \n", " \n", - " 42\n", - " x2(1)\n", + " 36\n", " x0(1)\n", - " -0.011222\n", - " 0.58\n", - " \n", - " \n", - " 43\n", - " x4(1)\n", - " x2(1)\n", - " -0.121987\n", - " 0.54\n", + " x0(2)\n", + " 0.136141\n", + " 0.15\n", " \n", " \n", - " 44\n", + " 37\n", " x2(1)\n", - " x4(1)\n", - " -0.108512\n", - " 0.46\n", - " \n", - " \n", - " 45\n", - " x1(2)\n", - " x3(2)\n", - " -0.030521\n", - " 0.37\n", - " \n", - " \n", - " 46\n", " x2(2)\n", - " x4(2)\n", - " 0.035184\n", - " 0.31\n", + " -0.089162\n", + " 0.12\n", " \n", " \n", - " 47\n", - " x0(1)\n", - " x2(1)\n", - " -0.071555\n", - " 0.10\n", - " \n", - " \n", - " 48\n", + " 38\n", " x3(2)\n", " x4(2)\n", - " -0.066850\n", + " -0.081235\n", " 0.08\n", " \n", " \n", @@ -1407,58 +1398,48 @@ ], "text/plain": [ " from to effect probability\n", - "0 x1(1) x0(1) 0.338725 1.00\n", - "1 x0(1) x2(2) 0.222189 1.00\n", - "2 x1(1) x2(2) 0.334539 1.00\n", - "3 x3(1) x2(2) 0.627104 1.00\n", - "4 x4(1) x2(2) -0.192083 1.00\n", - "5 x0(2) x2(2) 0.231114 1.00\n", - "6 x0(1) x3(2) 0.148424 1.00\n", - "7 x1(1) x3(2) -0.288648 1.00\n", - "8 x2(1) x3(2) 0.464517 1.00\n", - "9 x2(2) x1(2) -0.684859 1.00\n", - "10 x3(1) x3(2) -0.335765 1.00\n", - "11 x0(2) x3(2) -0.126437 1.00\n", - "12 x2(2) x3(2) -0.401410 1.00\n", - "13 x0(1) x4(2) -0.110202 1.00\n", - "14 x1(1) x4(2) 0.419646 1.00\n", - "15 x2(1) x4(2) -0.075903 1.00\n", - "16 x3(1) x4(2) 0.316278 1.00\n", - "17 x4(1) x4(2) -0.210909 1.00\n", - "18 x0(2) x4(2) 0.250131 1.00\n", - "19 x4(1) x3(2) -0.315993 1.00\n", - "20 x0(2) x1(2) -0.014613 1.00\n", - "21 x4(2) x1(2) 0.457002 1.00\n", - "22 x3(1) x1(2) -0.107434 1.00\n", - "23 x3(1) x0(1) 0.116298 1.00\n", - "24 x4(1) x0(1) -0.562715 1.00\n", - "25 x3(1) x1(1) 0.397728 1.00\n", - "26 x1(1) x2(1) 0.384131 1.00\n", - "27 x1(1) x4(1) -0.379965 1.00\n", - "28 x4(1) x1(2) 0.276994 1.00\n", - "29 x0(1) x0(2) 0.195237 1.00\n", - "30 x1(1) x0(2) 0.289916 1.00\n", - "31 x2(1) x0(2) 0.035207 1.00\n", - "32 x3(1) x4(1) -0.028890 1.00\n", - "33 x3(1) x0(2) -0.318041 1.00\n", - "34 x4(1) x0(2) -0.257058 1.00\n", - "35 x0(1) x1(2) -0.575730 1.00\n", - "36 x1(1) x1(2) -0.153895 1.00\n", - "37 x2(1) x1(2) 0.196489 1.00\n", - "38 x2(1) x2(2) -0.062109 0.99\n", - "39 x4(2) x3(2) -0.070714 0.92\n", - "40 x4(2) x2(2) 0.033930 0.69\n", - "41 x3(2) x1(2) -0.063276 0.63\n", - "42 x2(1) x0(1) -0.011222 0.58\n", - "43 x4(1) x2(1) -0.121987 0.54\n", - "44 x2(1) x4(1) -0.108512 0.46\n", - "45 x1(2) x3(2) -0.030521 0.37\n", - "46 x2(2) x4(2) 0.035184 0.31\n", - "47 x0(1) x2(1) -0.071555 0.10\n", - "48 x3(2) x4(2) -0.066850 0.08" + "0 x1(1) x0(1) 0.269441 1.00\n", + "1 x0(2) x4(2) 0.119620 1.00\n", + "2 x4(1) x4(2) -0.109855 1.00\n", + "3 x3(1) x4(2) 0.260481 1.00\n", + "4 x1(1) x4(2) 0.297682 1.00\n", + "5 x2(2) x3(2) -0.394208 1.00\n", + "6 x4(1) x3(2) -0.152984 1.00\n", + "7 x3(1) x3(2) -0.284373 1.00\n", + "8 x2(1) x3(2) 0.425542 1.00\n", + "9 x1(1) x3(2) -0.263069 1.00\n", + "10 x0(2) x2(2) 0.177046 1.00\n", + "11 x4(1) x2(2) -0.110188 1.00\n", + "12 x3(1) x2(2) 0.524608 1.00\n", + "13 x1(1) x2(2) 0.329232 1.00\n", + "14 x4(2) x1(2) 0.113916 1.00\n", + "15 x2(2) x1(2) -0.429614 1.00\n", + "16 x0(1) x2(2) 0.202225 1.00\n", + "17 x1(1) x0(2) 0.154852 1.00\n", + "18 x1(1) x1(2) -0.145485 1.00\n", + "19 x3(1) x0(1) 0.116298 1.00\n", + "20 x0(1) x1(2) -0.462228 1.00\n", + "21 x4(1) x0(1) -0.562721 1.00\n", + "22 x3(1) x0(2) -0.238794 1.00\n", + "23 x3(1) x1(1) 0.317693 1.00\n", + "24 x4(1) x1(2) 0.222208 1.00\n", + "25 x1(1) x2(1) 0.187445 1.00\n", + "26 x1(1) x4(1) -0.280015 1.00\n", + "27 x4(2) x3(2) -0.059277 0.92\n", + "28 x4(1) x0(2) -0.139972 0.91\n", + "29 x4(2) x2(2) 0.033740 0.69\n", + "30 x4(1) x2(1) -0.050954 0.54\n", + "31 x2(1) x4(1) -0.102010 0.46\n", + "32 x2(1) x0(2) 0.034217 0.35\n", + "33 x2(1) x1(2) 0.161172 0.34\n", + "34 x2(2) x4(2) 0.029630 0.31\n", + "35 x0(1) x3(2) 0.106614 0.19\n", + "36 x0(1) x0(2) 0.136141 0.15\n", + "37 x2(1) x2(2) -0.089162 0.12\n", + "38 x3(2) x4(2) -0.081235 0.08" ] }, - "execution_count": 20, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -1483,7 +1464,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -1515,38 +1496,38 @@ " \n", " \n", " \n", - " 3\n", + " 12\n", " x3(1)\n", " x2(2)\n", - " 0.627104\n", + " 0.524608\n", " 1.0\n", " \n", " \n", " 8\n", " x2(1)\n", " x3(2)\n", - " 0.464517\n", + " 0.425542\n", " 1.0\n", " \n", " \n", - " 21\n", - " x4(2)\n", - " x1(2)\n", - " 0.457002\n", + " 13\n", + " x1(1)\n", + " x2(2)\n", + " 0.329232\n", " 1.0\n", " \n", " \n", - " 14\n", + " 23\n", + " x3(1)\n", " x1(1)\n", - " x4(2)\n", - " 0.419646\n", + " 0.317693\n", " 1.0\n", " \n", " \n", - " 25\n", - " x3(1)\n", + " 4\n", " x1(1)\n", - " 0.397728\n", + " x4(2)\n", + " 0.297682\n", " 1.0\n", " \n", " \n", @@ -1555,14 +1536,14 @@ ], "text/plain": [ " from to effect probability\n", - "3 x3(1) x2(2) 0.627104 1.0\n", - "8 x2(1) x3(2) 0.464517 1.0\n", - "21 x4(2) x1(2) 0.457002 1.0\n", - "14 x1(1) x4(2) 0.419646 1.0\n", - "25 x3(1) x1(1) 0.397728 1.0" + "12 x3(1) x2(2) 0.524608 1.0\n", + "8 x2(1) x3(2) 0.425542 1.0\n", + "13 x1(1) x2(2) 0.329232 1.0\n", + "23 x3(1) x1(1) 0.317693 1.0\n", + "4 x1(1) x4(2) 0.297682 1.0" ] }, - "execution_count": 21, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -1580,7 +1561,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -1612,39 +1593,39 @@ " \n", " \n", " \n", - " 29\n", - " x0(1)\n", + " 17\n", + " x1(1)\n", " x0(2)\n", - " 0.195237\n", - " 1.0\n", + " 0.154852\n", + " 1.00\n", " \n", " \n", - " 30\n", - " x1(1)\n", + " 22\n", + " x3(1)\n", " x0(2)\n", - " 0.289916\n", - " 1.0\n", + " -0.238794\n", + " 1.00\n", " \n", " \n", - " 31\n", - " x2(1)\n", + " 28\n", + " x4(1)\n", " x0(2)\n", - " 0.035207\n", - " 1.0\n", + " -0.139972\n", + " 0.91\n", " \n", " \n", - " 33\n", - " x3(1)\n", + " 32\n", + " x2(1)\n", " x0(2)\n", - " -0.318041\n", - " 1.0\n", + " 0.034217\n", + " 0.35\n", " \n", " \n", - " 34\n", - " x4(1)\n", + " 36\n", + " x0(1)\n", " x0(2)\n", - " -0.257058\n", - " 1.0\n", + " 0.136141\n", + " 0.15\n", " \n", " \n", "\n", @@ -1652,14 +1633,14 @@ ], "text/plain": [ " from to effect probability\n", - "29 x0(1) x0(2) 0.195237 1.0\n", - "30 x1(1) x0(2) 0.289916 1.0\n", - "31 x2(1) x0(2) 0.035207 1.0\n", - "33 x3(1) x0(2) -0.318041 1.0\n", - "34 x4(1) x0(2) -0.257058 1.0" + "17 x1(1) x0(2) 0.154852 1.00\n", + "22 x3(1) x0(2) -0.238794 1.00\n", + "28 x4(1) x0(2) -0.139972 0.91\n", + "32 x2(1) x0(2) 0.034217 0.35\n", + "36 x0(1) x0(2) 0.136141 0.15" ] }, - "execution_count": 22, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -1677,25 +1658,25 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(array([ 9., 0., 4., 44., 0., 0., 0., 0., 0., 43.]),\n", - " array([0.196, 0.205, 0.213, 0.222, 0.23 , 0.239, 0.247, 0.255, 0.264,\n", - " 0.272, 0.281]),\n", + "(array([ 9., 6., 0., 4., 38., 0., 0., 0., 0., 43.]),\n", + " array([0.139, 0.152, 0.165, 0.178, 0.192, 0.205, 0.218, 0.231, 0.245,\n", + " 0.258, 0.271]),\n", "
)" ] }, - "execution_count": 23, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" }, { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAEBCAYAAACdctWRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAADllJREFUeJzt3X+MZfVZx/H3DEt3t+xspcuQXUp/RJEH1LgQXYwBNCqaoMX9wyIpjZaaLSEptX+gptq1hWqbVIU2bVolQQRdqxiwxRXwD6mxENLa1lISkSfYbFXcaVxXDLsUkGXGP84dnSDM3Hvuvefe+/B+/TX33nPm++wz537ud77nzNm5lZUVJEk1zU+6AEnS+Bj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fXLTo7M+8ByMy72/ueNoiQJ7Bm7vaNswdp/Rd8d/vp/wJeGRHL63JvO36/AWuam4jYBPwdrQLalZnPDTztC5rmHvvr8iVyj/q67Itxna5ptPhZZt5K6044ABGx1L5BNSxNc38jIp6MiEsy837gUuCrg436Ik0Xm/tv4EhEXJSZD7bf+XEoMw8OMOtKq+Zul/g+4DOZ+SfLz2fmcxHxIHA5rQv3N4D7h5S5ce62vcC/Addm5jD/9wHNz/dYX5er5B71ddkXY1nymfmtiFhe/Oxk4NbM/HJE3Ae8OzMfGW3CE+sx9xuBWyLiRuBp4KrBJ25pmjszlyLijcBH2nOZh2hdQGORG3gN8OPA+ohYvtH2SGbuBn4LuCMi9tCad33zuOcGPgrsAh4D/qk9t30gM39pnHO3z/fI9Jh7ZNdlv7hAmSQVNq5z8pKkPrDkJakwS16SCrPkJakwS16SCrPkJakwS16SCrPkJamw/wNdWe6OrvF5DQAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] diff --git a/examples/MultiGroupDirectLiNGAM.ipynb b/examples/MultiGroupDirectLiNGAM.ipynb index a7b072f..b9c1acc 100644 --- a/examples/MultiGroupDirectLiNGAM.ipynb +++ b/examples/MultiGroupDirectLiNGAM.ipynb @@ -29,7 +29,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['1.16.2', '0.24.2', '0.11.1', '1.3.1']\n" + "['1.16.2', '0.24.2', '0.11.1', '1.5.1']\n" ] } ], @@ -96,48 +96,48 @@ " \n", " \n", " 0\n", - " 2.394708\n", - " 15.312359\n", - " 3.685054\n", + " 2.239321\n", + " 15.340724\n", + " 4.104399\n", " 0.548814\n", - " 15.780259\n", - " 9.948090\n", + " 14.176947\n", + " 9.249925\n", " \n", " \n", " 1\n", - " 2.325771\n", - " 16.145216\n", - " 4.332293\n", + " 2.155632\n", + " 16.630954\n", + " 4.767220\n", " 0.715189\n", - " 14.335879\n", - " 9.514409\n", + " 12.775458\n", + " 9.189045\n", " \n", " \n", " 2\n", - " 2.197313\n", - " 15.848718\n", - " 4.539881\n", + " 2.284116\n", + " 15.910406\n", + " 4.139736\n", " 0.602763\n", - " 14.027410\n", - " 9.266158\n", + " 14.201794\n", + " 9.273880\n", " \n", " \n", " 3\n", - " 1.672250\n", - " 13.200354\n", - " 3.675534\n", + " 2.343420\n", + " 14.921457\n", + " 3.519820\n", " 0.544883\n", - " 10.421554\n", - " 6.771233\n", + " 15.580067\n", + " 9.723392\n", " \n", " \n", " 4\n", - " 1.282752\n", - " 11.337503\n", - " 3.486211\n", + " 1.314940\n", + " 11.055176\n", + " 3.146972\n", " 0.423655\n", - " 7.533376\n", - " 5.368668\n", + " 7.604743\n", + " 5.312976\n", " \n", " \n", "\n", @@ -145,11 +145,11 @@ ], "text/plain": [ " x0 x1 x2 x3 x4 x5\n", - "0 2.394708 15.312359 3.685054 0.548814 15.780259 9.948090\n", - "1 2.325771 16.145216 4.332293 0.715189 14.335879 9.514409\n", - "2 2.197313 15.848718 4.539881 0.602763 14.027410 9.266158\n", - "3 1.672250 13.200354 3.675534 0.544883 10.421554 6.771233\n", - "4 1.282752 11.337503 3.486211 0.423655 7.533376 5.368668" + "0 2.239321 15.340724 4.104399 0.548814 14.176947 9.249925\n", + "1 2.155632 16.630954 4.767220 0.715189 12.775458 9.189045\n", + "2 2.284116 15.910406 4.139736 0.602763 14.201794 9.273880\n", + "3 2.343420 14.921457 3.519820 0.544883 15.580067 9.723392\n", + "4 1.314940 11.055176 3.146972 0.423655 7.604743 5.312976" ] }, "execution_count": 2, @@ -158,12 +158,12 @@ } ], "source": [ - "x3 = np.random.uniform(size=10000)\n", - "x0 = 3.0*x3 + np.random.uniform(size=10000)\n", - "x2 = 6.0*x3 + np.random.uniform(size=10000)\n", - "x1 = 3.0*x0 + 2.0*x2 + np.random.uniform(size=10000)\n", - "x5 = 4.0*x0 + np.random.uniform(size=10000)\n", - "x4 = 8.0*x0 - 1.0*x2 + np.random.uniform(size=10000)\n", + "x3 = np.random.uniform(size=1000)\n", + "x0 = 3.0*x3 + np.random.uniform(size=1000)\n", + "x2 = 6.0*x3 + np.random.uniform(size=1000)\n", + "x1 = 3.0*x0 + 2.0*x2 + np.random.uniform(size=1000)\n", + "x5 = 4.0*x0 + np.random.uniform(size=1000)\n", + "x4 = 8.0*x0 - 1.0*x2 + np.random.uniform(size=1000)\n", "X1 = pd.DataFrame(np.array([x0, x1, x2, x3, x4, x5]).T ,columns=['x0', 'x1', 'x2', 'x3', 'x4', 'x5'])\n", "X1.head()" ] @@ -268,7 +268,7 @@ "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 3, @@ -329,48 +329,48 @@ " \n", " \n", " 0\n", - " 3.848617\n", - " 29.790327\n", - " 6.151635\n", - " 0.927955\n", - " 23.683228\n", - " 17.497765\n", + " 1.913337\n", + " 14.568170\n", + " 2.893918\n", + " 0.374794\n", + " 12.115455\n", + " 9.358286\n", " \n", " \n", " 1\n", - " 3.765482\n", - " 28.839731\n", - " 5.981344\n", - " 0.902937\n", - " 23.362070\n", - " 17.126491\n", + " 2.013935\n", + " 15.857260\n", + " 3.163377\n", + " 0.428686\n", + " 12.657021\n", + " 9.242911\n", " \n", " \n", " 2\n", - " 1.613042\n", - " 13.637872\n", - " 2.930467\n", - " 0.427617\n", - " 9.871720\n", - " 7.578267\n", + " 3.172835\n", + " 24.734385\n", + " 5.142203\n", + " 0.683057\n", + " 19.605722\n", + " 14.666783\n", " \n", " \n", " 3\n", - " 1.838085\n", - " 16.640591\n", - " 3.715235\n", - " 0.510806\n", - " 10.427863\n", - " 9.068131\n", + " 2.990395\n", + " 20.878961\n", + " 4.113485\n", + " 0.600948\n", + " 19.452091\n", + " 13.494380\n", " \n", " \n", " 4\n", - " 2.321607\n", - " 19.614986\n", - " 4.540952\n", - " 0.583200\n", - " 13.276292\n", - " 11.184535\n", + " 0.248702\n", + " 2.268163\n", + " 0.532419\n", + " 0.070483\n", + " 1.854870\n", + " 1.130948\n", " \n", " \n", "\n", @@ -378,11 +378,11 @@ ], "text/plain": [ " x0 x1 x2 x3 x4 x5\n", - "0 3.848617 29.790327 6.151635 0.927955 23.683228 17.497765\n", - "1 3.765482 28.839731 5.981344 0.902937 23.362070 17.126491\n", - "2 1.613042 13.637872 2.930467 0.427617 9.871720 7.578267\n", - "3 1.838085 16.640591 3.715235 0.510806 10.427863 9.068131\n", - "4 2.321607 19.614986 4.540952 0.583200 13.276292 11.184535" + "0 1.913337 14.568170 2.893918 0.374794 12.115455 9.358286\n", + "1 2.013935 15.857260 3.163377 0.428686 12.657021 9.242911\n", + "2 3.172835 24.734385 5.142203 0.683057 19.605722 14.666783\n", + "3 2.990395 20.878961 4.113485 0.600948 19.452091 13.494380\n", + "4 0.248702 2.268163 0.532419 0.070483 1.854870 1.130948" ] }, "execution_count": 4, @@ -403,7 +403,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:43:52.431942Z", @@ -501,7 +501,7 @@ "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 5, @@ -529,7 +529,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:43:52.441916Z", @@ -551,7 +551,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:43:52.654349Z", @@ -562,7 +562,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 7, @@ -584,7 +584,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:43:52.665320Z", @@ -595,7 +595,7 @@ { "data": { "text/plain": [ - "[3, 2, 0, 1, 5, 4]" + "[3, 0, 5, 2, 1, 4]" ] }, "execution_count": 8, @@ -621,7 +621,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:43:52.963524Z", @@ -633,12 +633,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "[[ 0. 0. 0. 3.006 0. 0. ]\n", - " [ 3.002 0. 1.996 0. 0. 0. ]\n", - " [ 0. 0. 0. 6.001 0. 0. ]\n", - " [ 0. 0. 0. 0. 0. 0. ]\n", - " [ 7.978 0. -0.988 0. 0. 0. ]\n", - " [ 3.998 0. 0. 0. 0. 0. ]]\n" + "[[0. 0. 0. 3.006 0. 0. ]\n", + " [2.873 0. 1.969 0. 0. 0. ]\n", + " [0. 0. 0. 5.882 0. 0. ]\n", + " [0. 0. 0. 0. 0. 0. ]\n", + " [6.095 0. 0. 0. 0. 0. ]\n", + " [3.967 0. 0. 0. 0. 0. ]]\n" ] }, { @@ -650,26 +650,26 @@ "\r\n", "\r\n", - "\r\n", + "\r\n", "\r\n", "%3\r\n", - "\r\n", + "\r\n", "\r\n", "x0\r\n", - "\r\n", - "x0\r\n", + "\r\n", + "x0\r\n", "\r\n", "\r\n", "x1\r\n", - "\r\n", - "x1\r\n", + "\r\n", + "x1\r\n", "\r\n", "\r\n", "x0->x1\r\n", - "\r\n", - "\r\n", - "3.00\r\n", + "\r\n", + "\r\n", + "2.87\r\n", "\r\n", "\r\n", "x4\r\n", @@ -678,60 +678,54 @@ "\r\n", "\r\n", "x0->x4\r\n", - "\r\n", - "\r\n", - "7.98\r\n", + "\r\n", + "\r\n", + "6.09\r\n", "\r\n", "\r\n", "x5\r\n", - "\r\n", - "x5\r\n", + "\r\n", + "x5\r\n", "\r\n", "\r\n", - "x0->x5\r\n", - "\r\n", - "\r\n", - "4.00\r\n", + "x0->x5\r\n", + "\r\n", + "\r\n", + "3.97\r\n", "\r\n", "\r\n", "x2\r\n", - "\r\n", - "x2\r\n", + "\r\n", + "x2\r\n", "\r\n", "\r\n", "x2->x1\r\n", - "\r\n", - "\r\n", - "2.00\r\n", - "\r\n", - "\r\n", - "x2->x4\r\n", - "\r\n", - "\r\n", - "-0.99\r\n", + "\r\n", + "\r\n", + "1.97\r\n", "\r\n", "\r\n", "x3\r\n", - "\r\n", - "x3\r\n", + "\r\n", + "x3\r\n", "\r\n", "\r\n", "x3->x0\r\n", - "\r\n", - "\r\n", - "3.01\r\n", + "\r\n", + "\r\n", + "3.01\r\n", "\r\n", "\r\n", "x3->x2\r\n", - "\r\n", - "\r\n", - "6.00\r\n", + "\r\n", + "\r\n", + "5.88\r\n", "\r\n", "\r\n", "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 9, @@ -746,7 +740,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:43:53.234415Z", @@ -758,12 +752,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "[[ 0. 0. 0.043 3.245 0. 0. ]\n", - " [ 3.508 0. 2.491 0. 0. 0. ]\n", - " [ 0. 0. 0. 6.481 0. 0. ]\n", + "[[ 0. 0. 0. 3.483 0. 0. ]\n", + " [ 3.516 0. 2.466 0.165 0. 0. ]\n", + " [ 0. 0. 0. 6.383 0. 0. ]\n", " [ 0. 0. 0. 0. 0. 0. ]\n", - " [ 7.519 0. -0.942 0. 0. 0. ]\n", - " [ 4.422 0. 0. 0. 0. 0. ]]\n" + " [ 8.456 0. -1.471 0. 0. 0. ]\n", + " [ 4.446 0. 0. 0. 0. 0. ]]\n" ] }, { @@ -775,94 +769,94 @@ "\r\n", "\r\n", - "\r\n", - "\r\n", + "\r\n", + "\r\n", "%3\r\n", - "\r\n", + "\r\n", "\r\n", "x0\r\n", - "\r\n", - "x0\r\n", + "\r\n", + "x0\r\n", "\r\n", "\r\n", "x1\r\n", - "\r\n", - "x1\r\n", + "\r\n", + "x1\r\n", "\r\n", "\r\n", - "x0->x1\r\n", - "\r\n", - "\r\n", - "3.51\r\n", + "x0->x1\r\n", + "\r\n", + "\r\n", + "3.52\r\n", "\r\n", "\r\n", "x4\r\n", - "\r\n", - "x4\r\n", + "\r\n", + "x4\r\n", "\r\n", "\r\n", "x0->x4\r\n", - "\r\n", - "\r\n", - "7.52\r\n", + "\r\n", + "\r\n", + "8.46\r\n", "\r\n", "\r\n", "x5\r\n", - "\r\n", - "x5\r\n", + "\r\n", + "x5\r\n", "\r\n", "\r\n", "x0->x5\r\n", - "\r\n", - "\r\n", - "4.42\r\n", + "\r\n", + "\r\n", + "4.45\r\n", "\r\n", "\r\n", "x2\r\n", - "\r\n", - "x2\r\n", - "\r\n", - "\r\n", - "x2->x0\r\n", - "\r\n", - "\r\n", - "0.04\r\n", + "\r\n", + "x2\r\n", "\r\n", "\r\n", - "x2->x1\r\n", - "\r\n", - "\r\n", - "2.49\r\n", + "x2->x1\r\n", + "\r\n", + "\r\n", + "2.47\r\n", "\r\n", "\r\n", "x2->x4\r\n", - "\r\n", - "\r\n", - "-0.94\r\n", + "\r\n", + "\r\n", + "-1.47\r\n", "\r\n", "\r\n", "x3\r\n", - "\r\n", - "x3\r\n", + "\r\n", + "x3\r\n", "\r\n", "\r\n", - "x3->x0\r\n", - "\r\n", - "\r\n", - "3.25\r\n", + "x3->x0\r\n", + "\r\n", + "\r\n", + "3.48\r\n", + "\r\n", + "\r\n", + "x3->x1\r\n", + "\r\n", + "\r\n", + "0.17\r\n", "\r\n", "\r\n", "x3->x2\r\n", - "\r\n", - "\r\n", - "6.48\r\n", + "\r\n", + "\r\n", + "6.38\r\n", "\r\n", "\r\n", "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 10, @@ -884,7 +878,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:43:53.245385Z", @@ -896,7 +890,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "(11000, 6)\n" + "(2000, 6)\n" ] } ], @@ -907,7 +901,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:43:53.390217Z", @@ -918,7 +912,7 @@ { "data": { "text/plain": [ - "[3, 4, 5, 2, 1, 0]" + "[1, 5, 2, 3, 0, 4]" ] }, "execution_count": 12, @@ -942,7 +936,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:43:53.660358Z", @@ -959,130 +953,118 @@ "\r\n", "\r\n", - "\r\n", + "\r\n", "\r\n", "%3\r\n", - "\r\n", + "\r\n", "\r\n", "x0\r\n", - "\r\n", - "x0\r\n", + "\r\n", + "x0\r\n", + "\r\n", + "\r\n", + "x4\r\n", + "\r\n", + "x4\r\n", + "\r\n", + "\r\n", + "x0->x4\r\n", + "\r\n", + "\r\n", + "8.98\r\n", "\r\n", "\r\n", "x1\r\n", - "\r\n", - "x1\r\n", + "\r\n", + "x1\r\n", "\r\n", "\r\n", "x1->x0\r\n", - "\r\n", - "\r\n", - "0.01\r\n", + "\r\n", + "\r\n", + "-0.03\r\n", "\r\n", "\r\n", "x2\r\n", - "\r\n", - "x2\r\n", + "\r\n", + "x2\r\n", "\r\n", - "\r\n", - "x2->x0\r\n", - "\r\n", - "\r\n", - "0.07\r\n", - "\r\n", - "\r\n", - "x2->x1\r\n", - "\r\n", - "\r\n", - "1.66\r\n", + "\r\n", + "x1->x2\r\n", + "\r\n", + "\r\n", + "0.32\r\n", "\r\n", "\r\n", "x3\r\n", - "\r\n", - "x3\r\n", + "\r\n", + "x3\r\n", "\r\n", - "\r\n", - "x3->x0\r\n", - "\r\n", - "\r\n", - "0.06\r\n", + "\r\n", + "x1->x3\r\n", + "\r\n", + "\r\n", + "-0.02\r\n", "\r\n", - "\r\n", - "x3->x2\r\n", - "\r\n", - "\r\n", - "5.60\r\n", - "\r\n", - "\r\n", - "x4\r\n", - "\r\n", - "x4\r\n", - "\r\n", - "\r\n", - "x3->x4\r\n", - "\r\n", - "\r\n", - "18.26\r\n", + "\r\n", + "x1->x4\r\n", + "\r\n", + "\r\n", + "-0.25\r\n", "\r\n", "\r\n", "x5\r\n", - "\r\n", - "x5\r\n", - "\r\n", - "\r\n", - "x3->x5\r\n", - "\r\n", - "\r\n", - "2.84\r\n", - "\r\n", - "\r\n", - "x4->x0\r\n", - "\r\n", - "\r\n", - "0.10\r\n", - "\r\n", - "\r\n", - "x4->x1\r\n", - "\r\n", - "\r\n", - "-0.26\r\n", - "\r\n", - "\r\n", - "x4->x2\r\n", - "\r\n", - "\r\n", - "-0.12\r\n", - "\r\n", - "\r\n", - "x4->x5\r\n", - "\r\n", - "\r\n", - "0.52\r\n", + "\r\n", + "x5\r\n", "\r\n", - "\r\n", - "x5->x0\r\n", - "\r\n", - "\r\n", - "0.04\r\n", + "\r\n", + "x1->x5\r\n", + "\r\n", + "\r\n", + "0.56\r\n", "\r\n", - "\r\n", - "x5->x1\r\n", - "\r\n", - "\r\n", - "1.32\r\n", + "\r\n", + "x2->x3\r\n", + "\r\n", + "\r\n", + "0.19\r\n", + "\r\n", + "\r\n", + "x2->x4\r\n", + "\r\n", + "\r\n", + "-0.66\r\n", + "\r\n", + "\r\n", + "x3->x0\r\n", + "\r\n", + "\r\n", + "0.99\r\n", + "\r\n", + "\r\n", + "x5->x0\r\n", + "\r\n", + "\r\n", + "0.22\r\n", "\r\n", "\r\n", - "x5->x2\r\n", - "\r\n", - "\r\n", - "0.22\r\n", + "x5->x2\r\n", + "\r\n", + "\r\n", + "-0.17\r\n", + "\r\n", + "\r\n", + "x5->x3\r\n", + "\r\n", + "\r\n", + "0.03\r\n", "\r\n", "\r\n", "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 13, @@ -1094,6 +1076,59 @@ "make_dot(model_all.adjacency_matrix_)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Independence between error variables\n", + "To check if the LiNGAM assumption is broken, we can get p-values of independence between error variables. The value in the i-th row and j-th column of the obtained matrix shows the p-value of the independence of the error variables $e_i$ and $e_j$." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0.136 0.075 0.838 0. 0.832]\n", + " [0.136 0. 0.008 0. 0.544 0.403]\n", + " [0.075 0.008 0. 0.11 0. 0.511]\n", + " [0.838 0. 0.11 0. 0.039 0.049]\n", + " [0. 0.544 0. 0.039 0. 0.101]\n", + " [0.832 0.403 0.511 0.049 0.101 0. ]]\n" + ] + } + ], + "source": [ + "p_values = model.get_error_independence_p_values(X_list)\n", + "print(p_values[0])" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0.545 0.908 0.285 0.525 0.728]\n", + " [0.545 0. 0.84 0.814 0.086 0.297]\n", + " [0.908 0.84 0. 0.032 0.328 0.026]\n", + " [0.285 0.814 0.032 0. 0.904 0. ]\n", + " [0.525 0.086 0.328 0.904 0. 0.237]\n", + " [0.728 0.297 0.026 0. 0.237 0. ]]\n" + ] + } + ], + "source": [ + "print(p_values[1])" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1104,7 +1139,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:44:26.156834Z", @@ -1132,14 +1167,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:44:26.174050Z", "start_time": "2019-12-12T06:44:26.156834Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x0 <--- x3 (100.0%)\n", + "x1 <--- x0 (100.0%)\n", + "x1 <--- x2 (100.0%)\n", + "x2 <--- x3 (100.0%)\n", + "x4 <--- x0 (100.0%)\n", + "x5 <--- x0 (100.0%)\n", + "x4 <--- x2 (94.0%)\n", + "x4 <--- x5 (20.0%)\n" + ] + } + ], "source": [ "cdc = results[0].get_causal_direction_counts(n_directions=8, min_causal_effect=0.01)\n", "print_causal_directions(cdc, 100)" @@ -1147,14 +1197,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:44:26.194991Z", "start_time": "2019-12-12T06:44:26.181029Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x0 <--- x3 (100.0%)\n", + "x1 <--- x0 (100.0%)\n", + "x1 <--- x2 (100.0%)\n", + "x2 <--- x3 (100.0%)\n", + "x4 <--- x0 (100.0%)\n", + "x4 <--- x2 (100.0%)\n", + "x5 <--- x0 (100.0%)\n", + "x1 <--- x3 (72.0%)\n" + ] + } + ], "source": [ "cdc = results[1].get_causal_direction_counts(n_directions=8, min_causal_effect=0.01)\n", "print_causal_directions(cdc, 100)" @@ -1170,14 +1235,45 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:44:26.218929Z", "start_time": "2019-12-12T06:44:26.199979Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "DAG[0]: 61.0%\n", + "\tx0 <--- x3 \n", + "\tx1 <--- x0 \n", + "\tx1 <--- x2 \n", + "\tx2 <--- x3 \n", + "\tx4 <--- x0 \n", + "\tx4 <--- x2 \n", + "\tx5 <--- x0 \n", + "DAG[1]: 13.0%\n", + "\tx0 <--- x3 \n", + "\tx1 <--- x0 \n", + "\tx1 <--- x2 \n", + "\tx2 <--- x3 \n", + "\tx4 <--- x0 \n", + "\tx4 <--- x2 \n", + "\tx4 <--- x5 \n", + "\tx5 <--- x0 \n", + "DAG[2]: 6.0%\n", + "\tx0 <--- x3 \n", + "\tx1 <--- x0 \n", + "\tx1 <--- x2 \n", + "\tx2 <--- x3 \n", + "\tx4 <--- x0 \n", + "\tx5 <--- x0 \n" + ] + } + ], "source": [ "dagc = results[0].get_directed_acyclic_graph_counts(n_dags=3, min_causal_effect=0.01)\n", "print_dagc(dagc, 100)" @@ -1185,14 +1281,48 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": { "ExecuteTime": { "end_time": "2019-12-12T06:44:26.239872Z", "start_time": "2019-12-12T06:44:26.220922Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "DAG[0]: 59.0%\n", + "\tx0 <--- x3 \n", + "\tx1 <--- x0 \n", + "\tx1 <--- x2 \n", + "\tx1 <--- x3 \n", + "\tx2 <--- x3 \n", + "\tx4 <--- x0 \n", + "\tx4 <--- x2 \n", + "\tx5 <--- x0 \n", + "DAG[1]: 17.0%\n", + "\tx0 <--- x3 \n", + "\tx1 <--- x0 \n", + "\tx1 <--- x2 \n", + "\tx2 <--- x3 \n", + "\tx4 <--- x0 \n", + "\tx4 <--- x2 \n", + "\tx5 <--- x0 \n", + "DAG[2]: 10.0%\n", + "\tx0 <--- x2 \n", + "\tx0 <--- x3 \n", + "\tx1 <--- x0 \n", + "\tx1 <--- x2 \n", + "\tx1 <--- x3 \n", + "\tx2 <--- x3 \n", + "\tx4 <--- x0 \n", + "\tx4 <--- x2 \n", + "\tx5 <--- x0 \n" + ] + } + ], "source": [ "dagc = results[1].get_directed_acyclic_graph_counts(n_dags=3, min_causal_effect=0.01)\n", "print_dagc(dagc, 100)" @@ -1208,9 +1338,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0. 0.08 1. 0. 0. ]\n", + " [1. 0. 1. 0.08 0. 0.05]\n", + " [0. 0. 0. 1. 0. 0. ]\n", + " [0. 0. 0. 0. 0. 0. ]\n", + " [1. 0. 0.94 0. 0. 0.2 ]\n", + " [1. 0. 0. 0. 0.01 0. ]]\n" + ] + } + ], "source": [ "prob = results[0].get_probabilities(min_causal_effect=0.01)\n", "print(prob)" @@ -1227,9 +1370,178 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
fromtoeffectprobability
0x3x03.0056041.00
1x0x12.9902641.00
2x2x12.0911701.00
3x3x120.9375201.00
4x3x25.9694571.00
5x0x47.9924771.00
6x3x418.0587171.00
7x0x53.9702751.00
8x3x512.0282401.00
9x5x10.1480780.29
10x5x40.1045610.21
11x2x50.1525020.15
12x5x20.0783910.09
13x2x00.0358520.08
14x4x1-1.6231880.03
15x4x50.0271300.01
\n", + "
" + ], + "text/plain": [ + " from to effect probability\n", + "0 x3 x0 3.005604 1.00\n", + "1 x0 x1 2.990264 1.00\n", + "2 x2 x1 2.091170 1.00\n", + "3 x3 x1 20.937520 1.00\n", + "4 x3 x2 5.969457 1.00\n", + "5 x0 x4 7.992477 1.00\n", + "6 x3 x4 18.058717 1.00\n", + "7 x0 x5 3.970275 1.00\n", + "8 x3 x5 12.028240 1.00\n", + "9 x5 x1 0.148078 0.29\n", + "10 x5 x4 0.104561 0.21\n", + "11 x2 x5 0.152502 0.15\n", + "12 x5 x2 0.078391 0.09\n", + "13 x2 x0 0.035852 0.08\n", + "14 x4 x1 -1.623188 0.03\n", + "15 x4 x5 0.027130 0.01" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "causal_effects = results[0].get_causal_effects(min_causal_effect=0.01)\n", "df = pd.DataFrame(causal_effects)\n", @@ -1249,9 +1561,90 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
fromtoeffectprobability
3x3x120.9375201.0
6x3x418.0587171.0
8x3x512.0282401.0
5x0x47.9924771.0
4x3x25.9694571.0
\n", + "
" + ], + "text/plain": [ + " from to effect probability\n", + "3 x3 x1 20.937520 1.0\n", + "6 x3 x4 18.058717 1.0\n", + "8 x3 x5 12.028240 1.0\n", + "5 x0 x4 7.992477 1.0\n", + "4 x3 x2 5.969457 1.0" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "df.sort_values('effect', ascending=False).head()" ] @@ -1265,9 +1658,90 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
fromtoeffectprobability
1x0x12.9902641.00
2x2x12.0911701.00
3x3x120.9375201.00
9x5x10.1480780.29
14x4x1-1.6231880.03
\n", + "
" + ], + "text/plain": [ + " from to effect probability\n", + "1 x0 x1 2.990264 1.00\n", + "2 x2 x1 2.091170 1.00\n", + "3 x3 x1 20.937520 1.00\n", + "9 x5 x1 0.148078 0.29\n", + "14 x4 x1 -1.623188 0.03" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "df[df['to']=='x1'].head()" ] @@ -1281,9 +1755,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(array([ 4., 8., 10., 19., 16., 14., 14., 8., 6., 1.]),\n", + " array([2.941, 2.955, 2.969, 2.984, 2.998, 3.012, 3.026, 3.04 , 3.055,\n", + " 3.069, 3.083]),\n", + "
)" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEBCAYAAAB13qL/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAFfxJREFUeJzt3X+0XWV95/H3vSEJ0dwoK1zKL4GxypfWNYIYwI6gnWnqWrIIKZ0RHVkFF4YfS+h0hgirFdCqa6yjDbj8AXbAVEfqjw4ZjJFgdcAZsIKVKsIq+pVxhBGTsdeMbRJLft47f5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a6f8K8I+Z+RvAnwB3DGit0JoK+nBmHg38NvDZiFjadK2Z+Q5gHHgBT/9+iwPd5HBmO3R+88Oe9VAnABGxiNa00CG0TW82qdtaI+JIWu+qf38u6mvXw8/1EFpTn/dk5mnARlrTnYNYK1Vtl2bmMcDlwB3VbEGjhiYIqhNpdwN/mJmfmLFuAfBkZp5R/bK/RevGS2fR2rl+PiIeopXEm2eZrxuEWn8C7AM+BZCZXwaWRsQRA1grwGpgfVXr/cCPgV9rsM6TqhNsZOY/Af+N1hzstAPd5PDvgedV/xeqPp3e/HAu66QK0i/S2nmtrqbrGlOj1nOA5cC91d8VEfFQRIzRkBq1/l9gR2Z+oWr/FHB6U3XWqTUixoGTMnNjte2Gat3hTdYLQxIEEfECWofJb8zMz8zSZQr4UkQcU6XnVcBnM/OvMvOEzDylOvmyBTg7M3MAa91N6135G6rneQWtecXGzmv0Wmu17ttU5wuqaaWjge81VSvwQuCWiFhcvWteTdsdavMANzmsdqb3Aa+v2i+k2Zsf9lRn9fg24H8Br69eD03r9Wd6a2b+atvfFdXjHQNY6/eBJ6N19RvAKuBvG6yz51pp/a3vioiz4Odv0nZk5kTD9Q7N5aNvBQ4Fbmh7M/9R4Fzg7Zn5YERcRuvd1GJaJ4bfPx+FUq/WNwN/FhFXAHtpXa3T5DRGnVovqmr9Q1rnNi7KzH9sqtDM3BwRp9M6KtkPbMjMz0TE5ulaad3k8JZoXYb7TX5x1c1bgE9ExHW05ov/7aDVGa3LMFfTmlP+ZvX72JKZZw9arU3V02Ctv0vrtfp+YDut1+7A1ZqZUxHxu8CHImIJsIPWBSSN86ZzklS4oZgakiQ1xyCQpMIZBJJUOINAkgpnEEhS4QwCSSqcQSBJhTMIJKlw/x+0S/ki/0ixuQAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], "source": [ "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", diff --git a/examples/RCD.ipynb b/examples/RCD.ipynb index 6eca518..a09e303 100644 --- a/examples/RCD.ipynb +++ b/examples/RCD.ipynb @@ -24,7 +24,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['1.19.2', '1.1.2', '0.14.1', '1.5.0']\n" + "['1.16.2', '0.24.2', '0.11.1', '1.5.1']\n" ] } ], @@ -79,6 +79,7 @@ " x2\n", " x3\n", " x4\n", + " x5\n", " \n", " \n", " \n", @@ -89,6 +90,7 @@ " 0.014075\n", " -0.047309\n", " 0.016311\n", + " 0.686190\n", " \n", " \n", " 1\n", @@ -97,6 +99,7 @@ " -1.115854\n", " -0.035899\n", " -1.254783\n", + " 0.008009\n", " \n", " \n", " 2\n", @@ -105,6 +108,7 @@ " 0.426923\n", " 0.064804\n", " 0.894242\n", + " 0.117195\n", " \n", " \n", " 3\n", @@ -113,6 +117,7 @@ " 1.265038\n", " 0.704166\n", " 1.994283\n", + " 1.406609\n", " \n", " \n", " 4\n", @@ -121,18 +126,19 @@ " 0.116967\n", " 0.329866\n", " 0.257932\n", + " 0.814202\n", " \n", " \n", "\n", "" ], "text/plain": [ - " x0 x1 x2 x3 x4\n", - "0 -0.191493 -0.054157 0.014075 -0.047309 0.016311\n", - "1 -0.967142 0.013890 -1.115854 -0.035899 -1.254783\n", - "2 0.527409 -0.034960 0.426923 0.064804 0.894242\n", - "3 1.583826 0.845653 1.265038 0.704166 1.994283\n", - "4 0.286276 0.141120 0.116967 0.329866 0.257932" + " x0 x1 x2 x3 x4 x5\n", + "0 -0.191493 -0.054157 0.014075 -0.047309 0.016311 0.686190\n", + "1 -0.967142 0.013890 -1.115854 -0.035899 -1.254783 0.008009\n", + "2 0.527409 -0.034960 0.426923 0.064804 0.894242 0.117195\n", + "3 1.583826 0.845653 1.265038 0.704166 1.994283 1.406609\n", + "4 0.286276 0.141120 0.116967 0.329866 0.257932 0.814202" ] }, "execution_count": 2, @@ -154,8 +160,8 @@ "x2 = 0.8*x0 - 0.6*x6 + get_external_effect(n_samples)\n", "x4 = 1.0*x0 - 0.5*x6 + get_external_effect(n_samples)\n", "\n", - "# The latent variables x5 and x6 are not included.\n", - "X = pd.DataFrame(np.array([x0, x1, x2, x3, x4]).T, columns=['x0', 'x1', 'x2', 'x3', 'x4'])\n", + "# The latent variable x6 is not included.\n", + "X = pd.DataFrame(np.array([x0, x1, x2, x3, x4, x5]).T, columns=['x0', 'x1', 'x2', 'x3', 'x4', 'x5'])\n", "\n", "X.head()" ] @@ -171,116 +177,102 @@ "\r\n", "\r\n", - "\r\n", - "\r\n", - "\r\n", + "\r\n", + "\r\n", "\r\n", - "\r\n", + "%3\r\n", + "\r\n", "\r\n", - "\r\n", - "x0\r\n", - "\r\n", - "x0\r\n", + "x0\r\n", + "\r\n", + "x0\r\n", "\r\n", "\r\n", - "\r\n", - "x2\r\n", - "\r\n", - "x2\r\n", + "x2\r\n", + "\r\n", + "x2\r\n", "\r\n", "\r\n", - "\r\n", - "x0->x2\r\n", - "\r\n", - "\r\n", - "0.80\r\n", + "x0->x2\r\n", + "\r\n", + "\r\n", + "0.80\r\n", "\r\n", "\r\n", - "\r\n", - "x4\r\n", - "\r\n", - "x4\r\n", + "x4\r\n", + "\r\n", + "x4\r\n", "\r\n", "\r\n", - "\r\n", - "x0->x4\r\n", - "\r\n", - "\r\n", - "1.00\r\n", + "x0->x4\r\n", + "\r\n", + "\r\n", + "1.00\r\n", "\r\n", "\r\n", - "\r\n", - "x1\r\n", + "x1\r\n", "\r\n", "x1\r\n", "\r\n", "\r\n", - "\r\n", - "x1->x0\r\n", - "\r\n", - "\r\n", - "1.00\r\n", + "x1->x0\r\n", + "\r\n", + "\r\n", + "1.00\r\n", "\r\n", "\r\n", - "\r\n", - "x3\r\n", + "x3\r\n", "\r\n", "x3\r\n", "\r\n", "\r\n", - "\r\n", - "x3->x0\r\n", - "\r\n", - "\r\n", - "1.00\r\n", + "x3->x0\r\n", + "\r\n", + "\r\n", + "1.00\r\n", "\r\n", - "\r\n", - "\r\n", - "f0(x5)\r\n", - "\r\n", - "f0(x5)\r\n", + "\r\n", + "x5\r\n", + "\r\n", + "x5\r\n", "\r\n", - "\r\n", - "\r\n", - "f0(x5)->x1\r\n", - "\r\n", - "\r\n", - "0.60\r\n", + "\r\n", + "x5->x1\r\n", + "\r\n", + "\r\n", + "0.60\r\n", "\r\n", - "\r\n", - "\r\n", - "f0(x5)->x3\r\n", - "\r\n", - "\r\n", - "0.50\r\n", + "\r\n", + "x5->x3\r\n", + "\r\n", + "\r\n", + "0.50\r\n", "\r\n", "\r\n", - "\r\n", - "f1(x6)\r\n", - "\r\n", - "f1(x6)\r\n", + "f1(x6)\r\n", + "\r\n", + "f1(x6)\r\n", "\r\n", "\r\n", - "\r\n", - "f1(x6)->x2\r\n", - "\r\n", - "\r\n", - "-0.60\r\n", + "f1(x6)->x2\r\n", + "\r\n", + "\r\n", + "-0.60\r\n", "\r\n", "\r\n", - "\r\n", - "f1(x6)->x4\r\n", - "\r\n", - "\r\n", - "-0.50\r\n", + "f1(x6)->x4\r\n", + "\r\n", + "\r\n", + "-0.50\r\n", "\r\n", "\r\n", "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 3, @@ -296,7 +288,7 @@ " [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,-0.5],\n", " [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],\n", " [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]])\n", - "dot = make_dot(m, labels=['x0', 'x1', 'x2', 'x3', 'x4', 'f0(x5)', 'f1(x6)'])\n", + "dot = make_dot(m, labels=['x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'f1(x6)'])\n", "\n", "# Save pdf\n", "dot.render('dag')\n", @@ -324,7 +316,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 4, @@ -353,11 +345,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "M0=set()\n", - "M1=set()\n", - "M2={0, 1, 3}\n", - "M3=set()\n", - "M4={0, 1, 3}\n" + "M0={1, 3, 5}\n", + "M1={5}\n", + "M2={0, 1, 3, 5}\n", + "M3={5}\n", + "M4={0, 1, 3, 5}\n", + "M5=set()\n" ] } ], @@ -383,11 +376,12 @@ { "data": { "text/plain": [ - "array([[0. , nan, 0. , nan, 0. ],\n", - " [ nan, 0. , 0. , nan, 0. ],\n", - " [0.751, 0. , 0. , 0. , nan],\n", - " [ nan, nan, 0. , 0. , 0. ],\n", - " [1.016, 0. , nan, 0. , 0. ]])" + "array([[0. , 0.939, 0. , 0.994, 0. , 0. ],\n", + " [0. , 0. , 0. , 0. , 0. , 0.556],\n", + " [0.751, 0. , 0. , 0. , nan, 0. ],\n", + " [0. , 0. , 0. , 0. , 0. , 0.563],\n", + " [1.016, 0. , nan, 0. , 0. , 0. ],\n", + " [0. , 0. , 0. , 0. , 0. , 0. ]])" ] }, "execution_count": 6, @@ -410,90 +404,91 @@ "\r\n", "\r\n", - "\r\n", - "\r\n", - "\r\n", - "\r\n", - "\r\n", + "\r\n", + "\r\n", + "\r\n", + "%3\r\n", + "\r\n", "\r\n", - "\r\n", - "x0\r\n", - "\r\n", - "x0\r\n", - "\r\n", - "\r\n", - "\r\n", - "x1\r\n", - "\r\n", - "x1\r\n", - "\r\n", - "\r\n", - "\r\n", - "x0->x1\r\n", - "\r\n", - "\r\n", - "\r\n", + "x0\r\n", + "\r\n", + "x0\r\n", "\r\n", "\r\n", - "\r\n", - "x2\r\n", - "\r\n", - "x2\r\n", + "x2\r\n", + "\r\n", + "x2\r\n", "\r\n", "\r\n", - "\r\n", - "x0->x2\r\n", - "\r\n", - "\r\n", - "0.75\r\n", - "\r\n", - "\r\n", - "\r\n", - "x3\r\n", - "\r\n", - "x3\r\n", - "\r\n", - "\r\n", - "\r\n", - "x0->x3\r\n", - "\r\n", - "\r\n", - "\r\n", + "x0->x2\r\n", + "\r\n", + "\r\n", + "0.75\r\n", "\r\n", "\r\n", - "\r\n", - "x4\r\n", - "\r\n", - "x4\r\n", + "x4\r\n", + "\r\n", + "x4\r\n", "\r\n", "\r\n", - "\r\n", - "x0->x4\r\n", - "\r\n", - "\r\n", - "1.02\r\n", + "x0->x4\r\n", + "\r\n", + "\r\n", + "1.02\r\n", "\r\n", - "\r\n", - "\r\n", - "x1->x3\r\n", - "\r\n", - "\r\n", - "\r\n", + "\r\n", + "x1\r\n", + "\r\n", + "x1\r\n", + "\r\n", + "\r\n", + "x1->x0\r\n", + "\r\n", + "\r\n", + "0.94\r\n", "\r\n", "\r\n", - "\r\n", - "x2->x4\r\n", - "\r\n", - "\r\n", - "\r\n", + "x2->x4\r\n", + "\r\n", + "\r\n", + "\r\n", + "\r\n", + "\r\n", + "x3\r\n", + "\r\n", + "x3\r\n", + "\r\n", + "\r\n", + "x3->x0\r\n", + "\r\n", + "\r\n", + "0.99\r\n", + "\r\n", + "\r\n", + "x5\r\n", + "\r\n", + "x5\r\n", + "\r\n", + "\r\n", + "x5->x1\r\n", + "\r\n", + "\r\n", + "0.56\r\n", + "\r\n", + "\r\n", + "x5->x3\r\n", + "\r\n", + "\r\n", + "0.56\r\n", "\r\n", "\r\n", "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 7, @@ -505,6 +500,37 @@ "make_dot(model.adjacency_matrix_)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Independence between error variables\n", + "To check if the LiNGAM assumption is broken, we can get p-values of independence between error variables. The value in the i-th row and j-th column of the obtained matrix shows the p-value of the independence of the error variables $e_i$ and $e_j$." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0. nan 0.413 nan 0.68 ]\n", + " [0. 0. nan 0.732 nan 0.382]\n", + " [ nan nan 0. nan nan nan]\n", + " [0.413 0.732 nan 0. nan 0.054]\n", + " [ nan nan nan nan 0. nan]\n", + " [0.68 0.382 nan 0.054 nan 0. ]]\n" + ] + } + ], + "source": [ + "p_values = model.get_error_independence_p_values(X)\n", + "print(p_values)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -515,7 +541,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": { "scrolled": true }, @@ -538,7 +564,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -554,21 +580,21 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "x4 <--- x0 (b>0) (98.0%)\n", - "x2 <--- x0 (b>0) (44.0%)\n", - "x2 <--- x4 (b>0) (36.0%)\n", - "x0 <--- x1 (b>0) (25.0%)\n", - "x0 <--- x3 (b>0) (22.0%)\n", - "x4 <--- x3 (b<0) (19.0%)\n", - "x2 <--- x1 (b>0) (6.0%)\n", - "x2 <--- x3 (b>0) (6.0%)\n" + "x0 <--- x1 (b>0) (100.0%)\n", + "x4 <--- x0 (b>0) (99.0%)\n", + "x1 <--- x5 (b>0) (97.0%)\n", + "x2 <--- x0 (b>0) (96.0%)\n", + "x0 <--- x3 (b>0) (92.0%)\n", + "x3 <--- x5 (b>0) (67.0%)\n", + "x2 <--- x4 (b>0) (13.0%)\n", + "x4 <--- x3 (b<0) (11.0%)\n" ] } ], @@ -586,7 +612,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -602,24 +628,34 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "DAG[0]: 21.0%\n", - "\tx2 <--- x4 (b>0)\n", + "DAG[0]: 47.0%\n", + "\tx0 <--- x1 (b>0)\n", + "\tx0 <--- x3 (b>0)\n", + "\tx1 <--- x5 (b>0)\n", + "\tx2 <--- x0 (b>0)\n", + "\tx3 <--- x5 (b>0)\n", "\tx4 <--- x0 (b>0)\n", - "DAG[1]: 19.0%\n", + "DAG[1]: 20.0%\n", "\tx0 <--- x1 (b>0)\n", "\tx0 <--- x3 (b>0)\n", + "\tx1 <--- x5 (b>0)\n", "\tx2 <--- x0 (b>0)\n", "\tx4 <--- x0 (b>0)\n", - "DAG[2]: 18.0%\n", + "DAG[2]: 10.0%\n", + "\tx0 <--- x1 (b>0)\n", + "\tx0 <--- x3 (b>0)\n", + "\tx1 <--- x5 (b>0)\n", "\tx2 <--- x0 (b>0)\n", - "\tx4 <--- x0 (b>0)\n" + "\tx3 <--- x5 (b>0)\n", + "\tx4 <--- x0 (b>0)\n", + "\tx4 <--- x3 (b<0)\n" ] } ], @@ -637,18 +673,19 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[[0. 0.25 0. 0.22 0. ]\n", - " [0. 0. 0. 0. 0. ]\n", - " [0.44 0.06 0. 0.06 0.36]\n", - " [0. 0. 0. 0. 0. ]\n", - " [0.98 0.03 0.01 0.21 0. ]]\n" + "[[0. 1. 0. 0.92 0. 0.08]\n", + " [0. 0. 0. 0. 0. 0.97]\n", + " [0.96 0. 0. 0. 0.13 0. ]\n", + " [0. 0. 0. 0. 0. 0.67]\n", + " [0.99 0.01 0.02 0.12 0. 0. ]\n", + " [0. 0. 0. 0. 0. 0. ]]\n" ] } ], @@ -668,9 +705,19 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\AA005431\\OneDrive - SCREEN Holdings Co., Ltd\\code\\as\\lingam\\v1.5.1\\lingam\\bootstrap.py:305: RuntimeWarning: invalid value encountered in greater\n", + " min_causal_effect, 1, 0), axis=0, keepdims=True)[0]\n", + "C:\\Users\\AA005431\\OneDrive - SCREEN Holdings Co., Ltd\\code\\as\\lingam\\v1.5.1\\lingam\\bootstrap.py:315: RuntimeWarning: invalid value encountered in greater\n", + " idx = np.where(np.abs(self._total_effects[:, to, from_]) > 0)\n" + ] + }, { "data": { "text/html": [ @@ -701,93 +748,133 @@ " \n", "
\n", " 0\n", - " x4\n", - " x2\n", - " 0.225102\n", - " 0.51\n", + " x1\n", + " x0\n", + " 0.929241\n", + " 0.97\n", "
\n", "
\n", " 1\n", - " x0\n", + " x1\n", " x2\n", - " 0.814519\n", - " 0.20\n", + " 0.642897\n", + " 0.97\n", "
\n", "
\n", " 2\n", - " x0\n", + " x1\n", " x4\n", - " 1.164953\n", - " 0.20\n", + " 0.940142\n", + " 0.96\n", "
\n", "
\n", " 3\n", + " x0\n", " x2\n", - " x4\n", - " 0.243174\n", - " 0.04\n", + " 0.733251\n", + " 0.91\n", "
\n", "
\n", " 4\n", - " x1\n", " x0\n", - " 1.140202\n", - " 0.02\n", + " x4\n", + " 0.976640\n", + " 0.91\n", "
\n", "
\n", " 5\n", - " x1\n", - " x2\n", - " 0.803256\n", - " 0.02\n", + " x3\n", + " x0\n", + " 0.986875\n", + " 0.66\n", "
\n", "
\n", " 6\n", - " x1\n", - " x4\n", - " 1.115286\n", - " 0.02\n", + " x3\n", + " x2\n", + " 0.732515\n", + " 0.66\n", "
\n", "
\n", " 7\n", " x3\n", - " x0\n", - " 1.184964\n", - " 0.01\n", + " x4\n", + " 0.899673\n", + " 0.65\n", "
\n", "
\n", " 8\n", - " x3\n", - " x2\n", - " 0.872317\n", - " 0.01\n", + " x5\n", + " x0\n", + " 1.021466\n", + " 0.63\n", "
\n", "
\n", " 9\n", + " x5\n", + " x1\n", + " 0.555707\n", + " 0.63\n", + "
\n", + "
\n", + " 10\n", + " x5\n", + " x2\n", + " 0.741192\n", + " 0.63\n", + "
\n", + "
\n", + " 11\n", + " x5\n", " x3\n", + " 0.563175\n", + " 0.63\n", + "
\n", + "
\n", + " 12\n", + " x5\n", + " x4\n", + " 0.941773\n", + " 0.61\n", + "
\n", + "
\n", + " 13\n", + " x4\n", + " x2\n", + " 0.225102\n", + " 0.13\n", + "
\n", + "
\n", + " 14\n", + " x2\n", " x4\n", - " 1.084753\n", - " 0.01\n", + " 0.243174\n", + " 0.03\n", "
\n", "
\n", "\n", "" ], "text/plain": [ - " from to effect probability\n", - "0 x4 x2 0.225102 0.51\n", - "1 x0 x2 0.814519 0.20\n", - "2 x0 x4 1.164953 0.20\n", - "3 x2 x4 0.243174 0.04\n", - "4 x1 x0 1.140202 0.02\n", - "5 x1 x2 0.803256 0.02\n", - "6 x1 x4 1.115286 0.02\n", - "7 x3 x0 1.184964 0.01\n", - "8 x3 x2 0.872317 0.01\n", - "9 x3 x4 1.084753 0.01" + " from to effect probability\n", + "0 x1 x0 0.929241 0.97\n", + "1 x1 x2 0.642897 0.97\n", + "2 x1 x4 0.940142 0.96\n", + "3 x0 x2 0.733251 0.91\n", + "4 x0 x4 0.976640 0.91\n", + "5 x3 x0 0.986875 0.66\n", + "6 x3 x2 0.732515 0.66\n", + "7 x3 x4 0.899673 0.65\n", + "8 x5 x0 1.021466 0.63\n", + "9 x5 x1 0.555707 0.63\n", + "10 x5 x2 0.741192 0.63\n", + "11 x5 x3 0.563175 0.63\n", + "12 x5 x4 0.941773 0.61\n", + "13 x4 x2 0.225102 0.13\n", + "14 x2 x4 0.243174 0.03" ] }, - "execution_count": 14, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -812,7 +899,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -844,54 +931,54 @@ " \n", " \n", "
\n", - " 7\n", - " x3\n", + " 8\n", + " x5\n", " x0\n", - " 1.184964\n", - " 0.01\n", + " 1.021466\n", + " 0.63\n", "
\n", "
\n", - " 2\n", + " 5\n", + " x3\n", " x0\n", - " x4\n", - " 1.164953\n", - " 0.20\n", + " 0.986875\n", + " 0.66\n", "
\n", "
\n", " 4\n", - " x1\n", " x0\n", - " 1.140202\n", - " 0.02\n", + " x4\n", + " 0.976640\n", + " 0.91\n", "
\n", "
\n", - " 6\n", - " x1\n", + " 12\n", + " x5\n", " x4\n", - " 1.115286\n", - " 0.02\n", + " 0.941773\n", + " 0.61\n", "
\n", "
\n", - " 9\n", - " x3\n", + " 2\n", + " x1\n", " x4\n", - " 1.084753\n", - " 0.01\n", + " 0.940142\n", + " 0.96\n", "
\n", "
\n", "\n", "" ], "text/plain": [ - " from to effect probability\n", - "7 x3 x0 1.184964 0.01\n", - "2 x0 x4 1.164953 0.20\n", - "4 x1 x0 1.140202 0.02\n", - "6 x1 x4 1.115286 0.02\n", - "9 x3 x4 1.084753 0.01" + " from to effect probability\n", + "8 x5 x0 1.021466 0.63\n", + "5 x3 x0 0.986875 0.66\n", + "4 x0 x4 0.976640 0.91\n", + "12 x5 x4 0.941773 0.61\n", + "2 x1 x4 0.940142 0.96" ] }, - "execution_count": 15, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -902,7 +989,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -934,103 +1021,51 @@ " \n", " \n", "
\n", - " 7\n", - " x3\n", - " x0\n", - " 1.184964\n", - " 0.01\n", + " 14\n", + " x2\n", + " x4\n", + " 0.243174\n", + " 0.03\n", "
\n", "
\n", - " 8\n", - " x3\n", + " 13\n", + " x4\n", " x2\n", - " 0.872317\n", - " 0.01\n", + " 0.225102\n", + " 0.13\n", "
\n", "
\n", - " 9\n", - " x3\n", + " 12\n", + " x5\n", " x4\n", - " 1.084753\n", - " 0.01\n", + " 0.941773\n", + " 0.61\n", "
\n", "
\n", - " 4\n", - " x1\n", + " 8\n", + " x5\n", " x0\n", - " 1.140202\n", - " 0.02\n", + " 1.021466\n", + " 0.63\n", "
\n", "
\n", - " 5\n", + " 9\n", + " x5\n", " x1\n", - " x2\n", - " 0.803256\n", - " 0.02\n", - "
\n", - "
\n", - "\n", - "" - ], - "text/plain": [ - " from to effect probability\n", - "7 x3 x0 1.184964 0.01\n", - "8 x3 x2 0.872317 0.01\n", - "9 x3 x4 1.084753 0.01\n", - "4 x1 x0 1.140202 0.02\n", - "5 x1 x2 0.803256 0.02" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.sort_values('probability', ascending=True).head()" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", " \n", - " \n", - " \n", " \n", "
fromtoeffectprobability0.5557070.63
\n", "
" ], "text/plain": [ - "Empty DataFrame\n", - "Columns: [from, to, effect, probability]\n", - "Index: []" + " from to effect probability\n", + "14 x2 x4 0.243174 0.03\n", + "13 x4 x2 0.225102 0.13\n", + "12 x5 x4 0.941773 0.61\n", + "8 x5 x0 1.021466 0.63\n", + "9 x5 x1 0.555707 0.63" ] }, "execution_count": 17, @@ -1039,7 +1074,7 @@ } ], "source": [ - "df[df['to']=='x1'].head()" + "df.sort_values('probability', ascending=True).head()" ] }, { @@ -1051,25 +1086,35 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\lib\\histograms.py:824: RuntimeWarning: invalid value encountered in greater_equal\n", + " keep = (tmp_a >= first_edge)\n", + "C:\\ProgramData\\Anaconda3\\lib\\site-packages\\numpy\\lib\\histograms.py:825: RuntimeWarning: invalid value encountered in less_equal\n", + " keep &= (tmp_a <= last_edge)\n" + ] + }, { "data": { "text/plain": [ - "(array([78., 0., 0., 0., 0., 0., 0., 0., 0., 1.]),\n", - " array([0. , 0.118, 0.237, 0.355, 0.474, 0.592, 0.711, 0.829, 0.948,\n", - " 1.066, 1.185]),\n", - " )" + "(array([ 0., 0., 0., 0., 0., 63., 0., 0., 0., 0.]),\n", + " array([0.521, 0.621, 0.721, 0.821, 0.921, 1.021, 1.121, 1.221, 1.321,\n", + " 1.421, 1.521]),\n", + "
)" ] }, - "execution_count": 18, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" }, { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXMAAAD7CAYAAACYLnSTAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAASCUlEQVR4nO3df5BddXnH8fdu+LWSBXHnahajVhrzSGtJ/BGcKVitpHao0tSRlIqOjTYoU0vtVKajNYrS6mhtg8VaZBAG2gwKDR38BdUaGBURVArYEXlK2+Bosow7K9YkEkjY7R/3pq5Lcu85m3v33v32/ZphJvfc7z3neTjMJ1++595zhmZmZpAkLW7D/S5AknT4DHNJKoBhLkkFMMwlqQCGuSQV4Ig+HPNoYA0wATzeh+NL0mK0BBgHvgk8OvfNfoT5GuCrfTiuJJXgJcBtczdWCvOIeD3wztbLmzPzwohYDVwBHA98BTg/M/dX2N0EwMMP72F6uv533MfGljI1tbv25wZVSf3Yy+AqqZ+SeoHq/QwPD3HCCcdCK0Pn6hjmEfEk4FJgJfBj4GsRsRb4CLAxM++IiCuB84DLKtT+OMD09My8wvzAZ0tSUj/2MrhK6qekXqB2Pwddnq5yAXRJa9yxwJGtf/YBI5l5R2vM1cD6OtVIkrqnY5hn5i7g3cD9wA7gQeAxfn6qPwEs70F9kqQKqiyznAK8CXgW8D/AFuAVBxk6XefAY2NL6wz/OY3G6Lw/O4hK6sdeBldJ/ZTUC3SnnyoXQH8T2JaZPwSIiKuBC4Fls8aMAzvrHHhqave81r0ajVEmJ3fV/tygKqkfexlcJfVTUi9QvZ/h4aG2k+Aqa+b3Amsj4tiIGALOAr4M7I2I01pj3gDcXGFfkqQeqLJm/kXgk8BdwLdpXgD9IPA64JKI+C7Ni6OX9rBOSVIblb5nnpkfAj40Z/O9wKldr0iSVFs/fgF6WB7b93jfLn7sfXQ/u37ySF+OLUntLLowP+rIJZz19k/35dif/Zt1lHPZRVJJvGuiJ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DHg3cPHwKl64Cj0/C2wGvhoR3wP+EDhnaAXXZL7f1uYHgM9FxBPACuDzw6usPm09/w7NDxWcGRGPtv67Zsjl1eIV13lJ8wFlklSwJTmTl6SlwpCXpIIZ8pJUMENekgpmyEtSwQx5SSqYIS9JBTPkJalg/w/0NsjQUC/OYQAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] @@ -1086,11 +1131,18 @@ "sns.set()\n", "%matplotlib inline\n", "\n", - "from_index = 3 # index of x3\n", + "from_index = 5 # index of x5\n", "to_index = 0 # index of x0\n", "plt.hist(result.total_effects_[:, to_index, from_index])" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -1115,7 +1167,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.7.3" } }, "nbformat": 4, diff --git a/examples/VARLiNGAM.ipynb b/examples/VARLiNGAM.ipynb index e367244..2b17ac3 100644 --- a/examples/VARLiNGAM.ipynb +++ b/examples/VARLiNGAM.ipynb @@ -24,7 +24,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['1.16.2', '0.24.2', '0.11.1', '1.4.1']\n" + "['1.16.2', '0.24.2', '0.11.1', '1.5.1']\n" ] } ], @@ -91,7 +91,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 3, @@ -453,7 +453,7 @@ "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 9, @@ -466,6 +466,36 @@ "make_dot(np.hstack(model.adjacency_matrices_), ignore_shape=True, lower_limit=0.05, labels=labels)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Independence between error variables\n", + "To check if the LiNGAM assumption is broken, we can get p-values of independence between error variables. The value in the i-th row and j-th column of the obtained matrix shows the p-value of the independence of the error variables $e_i$ and $e_j$." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0.065 0.068 0.038 0.249]\n", + " [0.065 0. 0.13 0.88 0.57 ]\n", + " [0.068 0.13 0. 0.321 0.231]\n", + " [0.038 0.88 0.321 0. 0.839]\n", + " [0.249 0.57 0.231 0.839 0. ]]\n" + ] + } + ], + "source": [ + "p_values = model.get_error_independence_p_values()\n", + "print(p_values)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -483,7 +513,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -501,7 +531,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -517,7 +547,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -549,7 +579,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -565,7 +595,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -625,7 +655,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -664,7 +694,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -699,280 +729,266 @@ " 0\n", " x1(t)\n", " x0(t)\n", - " -0.142773\n", + " -0.131094\n", " 1.00\n", " \n", " \n", " 1\n", " x4(t-1)\n", - " x3(t)\n", - " -0.245236\n", + " x2(t)\n", + " 0.463646\n", " 1.00\n", " \n", " \n", " 2\n", - " x3(t-1)\n", + " x4(t-1)\n", " x3(t)\n", - " 0.114877\n", + " -0.224349\n", " 1.00\n", " \n", " \n", " 3\n", - " x2(t-1)\n", - " x3(t)\n", - " -0.203598\n", + " x0(t-1)\n", + " x0(t)\n", + " -0.297905\n", " 1.00\n", " \n", " \n", " 4\n", - " x0(t-1)\n", + " x1(t)\n", " x3(t)\n", - " -0.324941\n", + " -0.217983\n", " 1.00\n", " \n", " \n", " 5\n", - " x1(t)\n", - " x3(t)\n", - " -0.218320\n", + " x3(t-1)\n", + " x0(t)\n", + " 0.273013\n", " 1.00\n", " \n", " \n", " 6\n", - " x4(t-1)\n", - " x2(t)\n", - " 0.496761\n", + " x2(t-1)\n", + " x3(t)\n", + " -0.177952\n", " 1.00\n", " \n", " \n", " 7\n", - " x1(t)\n", - " x2(t)\n", - " 0.099477\n", + " x0(t-1)\n", + " x3(t)\n", + " -0.269388\n", " 1.00\n", " \n", " \n", " 8\n", - " x0(t)\n", - " x2(t)\n", - " -0.439085\n", + " x1(t-1)\n", + " x1(t)\n", + " -0.260914\n", " 1.00\n", " \n", " \n", " 9\n", - " x4(t-1)\n", - " x1(t)\n", - " 0.454093\n", + " x2(t-1)\n", + " x2(t)\n", + " 0.310371\n", " 1.00\n", " \n", " \n", " 10\n", - " x3(t-1)\n", + " x4(t-1)\n", " x1(t)\n", - " -0.353886\n", + " 0.397907\n", " 1.00\n", " \n", " \n", " 11\n", - " x2(t-1)\n", + " x0(t)\n", " x2(t)\n", - " 0.354316\n", + " -0.404106\n", " 1.00\n", " \n", " \n", " 12\n", - " x1(t-1)\n", " x1(t)\n", - " -0.294882\n", + " x2(t)\n", + " 0.090684\n", " 1.00\n", " \n", " \n", " 13\n", " x3(t-1)\n", - " x0(t)\n", - " 0.339193\n", - " 1.00\n", + " x1(t)\n", + " -0.206743\n", + " 0.99\n", " \n", " \n", " 14\n", - " x2(t-1)\n", - " x0(t)\n", - " 0.107363\n", - " 1.00\n", + " x3(t-1)\n", + " x3(t)\n", + " 0.091307\n", + " 0.93\n", " \n", " \n", " 15\n", " x2(t-1)\n", " x1(t)\n", - " -0.192527\n", - " 1.00\n", + " -0.121280\n", + " 0.86\n", " \n", " \n", " 16\n", - " x0(t-1)\n", " x0(t)\n", - " -0.381328\n", - " 1.00\n", + " x4(t)\n", + " 0.106232\n", + " 0.86\n", " \n", " \n", " 17\n", - " x3(t-1)\n", - " x4(t)\n", - " 0.099357\n", - " 0.99\n", + " x0(t-1)\n", + " x2(t)\n", + " 0.083258\n", + " 0.79\n", " \n", " \n", " 18\n", - " x0(t)\n", - " x4(t)\n", - " 0.145934\n", - " 0.99\n", + " x3(t-1)\n", + " x2(t)\n", + " -0.085736\n", + " 0.73\n", " \n", " \n", " 19\n", - " x0(t-1)\n", - " x2(t)\n", - " 0.109297\n", - " 0.98\n", + " x0(t)\n", + " x3(t)\n", + " 0.075516\n", + " 0.68\n", " \n", " \n", " 20\n", - " x3(t-1)\n", - " x2(t)\n", - " -0.113304\n", - " 0.98\n", + " x2(t-1)\n", + " x0(t)\n", + " 0.070990\n", + " 0.58\n", " \n", " \n", " 21\n", - " x4(t-1)\n", - " x0(t)\n", - " -0.055275\n", - " 0.95\n", + " x1(t-1)\n", + " x2(t)\n", + " -0.043181\n", + " 0.55\n", " \n", " \n", " 22\n", - " x1(t-1)\n", - " x2(t)\n", - " -0.048436\n", - " 0.95\n", + " x4(t-1)\n", + " x0(t)\n", + " -0.047978\n", + " 0.50\n", " \n", " \n", " 23\n", - " x0(t-1)\n", - " x4(t)\n", - " -0.052491\n", - " 0.93\n", + " x1(t-1)\n", + " x0(t)\n", + " 0.026918\n", + " 0.32\n", " \n", " \n", " 24\n", - " x1(t)\n", + " x2(t)\n", " x4(t)\n", - " -0.038710\n", - " 0.92\n", + " -0.049998\n", + " 0.29\n", " \n", " \n", " 25\n", - " x0(t-1)\n", - " x1(t)\n", - " 0.032712\n", - " 0.90\n", + " x3(t)\n", + " x0(t)\n", + " 0.053440\n", + " 0.23\n", " \n", " \n", " 26\n", - " x1(t-1)\n", - " x0(t)\n", - " 0.026323\n", - " 0.83\n", + " x4(t)\n", + " x2(t)\n", + " -0.053585\n", + " 0.22\n", " \n", " \n", " 27\n", - " x2(t-1)\n", - " x4(t)\n", - " -0.003520\n", - " 0.81\n", + " x3(t)\n", + " x2(t)\n", + " -0.034164\n", + " 0.22\n", " \n", " \n", " 28\n", - " x4(t-1)\n", + " x3(t-1)\n", " x4(t)\n", - " -0.020322\n", - " 0.78\n", + " 0.069278\n", + " 0.20\n", " \n", " \n", " 29\n", - " x3(t)\n", + " x1(t)\n", " x4(t)\n", - " -0.074582\n", - " 0.70\n", + " -0.032277\n", + " 0.17\n", " \n", " \n", " 30\n", - " x0(t)\n", + " x4(t)\n", " x3(t)\n", - " 0.077178\n", - " 0.69\n", + " -0.041963\n", + " 0.16\n", " \n", " \n", " 31\n", - " x2(t)\n", - " x4(t)\n", - " -0.064105\n", - " 0.67\n", + " x1(t-1)\n", + " x3(t)\n", + " 0.018327\n", + " 0.14\n", " \n", " \n", " 32\n", - " x1(t-1)\n", + " x2(t)\n", " x3(t)\n", - " -0.000250\n", - " 0.59\n", + " -0.017783\n", + " 0.13\n", " \n", " \n", " 33\n", - " x1(t-1)\n", - " x4(t)\n", - " 0.002664\n", - " 0.56\n", + " x0(t-1)\n", + " x1(t)\n", + " 0.084306\n", + " 0.04\n", " \n", " \n", " 34\n", " x3(t)\n", - " x2(t)\n", - " 0.008626\n", - " 0.50\n", + " x4(t)\n", + " -0.117271\n", + " 0.02\n", " \n", " \n", " 35\n", " x4(t)\n", - " x2(t)\n", - " -0.062254\n", - " 0.33\n", - " \n", - " \n", - " 36\n", - " x2(t)\n", - " x3(t)\n", - " 0.006647\n", - " 0.32\n", - " \n", - " \n", - " 37\n", - " x3(t)\n", " x0(t)\n", - " 0.057305\n", - " 0.29\n", + " 0.081813\n", + " 0.01\n", " \n", " \n", - " 38\n", + " 36\n", + " x0(t-1)\n", " x4(t)\n", - " x3(t)\n", - " -0.040263\n", - " 0.27\n", + " -0.085855\n", + " 0.01\n", " \n", " \n", - " 39\n", + " 37\n", + " x1(t-1)\n", " x4(t)\n", - " x0(t)\n", - " 0.081813\n", + " 0.036685\n", " 0.01\n", " \n", " \n", @@ -981,49 +997,47 @@ ], "text/plain": [ " from to effect probability\n", - "0 x1(t) x0(t) -0.142773 1.00\n", - "1 x4(t-1) x3(t) -0.245236 1.00\n", - "2 x3(t-1) x3(t) 0.114877 1.00\n", - "3 x2(t-1) x3(t) -0.203598 1.00\n", - "4 x0(t-1) x3(t) -0.324941 1.00\n", - "5 x1(t) x3(t) -0.218320 1.00\n", - "6 x4(t-1) x2(t) 0.496761 1.00\n", - "7 x1(t) x2(t) 0.099477 1.00\n", - "8 x0(t) x2(t) -0.439085 1.00\n", - "9 x4(t-1) x1(t) 0.454093 1.00\n", - "10 x3(t-1) x1(t) -0.353886 1.00\n", - "11 x2(t-1) x2(t) 0.354316 1.00\n", - "12 x1(t-1) x1(t) -0.294882 1.00\n", - "13 x3(t-1) x0(t) 0.339193 1.00\n", - "14 x2(t-1) x0(t) 0.107363 1.00\n", - "15 x2(t-1) x1(t) -0.192527 1.00\n", - "16 x0(t-1) x0(t) -0.381328 1.00\n", - "17 x3(t-1) x4(t) 0.099357 0.99\n", - "18 x0(t) x4(t) 0.145934 0.99\n", - "19 x0(t-1) x2(t) 0.109297 0.98\n", - "20 x3(t-1) x2(t) -0.113304 0.98\n", - "21 x4(t-1) x0(t) -0.055275 0.95\n", - "22 x1(t-1) x2(t) -0.048436 0.95\n", - "23 x0(t-1) x4(t) -0.052491 0.93\n", - "24 x1(t) x4(t) -0.038710 0.92\n", - "25 x0(t-1) x1(t) 0.032712 0.90\n", - "26 x1(t-1) x0(t) 0.026323 0.83\n", - "27 x2(t-1) x4(t) -0.003520 0.81\n", - "28 x4(t-1) x4(t) -0.020322 0.78\n", - "29 x3(t) x4(t) -0.074582 0.70\n", - "30 x0(t) x3(t) 0.077178 0.69\n", - "31 x2(t) x4(t) -0.064105 0.67\n", - "32 x1(t-1) x3(t) -0.000250 0.59\n", - "33 x1(t-1) x4(t) 0.002664 0.56\n", - "34 x3(t) x2(t) 0.008626 0.50\n", - "35 x4(t) x2(t) -0.062254 0.33\n", - "36 x2(t) x3(t) 0.006647 0.32\n", - "37 x3(t) x0(t) 0.057305 0.29\n", - "38 x4(t) x3(t) -0.040263 0.27\n", - "39 x4(t) x0(t) 0.081813 0.01" + "0 x1(t) x0(t) -0.131094 1.00\n", + "1 x4(t-1) x2(t) 0.463646 1.00\n", + "2 x4(t-1) x3(t) -0.224349 1.00\n", + "3 x0(t-1) x0(t) -0.297905 1.00\n", + "4 x1(t) x3(t) -0.217983 1.00\n", + "5 x3(t-1) x0(t) 0.273013 1.00\n", + "6 x2(t-1) x3(t) -0.177952 1.00\n", + "7 x0(t-1) x3(t) -0.269388 1.00\n", + "8 x1(t-1) x1(t) -0.260914 1.00\n", + "9 x2(t-1) x2(t) 0.310371 1.00\n", + "10 x4(t-1) x1(t) 0.397907 1.00\n", + "11 x0(t) x2(t) -0.404106 1.00\n", + "12 x1(t) x2(t) 0.090684 1.00\n", + "13 x3(t-1) x1(t) -0.206743 0.99\n", + "14 x3(t-1) x3(t) 0.091307 0.93\n", + "15 x2(t-1) x1(t) -0.121280 0.86\n", + "16 x0(t) x4(t) 0.106232 0.86\n", + "17 x0(t-1) x2(t) 0.083258 0.79\n", + "18 x3(t-1) x2(t) -0.085736 0.73\n", + "19 x0(t) x3(t) 0.075516 0.68\n", + "20 x2(t-1) x0(t) 0.070990 0.58\n", + "21 x1(t-1) x2(t) -0.043181 0.55\n", + "22 x4(t-1) x0(t) -0.047978 0.50\n", + "23 x1(t-1) x0(t) 0.026918 0.32\n", + "24 x2(t) x4(t) -0.049998 0.29\n", + "25 x3(t) x0(t) 0.053440 0.23\n", + "26 x4(t) x2(t) -0.053585 0.22\n", + "27 x3(t) x2(t) -0.034164 0.22\n", + "28 x3(t-1) x4(t) 0.069278 0.20\n", + "29 x1(t) x4(t) -0.032277 0.17\n", + "30 x4(t) x3(t) -0.041963 0.16\n", + "31 x1(t-1) x3(t) 0.018327 0.14\n", + "32 x2(t) x3(t) -0.017783 0.13\n", + "33 x0(t-1) x1(t) 0.084306 0.04\n", + "34 x3(t) x4(t) -0.117271 0.02\n", + "35 x4(t) x0(t) 0.081813 0.01\n", + "36 x0(t-1) x4(t) -0.085855 0.01\n", + "37 x1(t-1) x4(t) 0.036685 0.01" ] }, - "execution_count": 16, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -1046,7 +1060,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -1078,39 +1092,39 @@ " \n", " \n", " \n", - " 6\n", + " 1\n", " x4(t-1)\n", " x2(t)\n", - " 0.496761\n", + " 0.463646\n", " 1.00\n", " \n", " \n", - " 9\n", + " 10\n", " x4(t-1)\n", " x1(t)\n", - " 0.454093\n", + " 0.397907\n", " 1.00\n", " \n", " \n", - " 11\n", + " 9\n", " x2(t-1)\n", " x2(t)\n", - " 0.354316\n", + " 0.310371\n", " 1.00\n", " \n", " \n", - " 13\n", + " 5\n", " x3(t-1)\n", " x0(t)\n", - " 0.339193\n", + " 0.273013\n", " 1.00\n", " \n", " \n", - " 18\n", + " 16\n", " x0(t)\n", " x4(t)\n", - " 0.145934\n", - " 0.99\n", + " 0.106232\n", + " 0.86\n", " \n", " \n", "\n", @@ -1118,14 +1132,14 @@ ], "text/plain": [ " from to effect probability\n", - "6 x4(t-1) x2(t) 0.496761 1.00\n", - "9 x4(t-1) x1(t) 0.454093 1.00\n", - "11 x2(t-1) x2(t) 0.354316 1.00\n", - "13 x3(t-1) x0(t) 0.339193 1.00\n", - "18 x0(t) x4(t) 0.145934 0.99" + "1 x4(t-1) x2(t) 0.463646 1.00\n", + "10 x4(t-1) x1(t) 0.397907 1.00\n", + "9 x2(t-1) x2(t) 0.310371 1.00\n", + "5 x3(t-1) x0(t) 0.273013 1.00\n", + "16 x0(t) x4(t) 0.106232 0.86" ] }, - "execution_count": 17, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -1143,7 +1157,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -1175,39 +1189,39 @@ " \n", " \n", " \n", - " 9\n", - " x4(t-1)\n", + " 8\n", + " x1(t-1)\n", " x1(t)\n", - " 0.454093\n", - " 1.0\n", + " -0.260914\n", + " 1.00\n", " \n", " \n", " 10\n", - " x3(t-1)\n", + " x4(t-1)\n", " x1(t)\n", - " -0.353886\n", - " 1.0\n", + " 0.397907\n", + " 1.00\n", " \n", " \n", - " 12\n", - " x1(t-1)\n", + " 13\n", + " x3(t-1)\n", " x1(t)\n", - " -0.294882\n", - " 1.0\n", + " -0.206743\n", + " 0.99\n", " \n", " \n", " 15\n", " x2(t-1)\n", " x1(t)\n", - " -0.192527\n", - " 1.0\n", + " -0.121280\n", + " 0.86\n", " \n", " \n", - " 25\n", + " 33\n", " x0(t-1)\n", " x1(t)\n", - " 0.032712\n", - " 0.9\n", + " 0.084306\n", + " 0.04\n", " \n", " \n", "\n", @@ -1215,14 +1229,14 @@ ], "text/plain": [ " from to effect probability\n", - "9 x4(t-1) x1(t) 0.454093 1.0\n", - "10 x3(t-1) x1(t) -0.353886 1.0\n", - "12 x1(t-1) x1(t) -0.294882 1.0\n", - "15 x2(t-1) x1(t) -0.192527 1.0\n", - "25 x0(t-1) x1(t) 0.032712 0.9" + "8 x1(t-1) x1(t) -0.260914 1.00\n", + "10 x4(t-1) x1(t) 0.397907 1.00\n", + "13 x3(t-1) x1(t) -0.206743 0.99\n", + "15 x2(t-1) x1(t) -0.121280 0.86\n", + "33 x0(t-1) x1(t) 0.084306 0.04" ] }, - "execution_count": 18, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -1240,25 +1254,25 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(array([ 2., 5., 16., 20., 25., 14., 9., 8., 0., 1.]),\n", - " array([0.266, 0.287, 0.308, 0.328, 0.349, 0.37 , 0.39 , 0.411, 0.432,\n", - " 0.452, 0.473]),\n", + "(array([ 3., 1., 6., 18., 13., 22., 9., 10., 9., 9.]),\n", + " array([0.215, 0.232, 0.25 , 0.267, 0.285, 0.302, 0.32 , 0.338, 0.355,\n", + " 0.373, 0.39 ]),\n", " )" ] }, - "execution_count": 19, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" }, { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEBCAYAAABysL6vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAADudJREFUeJzt3X+MZWV9x/H3zO6yizAgnV7KIlBslG8pVTGyYirgHyIJ6mazoUBKE8AWKRFTbFdpGyAUbaNphNBAkYQWS4JFExC3y6Kxsv4BaCltVRqh35gWkiJbu5nSskuA/THTP+6dOhKWOff3zHfer2Szc8895z7fee6Zzz773HOemZibm0OSVM/kuAuQJA2HAS9JRRnwklSUAS9JRRnwklSUAS9JRRnwklSUAS9JRRnwklSUAS9JRRnwklTU6jG0uRbYAOwEDoyhfUlajlYB64HHgVeaHDCOgN8APDyGdiWpgjOBR5rsOI6A3wnw/PMvMju7cleynJ4+nJmZPeMuY0mzj5qxnxZXoY8mJyc46qjDoJOhTYwj4A8AzM7OreiAB1b899+EfdSM/bS4Qn3UeGrbD1klqSgDXpKKMuAlqSgDXpKKavQha0RcD1zQebg9M6+OiC8CZwAvdrbfkJn3D6FGSVIPFg34iDgbOAd4JzAHfCMiNgOnAWdlZuNLdiRJo9NkBL8T2JKZewEi4inghM6fOyPiTcD9tEfws0OrVJLUlYm5uebXhkbEW4FHad9J9TngY8D/Ag8A92TmHQ1e5kTg6a4r1Yqyd98BDlmzasW0K3XhzcAzTXZsfKNTRJwCbAc+lZkJbF7w3C3AxUCTgAdgZmZPpRsPutZqTbFr1+5xl7FktVpTbNyydeTtbrtx07J7XzyXFlehjyYnJ5iePry7Y5rsFBHvBR4C/jAz74qIt0XEeQt2mQD2ddWyJGmomnzIejzwNeDCzNzR2TwB3BwRO4A9wOXAXUOrUpLUtSZTNJ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QdwYKXpKIseEkqyoKXpKIseEkqyoKXpKIseEkqyoKXpKL+Dw0Ffe9oVwiWAAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] diff --git a/examples/VARMALiNGAM.ipynb b/examples/VARMALiNGAM.ipynb index c8c6f74..3fc163b 100644 --- a/examples/VARMALiNGAM.ipynb +++ b/examples/VARMALiNGAM.ipynb @@ -24,7 +24,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['1.16.2', '0.24.2', '0.11.1', '1.4.1']\n" + "['1.16.2', '0.24.2', '0.11.1', '1.5.1']\n" ] } ], @@ -101,7 +101,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 3, @@ -390,7 +390,7 @@ "\r\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 9, @@ -403,6 +403,36 @@ "make_dot(np.hstack(model.adjacency_matrices_[0]), lower_limit=0.3, ignore_shape=True, labels=labels)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Independence between error variables\n", + "To check if the LiNGAM assumption is broken, we can get p-values of independence between error variables. The value in the i-th row and j-th column of the obtained matrix shows the p-value of the independence of the error variables $e_i$ and $e_j$." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0.517 0.793 0.004 0.001]\n", + " [0.517 0. 0.09 0.312 0.071]\n", + " [0.793 0.09 0. 0.058 0.075]\n", + " [0.004 0.312 0.058 0. 0.011]\n", + " [0.001 0.071 0.075 0.011 0. ]]\n" + ] + } + ], + "source": [ + "p_values = model.get_error_independence_p_values()\n", + "print(p_values)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -420,7 +450,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -438,7 +468,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -454,7 +484,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -487,7 +517,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -503,7 +533,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -581,7 +611,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -627,7 +657,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -660,262 +690,262 @@ " \n", " \n", " 0\n", + " y4(t-1)\n", " y2(t)\n", - " y0(t)\n", - " -0.239746\n", + " 0.377029\n", " 1.00\n", " \n", " \n", " 1\n", - " y2(t-1)\n", - " y4(t)\n", - " -0.400593\n", + " y2(t)\n", + " y3(t)\n", + " -0.238642\n", " 1.00\n", " \n", " \n", " 2\n", - " y1(t-1)\n", - " y4(t)\n", - " 0.260280\n", + " y1(t)\n", + " y3(t)\n", + " -0.213468\n", " 1.00\n", " \n", " \n", " 3\n", - " y0(t-1)\n", - " y4(t)\n", - " -0.562191\n", + " y0(t)\n", + " y3(t)\n", + " 0.563522\n", " 1.00\n", " \n", " \n", " 4\n", - " y0(t)\n", + " y3(t-1)\n", " y4(t)\n", - " 0.114686\n", + " 0.343541\n", " 1.00\n", " \n", " \n", " 5\n", - " y4(t-1)\n", - " y3(t)\n", - " -0.182899\n", + " y0(t-1)\n", + " y2(t)\n", + " -0.254723\n", " 1.00\n", " \n", " \n", " 6\n", - " y0(t-1)\n", - " y3(t)\n", - " 0.251303\n", + " y4(t-1)\n", + " y1(t)\n", + " 0.438051\n", " 1.00\n", " \n", " \n", " 7\n", - " y2(t)\n", - " y3(t)\n", - " -0.260720\n", + " y3(t-1)\n", + " y1(t)\n", + " 0.266735\n", " 1.00\n", " \n", " \n", " 8\n", + " y1(t-1)\n", " y1(t)\n", - " y3(t)\n", - " -0.212046\n", + " 0.312631\n", " 1.00\n", " \n", " \n", " 9\n", - " y0(t)\n", - " y3(t)\n", - " 0.647221\n", + " y0(t-1)\n", + " y4(t)\n", + " -0.531720\n", " 1.00\n", " \n", " \n", " 10\n", - " y3(t-1)\n", + " y1(t-1)\n", " y4(t)\n", - " 0.333874\n", + " 0.226082\n", " 1.00\n", " \n", " \n", " 11\n", - " y3(t-1)\n", " y2(t)\n", - " 0.282825\n", + " y1(t)\n", + " 0.231064\n", " 1.00\n", " \n", " \n", " 12\n", - " y1(t-1)\n", - " y2(t)\n", - " 0.378391\n", + " y0(t)\n", + " y1(t)\n", + " -0.310366\n", " 1.00\n", " \n", " \n", " 13\n", - " y0(t-1)\n", - " y2(t)\n", - " -0.306198\n", + " y4(t-1)\n", + " y0(t)\n", + " 0.210816\n", " 1.00\n", " \n", " \n", " 14\n", - " y4(t-1)\n", - " y2(t)\n", - " 0.421177\n", + " y3(t-1)\n", + " y0(t)\n", + " 0.375119\n", " 1.00\n", " \n", " \n", " 15\n", - " y3(t-1)\n", - " y1(t)\n", - " 0.314910\n", + " y2(t-1)\n", + " y0(t)\n", + " -0.377158\n", " 1.00\n", " \n", " \n", " 16\n", - " y0(t-1)\n", - " y0(t)\n", - " -0.227950\n", + " y2(t-1)\n", + " y4(t)\n", + " -0.368007\n", " 1.00\n", " \n", " \n", " 17\n", - " y2(t-1)\n", - " y0(t)\n", - " -0.385377\n", + " y0(t-1)\n", + " y1(t)\n", + " -0.419723\n", " 1.00\n", " \n", " \n", " 18\n", - " y3(t-1)\n", - " y0(t)\n", - " 0.441629\n", - " 1.00\n", + " y1(t-1)\n", + " y2(t)\n", + " 0.329416\n", + " 0.99\n", " \n", " \n", " 19\n", - " y4(t-1)\n", + " y0(t-1)\n", " y0(t)\n", - " 0.220811\n", - " 1.00\n", + " -0.188156\n", + " 0.99\n", " \n", " \n", " 20\n", - " y4(t-1)\n", - " y1(t)\n", - " 0.447219\n", - " 1.00\n", + " y1(t-1)\n", + " y3(t)\n", + " 0.120133\n", + " 0.98\n", " \n", " \n", " 21\n", - " y0(t)\n", - " y1(t)\n", - " -0.392861\n", - " 1.00\n", + " y0(t-1)\n", + " y3(t)\n", + " 0.217037\n", + " 0.98\n", " \n", " \n", " 22\n", " y4(t-1)\n", - " y4(t)\n", - " 0.295080\n", - " 1.00\n", + " y3(t)\n", + " -0.186410\n", + " 0.97\n", " \n", " \n", " 23\n", + " y3(t-1)\n", " y2(t)\n", - " y1(t)\n", - " 0.273604\n", - " 1.00\n", + " 0.184045\n", + " 0.97\n", " \n", " \n", " 24\n", - " y0(t-1)\n", - " y1(t)\n", - " -0.472803\n", - " 1.00\n", + " y4(t-1)\n", + " y4(t)\n", + " 0.287224\n", + " 0.92\n", " \n", " \n", " 25\n", - " y1(t-1)\n", - " y1(t)\n", - " 0.371311\n", - " 1.00\n", + " y2(t)\n", + " y0(t)\n", + " -0.147135\n", + " 0.91\n", " \n", " \n", " 26\n", - " y1(t-1)\n", " y3(t)\n", - " 0.115601\n", - " 0.99\n", + " y4(t)\n", + " 0.056672\n", + " 0.73\n", " \n", " \n", " 27\n", - " y2(t)\n", - " y4(t)\n", - " -0.103683\n", - " 0.97\n", + " y3(t-1)\n", + " y3(t)\n", + " -0.139039\n", + " 0.63\n", " \n", " \n", " 28\n", - " y3(t-1)\n", - " y3(t)\n", - " -0.156020\n", - " 0.95\n", + " y0(t)\n", + " y4(t)\n", + " 0.086335\n", + " 0.46\n", " \n", " \n", " 29\n", " y2(t-1)\n", - " y3(t)\n", - " -0.087312\n", - " 0.93\n", + " y1(t)\n", + " 0.081208\n", + " 0.41\n", " \n", " \n", " 30\n", - " y2(t-1)\n", - " y1(t)\n", - " 0.041698\n", - " 0.88\n", + " y1(t-1)\n", + " y0(t)\n", + " -0.040277\n", + " 0.26\n", " \n", " \n", " 31\n", - " y2(t-1)\n", " y2(t)\n", - " -0.013958\n", - " 0.87\n", + " y4(t)\n", + " -0.088182\n", + " 0.20\n", " \n", " \n", " 32\n", - " y1(t)\n", - " y4(t)\n", - " -0.047350\n", - " 0.83\n", + " y2(t-1)\n", + " y2(t)\n", + " -0.052064\n", + " 0.19\n", " \n", " \n", " 33\n", - " y1(t-1)\n", - " y0(t)\n", - " 0.026292\n", - " 0.81\n", + " y1(t)\n", + " y4(t)\n", + " -0.056033\n", + " 0.05\n", " \n", " \n", " 34\n", - " y3(t)\n", " y4(t)\n", - " 0.049731\n", - " 0.70\n", + " y3(t)\n", + " 0.057538\n", + " 0.04\n", " \n", " \n", " 35\n", - " y4(t)\n", + " y2(t-1)\n", " y3(t)\n", - " 0.006900\n", - " 0.17\n", + " -0.261473\n", + " 0.02\n", " \n", " \n", " 36\n", " y4(t)\n", " y1(t)\n", - " 0.008282\n", - " 0.06\n", + " 0.013746\n", + " 0.01\n", " \n", " \n", "\n", @@ -923,46 +953,46 @@ ], "text/plain": [ " from to effect probability\n", - "0 y2(t) y0(t) -0.239746 1.00\n", - "1 y2(t-1) y4(t) -0.400593 1.00\n", - "2 y1(t-1) y4(t) 0.260280 1.00\n", - "3 y0(t-1) y4(t) -0.562191 1.00\n", - "4 y0(t) y4(t) 0.114686 1.00\n", - "5 y4(t-1) y3(t) -0.182899 1.00\n", - "6 y0(t-1) y3(t) 0.251303 1.00\n", - "7 y2(t) y3(t) -0.260720 1.00\n", - "8 y1(t) y3(t) -0.212046 1.00\n", - "9 y0(t) y3(t) 0.647221 1.00\n", - "10 y3(t-1) y4(t) 0.333874 1.00\n", - "11 y3(t-1) y2(t) 0.282825 1.00\n", - "12 y1(t-1) y2(t) 0.378391 1.00\n", - "13 y0(t-1) y2(t) -0.306198 1.00\n", - "14 y4(t-1) y2(t) 0.421177 1.00\n", - "15 y3(t-1) y1(t) 0.314910 1.00\n", - "16 y0(t-1) y0(t) -0.227950 1.00\n", - "17 y2(t-1) y0(t) -0.385377 1.00\n", - "18 y3(t-1) y0(t) 0.441629 1.00\n", - "19 y4(t-1) y0(t) 0.220811 1.00\n", - "20 y4(t-1) y1(t) 0.447219 1.00\n", - "21 y0(t) y1(t) -0.392861 1.00\n", - "22 y4(t-1) y4(t) 0.295080 1.00\n", - "23 y2(t) y1(t) 0.273604 1.00\n", - "24 y0(t-1) y1(t) -0.472803 1.00\n", - "25 y1(t-1) y1(t) 0.371311 1.00\n", - "26 y1(t-1) y3(t) 0.115601 0.99\n", - "27 y2(t) y4(t) -0.103683 0.97\n", - "28 y3(t-1) y3(t) -0.156020 0.95\n", - "29 y2(t-1) y3(t) -0.087312 0.93\n", - "30 y2(t-1) y1(t) 0.041698 0.88\n", - "31 y2(t-1) y2(t) -0.013958 0.87\n", - "32 y1(t) y4(t) -0.047350 0.83\n", - "33 y1(t-1) y0(t) 0.026292 0.81\n", - "34 y3(t) y4(t) 0.049731 0.70\n", - "35 y4(t) y3(t) 0.006900 0.17\n", - "36 y4(t) y1(t) 0.008282 0.06" + "0 y4(t-1) y2(t) 0.377029 1.00\n", + "1 y2(t) y3(t) -0.238642 1.00\n", + "2 y1(t) y3(t) -0.213468 1.00\n", + "3 y0(t) y3(t) 0.563522 1.00\n", + "4 y3(t-1) y4(t) 0.343541 1.00\n", + "5 y0(t-1) y2(t) -0.254723 1.00\n", + "6 y4(t-1) y1(t) 0.438051 1.00\n", + "7 y3(t-1) y1(t) 0.266735 1.00\n", + "8 y1(t-1) y1(t) 0.312631 1.00\n", + "9 y0(t-1) y4(t) -0.531720 1.00\n", + "10 y1(t-1) y4(t) 0.226082 1.00\n", + "11 y2(t) y1(t) 0.231064 1.00\n", + "12 y0(t) y1(t) -0.310366 1.00\n", + "13 y4(t-1) y0(t) 0.210816 1.00\n", + "14 y3(t-1) y0(t) 0.375119 1.00\n", + "15 y2(t-1) y0(t) -0.377158 1.00\n", + "16 y2(t-1) y4(t) -0.368007 1.00\n", + "17 y0(t-1) y1(t) -0.419723 1.00\n", + "18 y1(t-1) y2(t) 0.329416 0.99\n", + "19 y0(t-1) y0(t) -0.188156 0.99\n", + "20 y1(t-1) y3(t) 0.120133 0.98\n", + "21 y0(t-1) y3(t) 0.217037 0.98\n", + "22 y4(t-1) y3(t) -0.186410 0.97\n", + "23 y3(t-1) y2(t) 0.184045 0.97\n", + "24 y4(t-1) y4(t) 0.287224 0.92\n", + "25 y2(t) y0(t) -0.147135 0.91\n", + "26 y3(t) y4(t) 0.056672 0.73\n", + "27 y3(t-1) y3(t) -0.139039 0.63\n", + "28 y0(t) y4(t) 0.086335 0.46\n", + "29 y2(t-1) y1(t) 0.081208 0.41\n", + "30 y1(t-1) y0(t) -0.040277 0.26\n", + "31 y2(t) y4(t) -0.088182 0.20\n", + "32 y2(t-1) y2(t) -0.052064 0.19\n", + "33 y1(t) y4(t) -0.056033 0.05\n", + "34 y4(t) y3(t) 0.057538 0.04\n", + "35 y2(t-1) y3(t) -0.261473 0.02\n", + "36 y4(t) y1(t) 0.013746 0.01" ] }, - "execution_count": 16, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -985,7 +1015,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -1017,38 +1047,38 @@ " \n", " \n", " \n", - " 9\n", + " 3\n", " y0(t)\n", " y3(t)\n", - " 0.647221\n", + " 0.563522\n", " 1.0\n", " \n", " \n", - " 20\n", + " 6\n", " y4(t-1)\n", " y1(t)\n", - " 0.447219\n", + " 0.438051\n", " 1.0\n", " \n", " \n", - " 18\n", - " y3(t-1)\n", - " y0(t)\n", - " 0.441629\n", + " 0\n", + " y4(t-1)\n", + " y2(t)\n", + " 0.377029\n", " 1.0\n", " \n", " \n", " 14\n", - " y4(t-1)\n", - " y2(t)\n", - " 0.421177\n", + " y3(t-1)\n", + " y0(t)\n", + " 0.375119\n", " 1.0\n", " \n", " \n", - " 12\n", - " y1(t-1)\n", - " y2(t)\n", - " 0.378391\n", + " 4\n", + " y3(t-1)\n", + " y4(t)\n", + " 0.343541\n", " 1.0\n", " \n", " \n", @@ -1057,14 +1087,14 @@ ], "text/plain": [ " from to effect probability\n", - "9 y0(t) y3(t) 0.647221 1.0\n", - "20 y4(t-1) y1(t) 0.447219 1.0\n", - "18 y3(t-1) y0(t) 0.441629 1.0\n", - "14 y4(t-1) y2(t) 0.421177 1.0\n", - "12 y1(t-1) y2(t) 0.378391 1.0" + "3 y0(t) y3(t) 0.563522 1.0\n", + "6 y4(t-1) y1(t) 0.438051 1.0\n", + "0 y4(t-1) y2(t) 0.377029 1.0\n", + "14 y3(t-1) y0(t) 0.375119 1.0\n", + "4 y3(t-1) y4(t) 0.343541 1.0" ] }, - "execution_count": 17, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -1082,7 +1112,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -1114,39 +1144,39 @@ " \n", " \n", " \n", - " 11\n", - " y3(t-1)\n", + " 0\n", + " y4(t-1)\n", " y2(t)\n", - " 0.282825\n", + " 0.377029\n", " 1.00\n", " \n", " \n", - " 12\n", - " y1(t-1)\n", + " 5\n", + " y0(t-1)\n", " y2(t)\n", - " 0.378391\n", + " -0.254723\n", " 1.00\n", " \n", " \n", - " 13\n", - " y0(t-1)\n", + " 18\n", + " y1(t-1)\n", " y2(t)\n", - " -0.306198\n", - " 1.00\n", + " 0.329416\n", + " 0.99\n", " \n", " \n", - " 14\n", - " y4(t-1)\n", + " 23\n", + " y3(t-1)\n", " y2(t)\n", - " 0.421177\n", - " 1.00\n", + " 0.184045\n", + " 0.97\n", " \n", " \n", - " 31\n", + " 32\n", " y2(t-1)\n", " y2(t)\n", - " -0.013958\n", - " 0.87\n", + " -0.052064\n", + " 0.19\n", " \n", " \n", "\n", @@ -1154,14 +1184,14 @@ ], "text/plain": [ " from to effect probability\n", - "11 y3(t-1) y2(t) 0.282825 1.00\n", - "12 y1(t-1) y2(t) 0.378391 1.00\n", - "13 y0(t-1) y2(t) -0.306198 1.00\n", - "14 y4(t-1) y2(t) 0.421177 1.00\n", - "31 y2(t-1) y2(t) -0.013958 0.87" + "0 y4(t-1) y2(t) 0.377029 1.00\n", + "5 y0(t-1) y2(t) -0.254723 1.00\n", + "18 y1(t-1) y2(t) 0.329416 0.99\n", + "23 y3(t-1) y2(t) 0.184045 0.97\n", + "32 y2(t-1) y2(t) -0.052064 0.19" ] }, - "execution_count": 18, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -1179,25 +1209,25 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(array([ 1., 0., 2., 6., 16., 25., 27., 14., 6., 3.]),\n", - " array([-0.458, -0.433, -0.408, -0.382, -0.357, -0.332, -0.307, -0.281,\n", - " -0.256, -0.231, -0.205]),\n", + "(array([ 1., 5., 5., 7., 24., 13., 17., 11., 13., 4.]),\n", + " array([-0.359, -0.34 , -0.322, -0.303, -0.285, -0.266, -0.248, -0.229,\n", + " -0.21 , -0.192, -0.173]),\n", " )" ] }, - "execution_count": 19, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" }, { "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEBCAYAAABysL6vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAEEBJREFUeJzt3X2MZfVdx/H3zO6ys2VnI45DdylQNHS/0AeBtNsmZQG1SAIFV4KUQJU28pi2EczSqhGkNCqJBCRBN9XKUlJCIWV5yLJFURYMT2JRkFjgKwpYkTWuU8LuEvZxxj/umXZ2u7Nzn++d37xfyYZ7zz3n/n5fzrmfOfM75/5mYGJiAklSeQZ73QFJUmcY8JJUKANekgplwEtSoQx4SSqUAS9JhTLgJalQBrwkFcqAl6RCGfCSVCgDXpIKNb8HbS4EVgCbgD09aF+SZqN5wDLge8COejboRcCvAB7vQbuSVIKTgCfqWbEXAb8J4K233mF8vHMzWY6MLGZsb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vfX3cD7IuLlUbsp3anAPb2ssTqa+zVq/fXUXt9+B7/4LILD6HM/7qPGoRmPjWocpvG4j34cmvG4gJ6ORyjgXjQR8VrgBmqXKj0JvD8zn42Ii4FDMvMz1Zzc3OVU24G1mXl/RKxkzyVfs8DvZ+a9secyq3dXzXwiM781oBp/VG33v3W7PJ/aDd7WU7saYBS4MjNvGVCNDfsralcQfJTavxb/ODO/2qsaqV3Z8wy1S8yerdv0jMx8OiLWAz/OzGvr9rmUPvbjvmoEtjEE43GBGu9mCMbjAjVuZgjGY2Z+pm7dU4DPZuYpdct6Ph4XfcBLkua3qKdoJEmNGfCSVCgDXpIKZcBLUqEMeEkqlAEvSYUy4CWpUAa8JBXq/wFFIXQfzF+JagAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] diff --git a/lingam/__init__.py b/lingam/__init__.py index d226f6c..cf83709 100644 --- a/lingam/__init__.py +++ b/lingam/__init__.py @@ -3,20 +3,19 @@ The LiNGAM Project: https://sites.google.com/site/sshimizu06/lingam """ -from .ica_lingam import ICALiNGAM +from .bootstrap import BootstrapResult, LongitudinalBootstrapResult +from .bottom_up_parce_lingam import BottomUpParceLiNGAM +from .causal_effect import CausalEffect from .direct_lingam import DirectLiNGAM -from .bootstrap import BootstrapResult +from .ica_lingam import ICALiNGAM +from .longitudinal_lingam import LongitudinalLiNGAM from .multi_group_direct_lingam import MultiGroupDirectLiNGAM -from .causal_effect import CausalEffect +from .rcd import RCD from .var_lingam import VARLiNGAM from .varma_lingam import VARMALiNGAM -from .longitudinal_lingam import LongitudinalLiNGAM -from .bootstrap import LongitudinalBootstrapResult -from .bottom_up_parce_lingam import BottomUpParceLiNGAM -from .rcd import RCD __all__ = ['ICALiNGAM', 'DirectLiNGAM', 'BootstrapResult', 'MultiGroupDirectLiNGAM', 'CausalEffect', 'VARLiNGAM', 'VARMALiNGAM', 'LongitudinalLiNGAM', 'LongitudinalBootstrapResult', 'BottomUpParceLiNGAM', 'RCD'] -__version__ = '1.5.0' +__version__ = '1.5.1' diff --git a/lingam/base.py b/lingam/base.py index 834b467..a55804b 100644 --- a/lingam/base.py +++ b/lingam/base.py @@ -3,6 +3,7 @@ The LiNGAM Project: https://sites.google.com/site/sshimizu06/lingam """ +import itertools import warnings from abc import ABCMeta, abstractmethod @@ -11,6 +12,7 @@ from sklearn.utils import check_array from .bootstrap import BootstrapMixin +from .hsic import hsic_test_gamma from .utils import predict_adaptive_lasso @@ -71,7 +73,7 @@ def estimate_total_effect(self, X, from_index, to_index): from_order = self._causal_order.index(from_index) to_order = self._causal_order.index(to_index) if from_order > to_order: - warnings.warn(f'The estimated causal effect may be incorrect because ' + warnings.warn(f'The estimated causal effect may be incorrect because ' f'the causal order of the destination variable (to_index={to_index}) ' f'is earlier than the source variable (from_index={from_index}).') @@ -81,10 +83,38 @@ def estimate_total_effect(self, X, from_index, to_index): predictors.extend(parents) # Estimate total effect - lr = LinearRegression() - lr.fit(X[:, predictors], X[:, to_index]) + coefs = predict_adaptive_lasso(X, predictors, to_index) - return lr.coef_[0] + return coefs[0] + + def get_error_independence_p_values(self, X): + """Calculate the p-value matrix of independence between error variables. + + Parameters + ---------- + X : array-like, shape (n_samples, n_features) + Original data, where n_samples is the number of samples + and n_features is the number of features. + + Returns + ------- + independence_p_values : array-like, shape (n_features, n_features) + p-value matrix of independence between error variables. + """ + # Check parameters + X = check_array(X) + n_samples = X.shape[0] + n_features = X.shape[1] + + E = X - np.dot(self._adjacency_matrix, X.T).T + p_values = np.zeros([n_features, n_features]) + for i, j in itertools.combinations(range(n_features), 2): + _, p_value = hsic_test_gamma(np.reshape(E[:, i], [n_samples, 1]), + np.reshape(E[:, j], [n_samples, 1])) + p_values[i, j] = p_value + p_values[j, i] = p_value + + return p_values def _estimate_adjacency_matrix(self, X): """Estimate adjacency matrix by causal order. diff --git a/lingam/bottom_up_parce_lingam.py b/lingam/bottom_up_parce_lingam.py index 995fcb5..ec93817 100644 --- a/lingam/bottom_up_parce_lingam.py +++ b/lingam/bottom_up_parce_lingam.py @@ -3,18 +3,19 @@ The LiNGAM Project: https://sites.google.com/site/sshimizu06/lingam """ +import itertools import numbers import warnings import numpy as np -from sklearn.utils import check_array, resample -from sklearn.linear_model import LinearRegression from scipy.stats import gamma from scipy.stats.distributions import chi2 -from .utils import predict_adaptive_lasso -from .hsic import hsic_test_gamma +from sklearn.linear_model import LinearRegression +from sklearn.utils import check_array, resample from .bootstrap import BootstrapResult +from .hsic import hsic_test_gamma +from .utils import predict_adaptive_lasso class BottomUpParceLiNGAM(): @@ -144,14 +145,17 @@ def _find_exo_vec(self, X, U): if self._reg is None: # Compute residuals of least square regressions - coef = np.dot(np.linalg.pinv(cov[np.ix_(xi_index, xi_index)]), cov[np.ix_(xj_index, xi_index)].reshape(xi_index.shape[0], 1)) + coef = np.dot(np.linalg.pinv(cov[np.ix_(xi_index, xi_index)]), cov[np.ix_( + xj_index, xi_index)].reshape(xi_index.shape[0], 1)) R = X[:, xj_index] - np.dot(X[:, xi_index], coef) else: self._reg.fit(X[:, xi_index], np.ravel(X[:, xj_index])) - R = X[:, xj_index] - self._reg.predict(X[:, xi_index]).reshape(-1, 1) + R = X[:, xj_index] - \ + self._reg.predict(X[:, xi_index]).reshape(-1, 1) # HSIC test with Fisher's method - fisher_p, fisher_stat = self._fisher_hsic_test(X[:, xi_index], R, max_p_stat) + fisher_p, fisher_stat = self._fisher_hsic_test( + X[:, xi_index], R, max_p_stat) # Update output if fisher_stat < max_p_stat or fisher_p > max_p: @@ -272,10 +276,44 @@ def estimate_total_effect(self, X, from_index, to_index): predictors.extend(parents) # Estimate total effect - lr = LinearRegression() - lr.fit(X[:, predictors], X[:, to_index]) + coefs = predict_adaptive_lasso(X, predictors, to_index) + + return coefs[0] + + def get_error_independence_p_values(self, X): + """Calculate the p-value matrix of independence between error variables. + + Parameters + ---------- + X : array-like, shape (n_samples, n_features) + Original data, where n_samples is the number of samples + and n_features is the number of features. + + Returns + ------- + independence_p_values : array-like, shape (n_features, n_features) + p-value matrix of independence between error variables. + """ + # Check parameters + X = check_array(X) + n_samples = X.shape[0] + n_features = X.shape[1] + + E = X - np.dot(self._adjacency_matrix, X.T).T + nan_cols = list( + set(np.argwhere(np.isnan(self._adjacency_matrix)).ravel())) + p_values = np.zeros([n_features, n_features]) + for i, j in itertools.combinations(range(n_features), 2): + if i in nan_cols or j in nan_cols: + p_values[i, j] = np.nan + p_values[j, i] = np.nan + else: + _, p_value = hsic_test_gamma(np.reshape(E[:, i], [n_samples, 1]), + np.reshape(E[:, j], [n_samples, 1])) + p_values[i, j] = p_value + p_values[j, i] = p_value - return lr.coef_[0] + return p_values @property def causal_order_(self): diff --git a/lingam/longitudinal_lingam.py b/lingam/longitudinal_lingam.py index 83a4bc6..78ab74d 100644 --- a/lingam/longitudinal_lingam.py +++ b/lingam/longitudinal_lingam.py @@ -2,6 +2,7 @@ Python implementation of the LiNGAM algorithms. The LiNGAM Project: https://sites.google.com/site/sshimizu06/lingam """ +import itertools import numbers import warnings @@ -11,6 +12,7 @@ from .bootstrap import LongitudinalBootstrapResult from .direct_lingam import DirectLiNGAM +from .hsic import hsic_test_gamma from .utils import predict_adaptive_lasso @@ -60,7 +62,8 @@ def fit(self, X_list): raise ValueError('X_list must be a array-like.') if len(X_list) < 2: - raise ValueError('X_list must be a list containing at least two items') + raise ValueError( + 'X_list must be a list containing at least two items') self._T = len(X_list) self._n = check_array(X_list[0]).shape[0] @@ -77,7 +80,8 @@ def fit(self, X_list): B_tau = self._estimate_lagged_effects(B_t, M_tau) # output B(t,t), B(t,t-τ) - self._adjacency_matrices = np.empty((self._T, 1+self._n_lags, self._p, self._p)) + self._adjacency_matrices = np.empty( + (self._T, 1+self._n_lags, self._p, self._p)) self._adjacency_matrices[:, :] = np.nan for t in range(1, self._T): self._adjacency_matrices[t, 0] = B_t[t] @@ -86,6 +90,9 @@ def fit(self, X_list): continue self._adjacency_matrices[t, l+1] = B_tau[t, l] + self._residuals = np.zeros((self._T, self._n, self._p)) + for t in range(self._T): + self._residuals[t] = N_t[t].T self._causal_orders = causal_orders return self @@ -111,7 +118,8 @@ def bootstrap(self, X_list, n_sampling, start_from_t=1): raise ValueError('X_list must be a array-like.') if len(X_list) < 2: - raise ValueError('X_list must be a list containing at least two items') + raise ValueError( + 'X_list must be a list containing at least two items') self._T = len(X_list) self._n = check_array(X_list[0]).shape[0] @@ -124,8 +132,10 @@ def bootstrap(self, X_list, n_sampling, start_from_t=1): X_t.append(X) # Bootstrapping - adjacency_matrices = np.zeros((n_sampling, self._T, 1+self._n_lags, self._p, self._p)) - total_effects = np.zeros((n_sampling, self._T*self._p, self._T*self._p)) + adjacency_matrices = np.zeros( + (n_sampling, self._T, 1+self._n_lags, self._p, self._p)) + total_effects = np.zeros( + (n_sampling, self._T*self._p, self._T*self._p)) for i in range(n_sampling): resampled_X_t = np.empty((self._T, self._n, self._p)) indices = np.random.randint(0, self._n, size=(self._n,)) @@ -177,11 +187,11 @@ def estimate_total_effect(self, X_t, from_t, from_index, to_t, to_index): from_order = self._causal_orders[to_t].index(from_index) to_order = self._causal_orders[from_t].index(to_index) if from_order > to_order: - warnings.warn(f'The estimated causal effect may be incorrect because ' + warnings.warn(f'The estimated causal effect may be incorrect because ' f'the causal order of the destination variable (to_t={to_t}, to_index={to_index}) ' f'is earlier than the source variable (from_t={from_t}, from_index={from_index}).') elif to_t < from_t: - warnings.warn(f'The estimated causal effect may be incorrect because ' + warnings.warn(f'The estimated causal effect may be incorrect because ' f'the causal order of the destination variable (to_t={to_t}) ' f'is earlier than the source variable (from_t={from_t}).') @@ -201,15 +211,42 @@ def estimate_total_effect(self, X_t, from_t, from_index, to_t, to_index): predictors.extend(parents + self._p) # Estimate total effect - lr = LinearRegression() - lr.fit(X_joined[:, predictors], X_joined[:, to_index]) + coefs = predict_adaptive_lasso(X_joined, predictors, to_index) + + return coefs[0] + + def get_error_independence_p_values(self): + """Calculate the p-value matrix of independence between error variables. + + Returns + ------- + independence_p_values : array-like, shape (n_features, n_features) + p-value matrix of independence between error variables. + """ + E_list = np.empty((self._T, self._n, self._p)) + for t, resid in enumerate(self.residuals_): + B_t = self._adjacency_matrices[t, 0] + E_list[t] = np.dot(np.eye(B_t.shape[0]) - B_t, resid.T).T + + p_values_list = np.zeros([self._T, self._p, self._p]) + p_values_list[:, :, :] = np.nan + for t in range(1, self._T): + p_values = np.zeros([self._p, self._p]) + for i, j in itertools.combinations(range(self._p), 2): + _, p_value = hsic_test_gamma(np.reshape(E_list[t][:, i], [self._n, 1]), + np.reshape(E_list[t][:, j], [self._n, 1])) + p_values[i, j] = p_value + p_values[j, i] = p_value - return lr.coef_[0] + p_values_list[t] = p_values + + return p_values_list def _compute_residuals(self, X_t): """Compute residuals N(t)""" M_tau = np.zeros((self._T, self._n_lags, self._p, self._p)) N_t = np.zeros((self._T, self._p, self._n)) + N_t[:, :, :] = np.nan for t in range(1, self._T): # predictors @@ -280,3 +317,17 @@ def adjacency_matrices_(self): such as B(t,t) or B(t,t-τ) at t=0, all elements of the matrix are nan**. """ return self._adjacency_matrices + + @property + def residuals_(self): + """Residuals of regression. + + Returns + ------- + residuals_ : list, shape [E, ...] + Residuals of regression, where ``E`` is an dataset. + The shape of ``E`` is (n_samples, n_features), + where ``n_samples`` is the number of samples and ``n_features`` is the number of features. + + """ + return self._residuals diff --git a/lingam/multi_group_direct_lingam.py b/lingam/multi_group_direct_lingam.py index da91a3e..5177746 100644 --- a/lingam/multi_group_direct_lingam.py +++ b/lingam/multi_group_direct_lingam.py @@ -2,6 +2,7 @@ Python implementation of the LiNGAM algorithms. The LiNGAM Project: https://sites.google.com/site/sshimizu06/lingam """ +import itertools import numbers import warnings @@ -11,6 +12,8 @@ from .bootstrap import BootstrapResult from .direct_lingam import DirectLiNGAM +from .hsic import hsic_test_gamma +from .utils import predict_adaptive_lasso class MultiGroupDirectLiNGAM(DirectLiNGAM): @@ -111,8 +114,10 @@ def bootstrap(self, X_list, n_sampling): raise ValueError('n_sampling must be an integer greater than 0.') # Bootstrapping - adjacency_matrices_list = np.zeros([len(X_list), n_sampling, self._n_features, self._n_features]) - total_effects_list = np.zeros([len(X_list), n_sampling, self._n_features, self._n_features]) + adjacency_matrices_list = np.zeros( + [len(X_list), n_sampling, self._n_features, self._n_features]) + total_effects_list = np.zeros( + [len(X_list), n_sampling, self._n_features, self._n_features]) for n in range(n_sampling): resampled_X_list = [resample(X) for X in X_list] self.fit(resampled_X_list) @@ -123,7 +128,8 @@ def bootstrap(self, X_list, n_sampling): # Calculate total effects for c, from_ in enumerate(self._causal_order): for to in self._causal_order[c+1:]: - effects = self.estimate_total_effect(resampled_X_list, from_, to) + effects = self.estimate_total_effect( + resampled_X_list, from_, to) for i, effect in enumerate(effects): total_effects_list[i, n, to, from_] = effect @@ -159,7 +165,7 @@ def estimate_total_effect(self, X_list, from_index, to_index): from_order = self._causal_order.index(from_index) to_order = self._causal_order.index(to_index) if from_order > to_order: - warnings.warn(f'The estimated causal effect may be incorrect because ' + warnings.warn(f'The estimated causal effect may be incorrect because ' f'the causal order of the destination variable (to_index={to_index}) ' f'is earlier than the source variable (from_index={from_index}).') @@ -172,13 +178,42 @@ def estimate_total_effect(self, X_list, from_index, to_index): predictors.extend(parents) # Estimate total effect - lr = LinearRegression() - lr.fit(X[:, predictors], X[:, to_index]) + coefs = predict_adaptive_lasso(X, predictors, to_index) - effects.append(lr.coef_[0]) + effects.append(coefs[0]) return effects + def get_error_independence_p_values(self, X_list): + """Calculate the p-value matrix of independence between error variables. + + Parameters + ---------- + X_list : array-like, shape (X, ...) + Multiple datasets for training, where ``X`` is an dataset. + The shape of ''X'' is (n_samples, n_features), + where ``n_samples`` is the number of samples and ``n_features`` is the number of features. + + Returns + ------- + independence_p_values : array-like, shape (n_datasets, n_features, n_features) + p-value matrix of independence between error variables. + """ + # Check parameters + X_list = self._check_X_list(X_list) + + p_values = np.zeros([len(X_list), self._n_features, self._n_features]) + for d, (X, am) in enumerate(zip(X_list, self._adjacency_matrices)): + n_samples = X.shape[0] + E = X - np.dot(am, X.T).T + for i, j in itertools.combinations(range(self._n_features), 2): + _, p_value = hsic_test_gamma(np.reshape(E[:, i], [n_samples, 1]), + np.reshape(E[:, j], [n_samples, 1])) + p_values[d, i, j] = p_value + p_values[d, j, i] = p_value + + return p_values + def _check_X_list(self, X_list): """Check input X list.""" if not isinstance(X_list, list): @@ -218,9 +253,12 @@ def _search_causal_order(self, X_list, U): if i != j: xi_std = (X[:, i] - np.mean(X[:, i])) / np.std(X[:, i]) xj_std = (X[:, j] - np.mean(X[:, j])) / np.std(X[:, j]) - ri_j = xi_std if i in Vj and j in Uc else self._residual(xi_std, xj_std) - rj_i = xj_std if j in Vj and i in Uc else self._residual(xj_std, xi_std) - M += np.min([0, self._diff_mutual_info(xi_std, xj_std, ri_j, rj_i)])**2 + ri_j = xi_std if i in Vj and j in Uc else self._residual( + xi_std, xj_std) + rj_i = xj_std if j in Vj and i in Uc else self._residual( + xj_std, xi_std) + M += np.min([0, self._diff_mutual_info(xi_std, + xj_std, ri_j, rj_i)])**2 MG += M * (len(X) / total_size) MG_list.append(-1.0 * MG) return Uc[np.argmax(MG_list)] diff --git a/lingam/rcd.py b/lingam/rcd.py index db86aa4..99382b8 100644 --- a/lingam/rcd.py +++ b/lingam/rcd.py @@ -8,13 +8,15 @@ import warnings import numpy as np -from sklearn.utils import check_array, resample -from sklearn.linear_model import LinearRegression -from scipy.stats import pearsonr, shapiro from scipy.optimize import fmin_l_bfgs_b -from .hsic import get_kernel_width, get_gram_matrix, hsic_teststat, hsic_test_gamma +from scipy.stats import pearsonr, shapiro +from sklearn.linear_model import LinearRegression +from sklearn.utils import check_array, resample from .bootstrap import BootstrapResult +from .hsic import (get_gram_matrix, get_kernel_width, hsic_test_gamma, + hsic_teststat) +from .utils import predict_adaptive_lasso class RCD(): @@ -40,9 +42,9 @@ def __init__(self, max_explanatory_num=2, cor_alpha=0.01, ind_alpha=0.01, shapir shapiro_alpha : float, optional (default=0.01) Alpha level for Shapiro-Wilk test. MLHSICR : bool, optional (default=False) - If True, use MLHSICR for multiple regression, if False, use OLS for multiple regression. + If True, use MLHSICR for multiple regression, if False, use OLS for multiple regression. bw_method : str, optional (default=``mdbs``) - The method used to calculate the bandwidth of the HSIC. + The method used to calculate the bandwidth of the HSIC. * ``mdbs`` : Median distance between samples. * ``scott`` : Scott's Rule of Thumb. @@ -62,7 +64,8 @@ def __init__(self, max_explanatory_num=2, cor_alpha=0.01, ind_alpha=0.01, shapir raise ValueError('shapiro_alpha must be >= 0.') if bw_method not in ('mdbs', 'scott', 'silverman'): - raise ValueError("bw_method must be 'mdbs', 'scott' or 'silverman'.") + raise ValueError( + "bw_method must be 'mdbs', 'scott' or 'silverman'.") self._max_explanatory_num = max_explanatory_num self._cor_alpha = cor_alpha @@ -181,7 +184,8 @@ def sum_empirical_hsic(coef): return objective # Estimate coefficients by minimizing the sum of HSICs using the L-BFGS method. - coefs, _, _ = fmin_l_bfgs_b(func=sum_empirical_hsic, x0=initial_coef, approx_grad=True) + coefs, _, _ = fmin_l_bfgs_b( + func=sum_empirical_hsic, x0=initial_coef, approx_grad=True) resid = Y[:, xi] for j, xj in enumerate(xj_list): @@ -390,10 +394,44 @@ def estimate_total_effect(self, X, from_index, to_index): predictors.extend(parents) # Estimate total effect - lr = LinearRegression() - lr.fit(X[:, predictors], X[:, to_index]) + coefs = predict_adaptive_lasso(X, predictors, to_index) + + return coefs[0] + + def get_error_independence_p_values(self, X): + """Calculate the p-value matrix of independence between error variables. + + Parameters + ---------- + X : array-like, shape (n_samples, n_features) + Original data, where n_samples is the number of samples + and n_features is the number of features. + + Returns + ------- + independence_p_values : array-like, shape (n_features, n_features) + p-value matrix of independence between error variables. + """ + # Check parameters + X = check_array(X) + n_samples = X.shape[0] + n_features = X.shape[1] + + E = X - np.dot(self._adjacency_matrix, X.T).T + nan_cols = list( + set(np.argwhere(np.isnan(self._adjacency_matrix)).ravel())) + p_values = np.zeros([n_features, n_features]) + for i, j in itertools.combinations(range(n_features), 2): + if i in nan_cols or j in nan_cols: + p_values[i, j] = np.nan + p_values[j, i] = np.nan + else: + _, p_value = hsic_test_gamma(np.reshape(E[:, i], [n_samples, 1]), + np.reshape(E[:, j], [n_samples, 1])) + p_values[i, j] = p_value + p_values[j, i] = p_value - return lr.coef_[0] + return p_values @property def ancestors_list_(self): @@ -450,7 +488,8 @@ def bootstrap(self, X, n_sampling): adjacency_matrices = np.zeros([n_sampling, X.shape[1], X.shape[1]]) total_effects = np.zeros([n_sampling, X.shape[1], X.shape[1]]) for i in range(n_sampling): - self.fit(resample(X, replace=False, n_samples=X.shape[0] - n_sampling)) + self.fit(resample(X, replace=False, + n_samples=X.shape[0] - n_sampling)) adjacency_matrices[i] = self._adjacency_matrix # Calculate total effects diff --git a/lingam/var_lingam.py b/lingam/var_lingam.py index a4542b5..5b4dec6 100644 --- a/lingam/var_lingam.py +++ b/lingam/var_lingam.py @@ -2,6 +2,7 @@ Python implementation of the LiNGAM algorithms. The LiNGAM Project: https://sites.google.com/site/sshimizu06/lingam """ +import itertools import warnings import numpy as np @@ -12,6 +13,8 @@ from .base import _BaseLiNGAM from .bootstrap import BootstrapResult from .direct_lingam import DirectLiNGAM +from .hsic import hsic_test_gamma +from .utils import predict_adaptive_lasso class VARLiNGAM: @@ -46,7 +49,8 @@ def __init__(self, lags=1, criterion='bic', prune=False, ar_coefs=None, lingam_m self._lags = lags self._criterion = criterion self._prune = prune - self._ar_coefs = check_array(ar_coefs, allow_nd=True) if ar_coefs is not None else None + self._ar_coefs = check_array( + ar_coefs, allow_nd=True) if ar_coefs is not None else None self._lingam_model = lingam_model self._random_state = random_state @@ -196,7 +200,7 @@ def estimate_total_effect(self, X, from_index, to_index, from_lag=0): from_order = self._causal_order.index(from_index) to_order = self._causal_order.index(to_index) if from_order > to_order: - warnings.warn(f'The estimated causal effect may be incorrect because ' + warnings.warn(f'The estimated causal effect may be incorrect because ' f'the causal order of the destination variable (to_index={to_index}) ' f'is earlier than the source variable (from_index={from_index}).') @@ -217,10 +221,32 @@ def estimate_total_effect(self, X, from_index, to_index, from_lag=0): predictors.extend(parents) # estimate total effect - lr = LinearRegression() - lr.fit(X_joined[:, predictors], X_joined[:, to_index]) + coefs = predict_adaptive_lasso(X_joined, predictors, to_index) - return lr.coef_[0] + return coefs[0] + + def get_error_independence_p_values(self): + """Calculate the p-value matrix of independence between error variables. + + Returns + ------- + independence_p_values : array-like, shape (n_features, n_features) + p-value matrix of independence between error variables. + """ + nn = self.residuals_ + B0 = self._adjacency_matrices[0] + E = np.dot(np.eye(B0.shape[0]) - B0, nn.T).T + n_samples = E.shape[0] + n_features = E.shape[1] + + p_values = np.zeros([n_features, n_features]) + for i, j in itertools.combinations(range(n_features), 2): + _, p_value = hsic_test_gamma(np.reshape(E[:, i], [n_samples, 1]), + np.reshape(E[:, j], [n_samples, 1])) + p_values[i, j] = p_value + p_values[j, i] = p_value + + return p_values def _estimate_var_coefs(self, X): """Estimate coefficients of VAR""" @@ -256,7 +282,8 @@ def _calc_residuals(self, X, M_taus, lags): estimated = np.zeros((X.shape[0], 1)) for tau in range(1, lags + 1): - estimated += np.dot(M_taus[tau - 1], X[:, t - tau].reshape((-1, 1))) + estimated += np.dot(M_taus[tau - 1], + X[:, t - tau].reshape((-1, 1))) residuals[:, t] = X[:, t] - estimated.reshape((-1,)) @@ -290,10 +317,12 @@ def _pruning(self, X, B_taus, causal_order): ancestor_indexes = causal_order[:causal_order_no] obj = np.zeros((len(blocks))) - exp = np.zeros((len(blocks), causal_order_no + n_features * self._lags)) + exp = np.zeros( + (len(blocks), causal_order_no + n_features * self._lags)) for j, block in enumerate(blocks): obj[j] = block[0][i] - exp[j:] = np.concatenate([block[0][ancestor_indexes].flatten(), block[1:][:].flatten()], axis=0) + exp[j:] = np.concatenate( + [block[0][ancestor_indexes].flatten(), block[1:][:].flatten()], axis=0) # adaptive lasso gamma = 1.0 @@ -306,7 +335,8 @@ def _pruning(self, X, B_taus, causal_order): B_taus[0][i, ancestor_indexes] = coef[:causal_order_no] for j in range(len(B_taus[1:])): - B_taus[j + 1][i, :] = coef[causal_order_no + n_features * j: causal_order_no + n_features * j + n_features] + B_taus[j + 1][i, :] = coef[causal_order_no + n_features * + j: causal_order_no + n_features * j + n_features] return B_taus diff --git a/lingam/varma_lingam.py b/lingam/varma_lingam.py index fc32a25..cb10c96 100644 --- a/lingam/varma_lingam.py +++ b/lingam/varma_lingam.py @@ -2,6 +2,7 @@ Python implementation of the LiNGAM algorithms. The LiNGAM Project: https://sites.google.com/site/sshimizu06/lingam """ +import itertools import warnings import numpy as np @@ -12,6 +13,8 @@ from .base import _BaseLiNGAM from .bootstrap import BootstrapResult from .direct_lingam import DirectLiNGAM +from .hsic import hsic_test_gamma +from .utils import predict_adaptive_lasso class VARMALiNGAM: @@ -177,7 +180,8 @@ def bootstrap(self, X, n_sampling): am = np.concatenate([*psi, *omega], axis=1) adjacency_matrices.append(am) - ee = np.dot(np.eye(psi[0].shape[0]) - psi[0], sampled_residuals.T).T + ee = np.dot(np.eye(psi[0].shape[0]) - + psi[0], sampled_residuals.T).T # total effects for c, to in enumerate(reversed(self._causal_order)): @@ -225,7 +229,7 @@ def estimate_total_effect(self, X, E, from_index, to_index, from_lag=0): from_order = self._causal_order.index(from_index) to_order = self._causal_order.index(to_index) if from_order > to_order: - warnings.warn(f'The estimated causal effect may be incorrect because ' + warnings.warn(f'The estimated causal effect may be incorrect because ' f'the causal order of the destination variable (to_index={to_index}) ' f'is earlier than the source variable (from_index={from_index}).') @@ -256,10 +260,32 @@ def estimate_total_effect(self, X, E, from_index, to_index, from_lag=0): predictors.extend(parents) # Estimate total effect - lr = LinearRegression() - lr.fit(X_joined[:, predictors], X_joined[:, to_index]) + coefs = predict_adaptive_lasso(X_joined, predictors, to_index) - return lr.coef_[0] + return coefs[0] + + def get_error_independence_p_values(self): + """Calculate the p-value matrix of independence between error variables. + + Returns + ------- + independence_p_values : array-like, shape (n_features, n_features) + p-value matrix of independence between error variables. + """ + eps = self.residuals_ + psi0 = self._adjacency_matrices[0][0] + E = np.dot(np.eye(psi0.shape[0]) - psi0, eps.T).T + n_samples = E.shape[0] + n_features = E.shape[1] + + p_values = np.zeros([n_features, n_features]) + for i, j in itertools.combinations(range(n_features), 2): + _, p_value = hsic_test_gamma(np.reshape(E[:, i], [n_samples, 1]), + np.reshape(E[:, j], [n_samples, 1])) + p_values[i, j] = p_value + p_values[j, i] = p_value + + return p_values def _estimate_varma_coefs(self, X): if self._criterion not in ['aic', 'bic', 'hqic']: @@ -269,7 +295,8 @@ def _estimate_varma_coefs(self, X): min_value = float('Inf') result = None - orders = [(p, q) for p in range(self._order[0] + 1) for q in range(self._order[1] + 1)] + orders = [(p, q) for p in range(self._order[0] + 1) + for q in range(self._order[1] + 1)] orders.remove((0, 0)) for order in orders: @@ -318,7 +345,8 @@ def _calc_psi_and_omega(self, psi0, phis, thetas, order): omegas = [] for j in range(order[1]): - omega = np.dot(np.eye(psi0.shape[0]) - psi0, thetas[j], np.linalg.inv(np.eye(psi0.shape[0]) - psi0)) + omega = np.dot(np.eye( + psi0.shape[0]) - psi0, thetas[j], np.linalg.inv(np.eye(psi0.shape[0]) - psi0)) omegas.append(omega) return np.array(psis), np.array(omegas) @@ -331,11 +359,13 @@ def _pruning(self, X, ee, order, causal_order): X_joined = np.zeros((X.shape[0], X.shape[1]*(1+order[0]+order[1]))) for p in range(1+order[0]): pos = n_features * p - X_joined[:, pos:pos + n_features] = np.roll(X[:, 0:n_features], p, axis=0) + X_joined[:, pos:pos + + n_features] = np.roll(X[:, 0:n_features], p, axis=0) for q in range(order[1]): pos = n_features * (1+order[0]) + n_features * q - X_joined[:, pos:pos + n_features] = np.roll(ee[:, 0:n_features], q+1, axis=0) + X_joined[:, pos:pos + + n_features] = np.roll(ee[:, 0:n_features], q+1, axis=0) # pruned by adaptive lasso psi_omega = np.zeros((n_features, n_features*(1+order[0]+order[1])))