reconnect moved files to git repo

This commit is contained in:
root
2025-08-01 04:33:03 -04:00
commit 5d3c35492d
23190 changed files with 4750716 additions and 0 deletions

View File

@ -0,0 +1,39 @@
food,income,persons
15.998,62.476,1
16.652,82.304,5
21.741,74.679,3
7.431,39.151,3
10.481,64.724,5
13.548,36.786,3
23.256,83.052,4
17.976,86.935,1
14.161,88.233,2
8.825,38.695,2
14.184,73.831,7
19.604,77.122,3
13.728,45.519,2
21.141,82.251,2
17.446,59.862,3
9.629,26.563,3
14.005,61.818,2
9.16,29.682,1
18.831,50.825,5
7.641,71.062,4
13.882,41.99,4
9.67,37.324,3
21.604,86.352,5
10.866,45.506,2
28.98,69.929,6
10.882,61.041,2
18.561,82.469,1
11.629,44.208,2
18.067,49.467,5
14.539,25.905,5
19.192,79.178,5
25.918,75.811,3
28.833,82.718,6
15.869,48.311,4
14.91,42.494,5
9.55,40.573,4
23.066,44.872,6
14.751,27.167,7
1 food income persons
2 15.998 62.476 1
3 16.652 82.304 5
4 21.741 74.679 3
5 7.431 39.151 3
6 10.481 64.724 5
7 13.548 36.786 3
8 23.256 83.052 4
9 17.976 86.935 1
10 14.161 88.233 2
11 8.825 38.695 2
12 14.184 73.831 7
13 19.604 77.122 3
14 13.728 45.519 2
15 21.141 82.251 2
16 17.446 59.862 3
17 9.629 26.563 3
18 14.005 61.818 2
19 9.16 29.682 1
20 18.831 50.825 5
21 7.641 71.062 4
22 13.882 41.99 4
23 9.67 37.324 3
24 21.604 86.352 5
25 10.866 45.506 2
26 28.98 69.929 6
27 10.882 61.041 2
28 18.561 82.469 1
29 11.629 44.208 2
30 18.067 49.467 5
31 14.539 25.905 5
32 19.192 79.178 5
33 25.918 75.811 3
34 28.833 82.718 6
35 15.869 48.311 4
36 14.91 42.494 5
37 9.55 40.573 4
38 23.066 44.872 6
39 14.751 27.167 7

View File

@ -0,0 +1,37 @@
,Unnamed: 0,gender,age,Basename,ID,id,plate,CpG,methylation
0,0,F,58.231,6042324088_R04C01,age58.231_F,id_0,6042324088,CpG_0,0.815
1,1,M,52.632,6042324088_R06C01,age52.632_M,id_1,6042324088,CpG_0,0.803
2,2,M,64.679,6042324088_R01C01,age64.679_M,id_2,6042324088,CpG_0,0.803
3,3,F,55.299,6042324088_R04C02,age55.299_F,id_3,6042324088,CpG_0,0.808
4,4,M,56.019,6042324088_R02C01,age56.019_M,id_4,6042324088,CpG_0,0.8550000000000001
5,5,M,62.021,6042324088_R01C02,age62.021_M,id_5,6042324088,CpG_0,0.8129999999999998
6,6,F,52.298,6042324088_R06C02,age52.298_F,id_6,6042324088,CpG_0,0.816
7,7,F,39.71,6042324088_R03C01,age39.71_F,id_7,6042324088,CpG_0,0.827
8,8,F,57.492,6042324088_R05C02,age57.492_F,id_8,6042324088,CpG_0,0.829
9,9,F,57.623999999999995,6042324088_R05C01,age57.624_F,id_9,6042324088,CpG_0,0.7760000000000001
10,10,F,40.486999999999995,6042324088_R03C02,age40.487_F,id_10,6042324088,CpG_0,0.7859999999999999
11,11,M,53.662,6042324088_R02C02,age53.662_M,id_11,6042324088,CpG_0,0.822
12,12,F,58.231,6042324088_R04C01,age58.231_F,id_0,6042324088,CpG_1,0.891
13,13,M,52.632,6042324088_R06C01,age52.632_M,id_1,6042324088,CpG_1,0.894
14,14,M,64.679,6042324088_R01C01,age64.679_M,id_2,6042324088,CpG_1,0.894
15,15,F,55.299,6042324088_R04C02,age55.299_F,id_3,6042324088,CpG_1,0.869
16,16,M,56.019,6042324088_R02C01,age56.019_M,id_4,6042324088,CpG_1,0.914
17,17,M,62.021,6042324088_R01C02,age62.021_M,id_5,6042324088,CpG_1,0.889
18,18,F,52.298,6042324088_R06C02,age52.298_F,id_6,6042324088,CpG_1,0.8850000000000001
19,19,F,39.71,6042324088_R03C01,age39.71_F,id_7,6042324088,CpG_1,0.898
20,20,F,57.492,6042324088_R05C02,age57.492_F,id_8,6042324088,CpG_1,0.896
21,21,F,57.623999999999995,6042324088_R05C01,age57.624_F,id_9,6042324088,CpG_1,0.86
22,22,F,40.486999999999995,6042324088_R03C02,age40.487_F,id_10,6042324088,CpG_1,0.887
23,23,M,53.662,6042324088_R02C02,age53.662_M,id_11,6042324088,CpG_1,0.8800000000000001
24,24,F,58.231,6042324088_R04C01,age58.231_F,id_0,6042324088,CpG_2,0.936
25,25,M,52.632,6042324088_R06C01,age52.632_M,id_1,6042324088,CpG_2,0.9129999999999999
26,26,M,64.679,6042324088_R01C01,age64.679_M,id_2,6042324088,CpG_2,0.9000000000000001
27,27,F,55.299,6042324088_R04C02,age55.299_F,id_3,6042324088,CpG_2,0.9119999999999999
28,28,M,56.019,6042324088_R02C01,age56.019_M,id_4,6042324088,CpG_2,0.9349999999999999
29,29,M,62.021,6042324088_R01C02,age62.021_M,id_5,6042324088,CpG_2,0.9280000000000002
30,30,F,52.298,6042324088_R06C02,age52.298_F,id_6,6042324088,CpG_2,0.9150000000000001
31,31,F,39.71,6042324088_R03C01,age39.71_F,id_7,6042324088,CpG_2,0.9160000000000001
32,32,F,57.492,6042324088_R05C02,age57.492_F,id_8,6042324088,CpG_2,0.929
33,33,F,57.623999999999995,6042324088_R05C01,age57.624_F,id_9,6042324088,CpG_2,0.92
34,34,F,40.486999999999995,6042324088_R03C02,age40.487_F,id_10,6042324088,CpG_2,0.9160000000000001
35,35,M,53.662,6042324088_R02C02,age53.662_M,id_11,6042324088,CpG_2,0.926
1 Unnamed: 0 gender age Basename ID id plate CpG methylation
2 0 0 F 58.231 6042324088_R04C01 age58.231_F id_0 6042324088 CpG_0 0.815
3 1 1 M 52.632 6042324088_R06C01 age52.632_M id_1 6042324088 CpG_0 0.803
4 2 2 M 64.679 6042324088_R01C01 age64.679_M id_2 6042324088 CpG_0 0.803
5 3 3 F 55.299 6042324088_R04C02 age55.299_F id_3 6042324088 CpG_0 0.808
6 4 4 M 56.019 6042324088_R02C01 age56.019_M id_4 6042324088 CpG_0 0.8550000000000001
7 5 5 M 62.021 6042324088_R01C02 age62.021_M id_5 6042324088 CpG_0 0.8129999999999998
8 6 6 F 52.298 6042324088_R06C02 age52.298_F id_6 6042324088 CpG_0 0.816
9 7 7 F 39.71 6042324088_R03C01 age39.71_F id_7 6042324088 CpG_0 0.827
10 8 8 F 57.492 6042324088_R05C02 age57.492_F id_8 6042324088 CpG_0 0.829
11 9 9 F 57.623999999999995 6042324088_R05C01 age57.624_F id_9 6042324088 CpG_0 0.7760000000000001
12 10 10 F 40.486999999999995 6042324088_R03C02 age40.487_F id_10 6042324088 CpG_0 0.7859999999999999
13 11 11 M 53.662 6042324088_R02C02 age53.662_M id_11 6042324088 CpG_0 0.822
14 12 12 F 58.231 6042324088_R04C01 age58.231_F id_0 6042324088 CpG_1 0.891
15 13 13 M 52.632 6042324088_R06C01 age52.632_M id_1 6042324088 CpG_1 0.894
16 14 14 M 64.679 6042324088_R01C01 age64.679_M id_2 6042324088 CpG_1 0.894
17 15 15 F 55.299 6042324088_R04C02 age55.299_F id_3 6042324088 CpG_1 0.869
18 16 16 M 56.019 6042324088_R02C01 age56.019_M id_4 6042324088 CpG_1 0.914
19 17 17 M 62.021 6042324088_R01C02 age62.021_M id_5 6042324088 CpG_1 0.889
20 18 18 F 52.298 6042324088_R06C02 age52.298_F id_6 6042324088 CpG_1 0.8850000000000001
21 19 19 F 39.71 6042324088_R03C01 age39.71_F id_7 6042324088 CpG_1 0.898
22 20 20 F 57.492 6042324088_R05C02 age57.492_F id_8 6042324088 CpG_1 0.896
23 21 21 F 57.623999999999995 6042324088_R05C01 age57.624_F id_9 6042324088 CpG_1 0.86
24 22 22 F 40.486999999999995 6042324088_R03C02 age40.487_F id_10 6042324088 CpG_1 0.887
25 23 23 M 53.662 6042324088_R02C02 age53.662_M id_11 6042324088 CpG_1 0.8800000000000001
26 24 24 F 58.231 6042324088_R04C01 age58.231_F id_0 6042324088 CpG_2 0.936
27 25 25 M 52.632 6042324088_R06C01 age52.632_M id_1 6042324088 CpG_2 0.9129999999999999
28 26 26 M 64.679 6042324088_R01C01 age64.679_M id_2 6042324088 CpG_2 0.9000000000000001
29 27 27 F 55.299 6042324088_R04C02 age55.299_F id_3 6042324088 CpG_2 0.9119999999999999
30 28 28 M 56.019 6042324088_R02C01 age56.019_M id_4 6042324088 CpG_2 0.9349999999999999
31 29 29 M 62.021 6042324088_R01C02 age62.021_M id_5 6042324088 CpG_2 0.9280000000000002
32 30 30 F 52.298 6042324088_R06C02 age52.298_F id_6 6042324088 CpG_2 0.9150000000000001
33 31 31 F 39.71 6042324088_R03C01 age39.71_F id_7 6042324088 CpG_2 0.9160000000000001
34 32 32 F 57.492 6042324088_R05C02 age57.492_F id_8 6042324088 CpG_2 0.929
35 33 33 F 57.623999999999995 6042324088_R05C01 age57.624_F id_9 6042324088 CpG_2 0.92
36 34 34 F 40.486999999999995 6042324088_R03C02 age40.487_F id_10 6042324088 CpG_2 0.9160000000000001
37 35 35 M 53.662 6042324088_R02C02 age53.662_M id_11 6042324088 CpG_2 0.926

View File

@ -0,0 +1,37 @@
"fittedvalues","pearson","deviance","response","weighted","sweighted","sweighted2"
0.808801783033006,0.35152036037566,0.316277475404175,0.00619821696699407,0.0143437070668562,0.319573728733701,0.339140493550815
0.819372283335466,-1.04578186069401,-1.05384293226473,-0.0163722833354659,-0.0424402211037504,-1.04203526956567,-1.12150619891079
0.819372283335466,-0.848866164111184,-0.868303748623021,-0.0163722833354659,-0.0431126841865535,-0.858858035684054,-0.924509357407569
0.808801783033006,-0.0478403593182754,-0.0740190330766135,-0.000801783033005821,-0.00346030425148218,-0.0811185264757917,-0.086082858454213
0.819372283335466,2.14604894870802,2.23125643431909,0.0356277166645341,0.0991242044217954,2.29487706595179,2.46999256391156
0.819372283335466,-0.345945859185448,-0.379745334132177,-0.00637228333546613,-0.0182042467717062,-0.379769622695936,-0.408782131481404
0.808801783033006,0.452417702358772,0.422868818621262,0.00719821696699408,0.0172535750290291,0.426089629903614,0.452154192998679
0.808801783033006,1.42260123423979,1.43173413510406,0.0181982169669941,0.0471933178688695,1.44999971504468,1.53857262907721
0.808801783033006,1.16025896160801,1.15557258567386,0.0201982169669941,0.0519452178671859,1.17226143527927,1.24402734629728
0.808801783033006,-1.87995098901712,-1.83681386957748,-0.0328017830330057,-0.0799212843345725,-1.79947817362265,-1.90964475994369
0.808801783033006,-1.75862731269533,-1.73276624166304,-0.022801783033006,-0.0563377478383546,-1.70777742849756,-1.81210402283831
0.819372283335466,0.164877426795495,0.125978175853291,0.00262771666453399,0.00542846196158609,0.130924012206529,0.140910550838054
0.885906034257019,0.357336625125062,0.301293672955372,0.00509396574298104,0.0138352538385608,0.30824553489262,0.325442400805389
0.892778886747752,0.096985881228438,0.0257403439859805,0.0012211132522485,0.00184829475110839,0.0453812037053184,0.0482934532444257
0.892778886747752,0.0787239060703272,0.0625155549271173,0.0012211132522485,0.000749754320257284,0.0149360341368548,0.0158983762537736
0.885906034257019,-1.24771994382442,-1.2462075883806,-0.016906034257019,-0.0520827370000992,-1.22095474074702,-1.28901416807562
0.892778886747752,1.58942674175724,1.63373837694379,0.0212211132522485,0.07283953019518,1.68634662254971,1.79466886330034
0.892778886747752,-0.255092478889325,-0.306807633696473,-0.00377888674775151,-0.0148849956658763,-0.31052475055691,-0.330511444147795
0.885906034257019,-0.0704363879176134,-0.108791198935213,-0.000906034257018851,-0.00482003763451928,-0.119034347858826,-0.125664526445956
0.885906034257019,1.16939404467676,1.16572330650475,0.012093965742981,0.0385653528018314,1.18490822638558,1.25074305918135
0.885906034257019,0.71720205631466,0.678301944285756,0.010093965742981,0.0305419280332159,0.689247747193123,0.727692107851627
0.885906034257019,-1.83648680424447,-1.7784513791609,-0.025906034257019,-0.0765923381476135,-1.72452484855445,-1.82071787157763
0.885906034257019,0.104362993682885,0.0502517218075574,0.00109396574298104,0.00212749934649926,0.0644913135952729,0.068074968576542
0.892778886747752,-0.997002863803822,-1.01348529078318,-0.0127788867477514,-0.0413363208029017,-0.996952176817101,-1.06094759772788
0.918023532863447,1.4614350478071,1.49772318274252,0.0179764671365528,0.0697476840643581,1.55395863587393,1.63670046801479
0.923129550226661,-0.934423619871682,-0.959684761138903,-0.0101295502266615,-0.0383660250384391,-0.942001483577578,-0.99713053437261
0.923129550226661,-1.73188460406476,-1.66782538710199,-0.0231295502266613,-0.0802425599096661,-1.59853112100523,-1.69261746277774
0.918023532863447,-0.515205295487776,-0.5642053296945,-0.00602353286344737,-0.0239176600611151,-0.560692124132005,-0.590510997925376
0.923129550226661,1.03262016372701,1.01116522680603,0.0118704497733385,0.0448548512198665,1.03845846694652,1.09931575827466
0.923129550226661,0.381859782258925,0.301449984612702,0.00487044977333873,0.0150633721746665,0.314245969033599,0.332714652297136
0.918023532863447,-0.272408599341429,-0.324820914964905,-0.00302353286344714,-0.0132867920220962,-0.328127027921809,-0.345558331766231
0.918023532863447,-0.226754579862161,-0.269883188299346,-0.00202353286344714,-0.00888608306610775,-0.273022082268535,-0.287474583737226
0.918023532863447,0.903849126847892,0.869867326874846,0.0109764671365528,0.0394710984913298,0.890754692526278,0.938168842232837
0.918023532863447,0.162379102254773,0.0659862616502334,0.00197646713655275,0.00424246655240526,0.0955218128304648,0.100606642499834
0.918023532863447,-0.223720988594165,-0.26737967038831,-0.00202353286344714,-0.00892954951459952,-0.270683222045707,-0.285014452775087
0.923129550226661,0.260108419658216,0.184475101737707,0.00287044977333861,0.00818026681503129,0.197292227508009,0.20884303478398
1 fittedvalues pearson deviance response weighted sweighted sweighted2
2 0.808801783033006 0.35152036037566 0.316277475404175 0.00619821696699407 0.0143437070668562 0.319573728733701 0.339140493550815
3 0.819372283335466 -1.04578186069401 -1.05384293226473 -0.0163722833354659 -0.0424402211037504 -1.04203526956567 -1.12150619891079
4 0.819372283335466 -0.848866164111184 -0.868303748623021 -0.0163722833354659 -0.0431126841865535 -0.858858035684054 -0.924509357407569
5 0.808801783033006 -0.0478403593182754 -0.0740190330766135 -0.000801783033005821 -0.00346030425148218 -0.0811185264757917 -0.086082858454213
6 0.819372283335466 2.14604894870802 2.23125643431909 0.0356277166645341 0.0991242044217954 2.29487706595179 2.46999256391156
7 0.819372283335466 -0.345945859185448 -0.379745334132177 -0.00637228333546613 -0.0182042467717062 -0.379769622695936 -0.408782131481404
8 0.808801783033006 0.452417702358772 0.422868818621262 0.00719821696699408 0.0172535750290291 0.426089629903614 0.452154192998679
9 0.808801783033006 1.42260123423979 1.43173413510406 0.0181982169669941 0.0471933178688695 1.44999971504468 1.53857262907721
10 0.808801783033006 1.16025896160801 1.15557258567386 0.0201982169669941 0.0519452178671859 1.17226143527927 1.24402734629728
11 0.808801783033006 -1.87995098901712 -1.83681386957748 -0.0328017830330057 -0.0799212843345725 -1.79947817362265 -1.90964475994369
12 0.808801783033006 -1.75862731269533 -1.73276624166304 -0.022801783033006 -0.0563377478383546 -1.70777742849756 -1.81210402283831
13 0.819372283335466 0.164877426795495 0.125978175853291 0.00262771666453399 0.00542846196158609 0.130924012206529 0.140910550838054
14 0.885906034257019 0.357336625125062 0.301293672955372 0.00509396574298104 0.0138352538385608 0.30824553489262 0.325442400805389
15 0.892778886747752 0.096985881228438 0.0257403439859805 0.0012211132522485 0.00184829475110839 0.0453812037053184 0.0482934532444257
16 0.892778886747752 0.0787239060703272 0.0625155549271173 0.0012211132522485 0.000749754320257284 0.0149360341368548 0.0158983762537736
17 0.885906034257019 -1.24771994382442 -1.2462075883806 -0.016906034257019 -0.0520827370000992 -1.22095474074702 -1.28901416807562
18 0.892778886747752 1.58942674175724 1.63373837694379 0.0212211132522485 0.07283953019518 1.68634662254971 1.79466886330034
19 0.892778886747752 -0.255092478889325 -0.306807633696473 -0.00377888674775151 -0.0148849956658763 -0.31052475055691 -0.330511444147795
20 0.885906034257019 -0.0704363879176134 -0.108791198935213 -0.000906034257018851 -0.00482003763451928 -0.119034347858826 -0.125664526445956
21 0.885906034257019 1.16939404467676 1.16572330650475 0.012093965742981 0.0385653528018314 1.18490822638558 1.25074305918135
22 0.885906034257019 0.71720205631466 0.678301944285756 0.010093965742981 0.0305419280332159 0.689247747193123 0.727692107851627
23 0.885906034257019 -1.83648680424447 -1.7784513791609 -0.025906034257019 -0.0765923381476135 -1.72452484855445 -1.82071787157763
24 0.885906034257019 0.104362993682885 0.0502517218075574 0.00109396574298104 0.00212749934649926 0.0644913135952729 0.068074968576542
25 0.892778886747752 -0.997002863803822 -1.01348529078318 -0.0127788867477514 -0.0413363208029017 -0.996952176817101 -1.06094759772788
26 0.918023532863447 1.4614350478071 1.49772318274252 0.0179764671365528 0.0697476840643581 1.55395863587393 1.63670046801479
27 0.923129550226661 -0.934423619871682 -0.959684761138903 -0.0101295502266615 -0.0383660250384391 -0.942001483577578 -0.99713053437261
28 0.923129550226661 -1.73188460406476 -1.66782538710199 -0.0231295502266613 -0.0802425599096661 -1.59853112100523 -1.69261746277774
29 0.918023532863447 -0.515205295487776 -0.5642053296945 -0.00602353286344737 -0.0239176600611151 -0.560692124132005 -0.590510997925376
30 0.923129550226661 1.03262016372701 1.01116522680603 0.0118704497733385 0.0448548512198665 1.03845846694652 1.09931575827466
31 0.923129550226661 0.381859782258925 0.301449984612702 0.00487044977333873 0.0150633721746665 0.314245969033599 0.332714652297136
32 0.918023532863447 -0.272408599341429 -0.324820914964905 -0.00302353286344714 -0.0132867920220962 -0.328127027921809 -0.345558331766231
33 0.918023532863447 -0.226754579862161 -0.269883188299346 -0.00202353286344714 -0.00888608306610775 -0.273022082268535 -0.287474583737226
34 0.918023532863447 0.903849126847892 0.869867326874846 0.0109764671365528 0.0394710984913298 0.890754692526278 0.938168842232837
35 0.918023532863447 0.162379102254773 0.0659862616502334 0.00197646713655275 0.00424246655240526 0.0955218128304648 0.100606642499834
36 0.918023532863447 -0.223720988594165 -0.26737967038831 -0.00202353286344714 -0.00892954951459952 -0.270683222045707 -0.285014452775087
37 0.923129550226661 0.260108419658216 0.184475101737707 0.00287044977333861 0.00818026681503129 0.197292227508009 0.20884303478398

View File

@ -0,0 +1,83 @@
import numpy as np
import os
import pandas as pd
from statsmodels.tools.testing import Holder
cur_dir = os.path.dirname(os.path.abspath(__file__))
results_meth = Holder()
results_meth.type = 'ML'
results_meth.method = 'BFGS'
results_meth.scoring = 3
results_meth.start = np.array([
1.44771372395646, 0.0615237727637243, 0.604926837329731, 0.98389051740736,
6.25859738441389, 0
])
results_meth.n = 36
results_meth.nobs = 36
results_meth.df_null = 34
results_meth.df_residual = 30
results_meth.loglik = 104.148028405343
results_meth.vcov = np.array([
0.00115682165449043, -0.000665413980696048, -0.000924081767589657,
-0.000924126199147583, 0.000941505276523348, -1.44829373972985e-05,
-0.000665413980696048, 0.00190019966824938, 4.45163588328844e-06,
6.23668249663711e-06, -0.00216418558500309, 4.18754929463506e-05,
-0.000924081767589657, 4.45163588328844e-06, 0.0023369966334575,
0.000924223263225116, 0.000168988804218447, 1.14762434349836e-07,
-0.000924126199147583, 6.23668249663711e-06, 0.000924223263225116,
0.00282071714820361, 0.000331499252772628, 1.93773358431975e-07,
0.000941505276523348, -0.00216418558500309, 0.000168988804218447,
0.000331499252772628, 3.20761137509433, -0.0581708456538647,
-1.44829373972985e-05, 4.18754929463506e-05, 1.14762434349836e-07,
1.93773358431975e-07, -0.0581708456538647, 0.00107353277853341
]).reshape(6, 6, order='F')
results_meth.pseudo_r_squared = 0.905194911478503
results_meth.y = np.array([
0.815, 0.803, 0.803, 0.808, 0.855, 0.813, 0.816, 0.827, 0.829, 0.776,
0.786, 0.822, 0.891, 0.894, 0.894, 0.869, 0.914, 0.889, 0.885, 0.898,
0.896, 0.86, 0.887, 0.88, 0.936, 0.913, 0.9, 0.912, 0.935, 0.928, 0.915,
0.916, 0.929, 0.92, 0.916, 0.926
])
# > cat_items(summ_meth, prefix="results_meth.")
# duplicate deleted
results_meth.residuals_type = 'sweighted2'
results_meth.iterations = np.array([
12, 3
])
results_meth.table_mean = np.array([
1.44224319715775, 0.0698572427112336, 0.607345321898288, 0.973547608125426,
0.0340120810079364, 0.0435912797271355, 0.0483424930413969,
0.0531104241011462, 42.4038504677562, 1.60255085761448, 12.5633843785881,
18.3306314080896, 0, 0.109033850726723, 3.35661710796797e-36,
4.71401008973566e-75
]).reshape(4, 4, order='F')
results_meth.table_precision = np.array([
8.22828526376512, -0.0347054296138766, 1.79098056245575,
0.0327648100640521, 4.59429065633335, -1.05922877459173,
4.34223794561173e-06, 0.289495603466561
]).reshape(2, 4, order='F')
results_meth.aic = -196.296056810686
results_meth.bic = -186.79494317995
results_meth.table_mean_oim = np.array([
1.44224320770907, 0.069857238768632, 0.607345313356895, 0.973547591731571,
0.0340453325782864, 0.0435867955242771, 0.0490089283252544,
0.053386889034385, 42.362435567127, 1.60271563734762, 12.3925442590004,
18.2357056075048, 0, 0.108997449531221, 2.86797597854623e-35,
2.68762966306205e-74
]).reshape(4, 4, order='F')
results_meth.table_precision_oim = np.array([
8.22828540005571, -0.0347054322904486, 1.83887205150239,
0.0336205378385678, 4.4746372611042, -1.0322688012039,
7.65411434417314e-06, 0.301946212204644
]).reshape(2, 4, order='F')
results_meth.resid = pd.read_csv(os.path.join(cur_dir,
'resid_methylation.csv'))

View File

@ -0,0 +1,399 @@
import io
import os
import pytest
import numpy as np
from numpy.testing import assert_allclose, assert_equal
import pandas as pd
import patsy
from statsmodels.api import families
from statsmodels.tools.sm_exceptions import (
ValueWarning,
)
from statsmodels.othermod.betareg import BetaModel
from .results import results_betareg as resultsb
links = families.links
cur_dir = os.path.dirname(os.path.abspath(__file__))
res_dir = os.path.join(cur_dir, "results")
# betareg(I(food/income) ~ income + persons, data = FoodExpenditure)
_income_estimates_mean = """\
varname Estimate StdError zvalue Pr(>|z|)
(Intercept) -0.62254806 0.223853539 -2.781051 5.418326e-03
income -0.01229884 0.003035585 -4.051556 5.087819e-05
persons 0.11846210 0.035340667 3.352005 8.022853e-04"""
_income_estimates_precision = """\
varname Estimate StdError zvalue Pr(>|z|)
(phi) 35.60975 8.079598 4.407366 1.046351e-05
"""
_methylation_estimates_mean = """\
varname Estimate StdError zvalue Pr(>|z|)
(Intercept) 1.44224 0.03401 42.404 2e-16
genderM 0.06986 0.04359 1.603 0.109
CpGCpG_1 0.60735 0.04834 12.563 2e-16
CpGCpG_2 0.97355 0.05311 18.331 2e-16"""
_methylation_estimates_precision = """\
varname Estimate StdError zvalue Pr(>|z|)
(Intercept) 8.22829 1.79098 4.594 4.34e-06
age -0.03471 0.03276 -1.059 0.289"""
expected_income_mean = pd.read_table(
io.StringIO(_income_estimates_mean), sep=r"\s+")
expected_income_precision = pd.read_table(
io.StringIO(_income_estimates_precision), sep=r"\s+")
expected_methylation_mean = pd.read_table(
io.StringIO(_methylation_estimates_mean), sep=r"\s+")
expected_methylation_precision = pd.read_table(
io.StringIO(_methylation_estimates_precision), sep=r"\s+")
income = pd.read_csv(os.path.join(res_dir, 'foodexpenditure.csv'))
methylation = pd.read_csv(os.path.join(res_dir, 'methylation-test.csv'))
def check_same(a, b, eps, name):
assert np.allclose(a, b, rtol=0.01, atol=eps), \
("different from expected", name, list(a), list(b))
def assert_close(a, b, eps):
assert np.allclose(a, b, rtol=0.01, atol=eps), (list(a), list(b))
class TestBetaModel:
@classmethod
def setup_class(cls):
model = "I(food/income) ~ income + persons"
cls.income_fit = BetaModel.from_formula(model, income).fit()
model = cls.model = "methylation ~ gender + CpG"
Z = cls.Z = patsy.dmatrix("~ age", methylation)
mod = BetaModel.from_formula(model, methylation, exog_precision=Z,
link_precision=links.Identity())
cls.meth_fit = mod.fit()
mod = BetaModel.from_formula(model, methylation, exog_precision=Z,
link_precision=links.Log())
cls.meth_log_fit = mod.fit()
def test_income_coefficients(self):
rslt = self.income_fit
assert_close(rslt.params[:-1], expected_income_mean['Estimate'], 1e-3)
assert_close(rslt.tvalues[:-1], expected_income_mean['zvalue'], 0.1)
assert_close(rslt.pvalues[:-1], expected_income_mean['Pr(>|z|)'], 1e-3)
def test_income_precision(self):
rslt = self.income_fit
# note that we have to exp the phi results for now.
assert_close(np.exp(rslt.params[-1:]),
expected_income_precision['Estimate'], 1e-3)
# yield check_same, rslt.tvalues[-1:],
# expected_income_precision['zvalue'], 0.1, "z-score"
assert_close(rslt.pvalues[-1:],
expected_income_precision['Pr(>|z|)'], 1e-3)
def test_methylation_coefficients(self):
rslt = self.meth_fit
assert_close(rslt.params[:-2],
expected_methylation_mean['Estimate'], 1e-2)
assert_close(rslt.tvalues[:-2],
expected_methylation_mean['zvalue'], 0.1)
assert_close(rslt.pvalues[:-2],
expected_methylation_mean['Pr(>|z|)'], 1e-2)
def test_methylation_precision(self):
# R results are from log link_precision
rslt = self.meth_log_fit
assert_allclose(rslt.params[-2:],
expected_methylation_precision['Estimate'],
atol=1e-5, rtol=1e-10)
# expected_methylation_precision['Estimate']
# yield check_same, links.logit()(rslt.params[-2:]),
# expected_methylation_precision['Estimate'], 1e-3, "estimate"
# yield check_same, rslt.tvalues[-2:],
# expected_methylation_precision['zvalue'], 0.1, "z-score"
def test_precision_formula(self):
m = BetaModel.from_formula(self.model, methylation,
exog_precision_formula='~ age',
link_precision=links.Identity())
rslt = m.fit()
assert_close(rslt.params, self.meth_fit.params, 1e-10)
assert isinstance(rslt.params, pd.Series)
with pytest.warns(ValueWarning, match="unknown kwargs"):
BetaModel.from_formula(self.model, methylation,
exog_precision_formula='~ age',
link_precision=links.Identity(),
junk=False)
def test_scores(self):
model, Z = self.model, self.Z
for link in (links.Identity(), links.Log()):
mod2 = BetaModel.from_formula(model, methylation, exog_precision=Z,
link_precision=link)
rslt_m = mod2.fit()
# evaluate away from optimum to get larger score
analytical = rslt_m.model.score(rslt_m.params * 1.01)
numerical = rslt_m.model._score_check(rslt_m.params * 1.01)
assert_allclose(analytical, numerical, rtol=1e-6, atol=1e-6)
assert_allclose(link.inverse(analytical[3:]),
link.inverse(numerical[3:]), rtol=5e-7, atol=5e-6)
def test_results_other(self):
rslt = self.meth_fit
distr = rslt.get_distribution()
mean, var = distr.stats()
assert_allclose(rslt.fittedvalues, mean, rtol=1e-13)
assert_allclose(rslt.model._predict_var(rslt.params), var, rtol=1e-13)
resid = rslt.model.endog - mean
assert_allclose(rslt.resid, resid, rtol=1e-12)
assert_allclose(rslt.resid_pearson, resid / np.sqrt(var), rtol=1e-12)
class TestBetaMeth():
@classmethod
def setup_class(cls):
formula = "methylation ~ gender + CpG"
mod = BetaModel.from_formula(formula, methylation,
exog_precision_formula="~ age",
link_precision=links.Log())
cls.res1 = mod.fit(cov_type="eim")
cls.res2 = resultsb.results_meth
def test_basic(self):
res1 = self.res1
res2 = self.res2
k_mean = 4
p, se, zv, pv = res2.table_mean.T
assert_allclose(res1.params[:k_mean], p, rtol=1e-6)
assert_allclose(res1.bse[:k_mean], se, rtol=1e-6)
assert_allclose(res1.tvalues[:k_mean], zv, rtol=1e-6)
assert_allclose(res1.pvalues[:k_mean], pv, rtol=1e-5)
p, se, zv, pv = res2.table_precision.T
assert_allclose(res1.params[k_mean:], p, rtol=1e-6)
assert_allclose(res1.bse[k_mean:], se, rtol=1e-6)
assert_allclose(res1.tvalues[k_mean:], zv, rtol=1e-6)
assert_allclose(res1.pvalues[k_mean:], pv, rtol=1e-5)
assert_allclose(res1.llf, res2.loglik, rtol=1e-10)
assert_allclose(res1.aic, res2.aic, rtol=1e-10)
assert_allclose(res1.bic, res2.bic, rtol=1e-10)
# dofferent definitions for prsquared
assert_allclose(res1.prsquared, res2.pseudo_r_squared, atol=0.01)
assert_equal(res1.df_resid, res2.df_residual)
assert_equal(res1.nobs, res2.nobs)
# null model compared to R betareg and lmtest
df_c = res1.df_resid_null - res1.df_resid
assert_equal(res1.k_null, 2)
# > lrt = lrtest(res_meth_null, res_meth) # results from R
pv = 7.21872953868659e-18
lln = 60.88809589492269
llf = 104.14802840534323
chisq = 86.51986502084107
dfc = 4
# stats.chi2.sf(86.51986502093865, 4)
assert_equal(df_c, dfc)
assert_allclose(res1.llf, llf, rtol=1e-10)
assert_allclose(res1.llnull, lln, rtol=1e-10)
assert_allclose(res1.llr, chisq, rtol=1e-10)
assert_allclose(res1.llr_pvalue, pv, rtol=1e-6)
def test_resid(self):
res1 = self.res1
res2 = self.res2
assert_allclose(res1.fittedvalues, res2.resid['fittedvalues'],
rtol=1e-8)
assert_allclose(res1.resid, res2.resid['response'],
atol=1e-8, rtol=1e-8)
def test_oim(self):
# estimate with default oim, cov_type nonrobust
res1 = self.res1.model.fit()
res2 = self.res2
k_mean = 4
# R betareg uses numerical derivatives from bfgs, has lower precision
p, se, zv, pv = res2.table_mean_oim.T
assert_allclose(res1.params[:k_mean], p, rtol=1e-6)
assert_allclose(res1.bse[:k_mean], se, rtol=1e-5)
assert_allclose(res1.tvalues[:k_mean], zv, rtol=1e-5)
assert_allclose(res1.pvalues[:k_mean], pv, atol=1e-6, rtol=1e-5)
p, se, zv, pv = res2.table_precision_oim.T
assert_allclose(res1.params[k_mean:], p, rtol=1e-6)
assert_allclose(res1.bse[k_mean:], se, rtol=1e-3)
assert_allclose(res1.tvalues[k_mean:], zv, rtol=1e-3)
assert_allclose(res1.pvalues[k_mean:], pv, rtol=1e-2)
def test_predict_distribution(self):
res1 = self.res1
mean = res1.predict()
var_ = res1.model._predict_var(res1.params)
distr = res1.get_distribution()
m2, v2 = distr.stats()
assert_allclose(mean, m2, rtol=1e-13)
assert_allclose(var_, v2, rtol=1e-13)
# from R: > predict(res_meth, type="variance")
var_r6 = [
3.1090848852102e-04, 2.4509604000073e-04, 3.7199753140565e-04,
2.8088261358738e-04, 2.7561111800350e-04, 3.3929220526847e-04]
n = 6
assert_allclose(v2[:n], var_r6, rtol=1e-7)
ex = res1.model.exog[:n]
ex_prec = res1.model.exog_precision[:n]
mean6 = res1.predict(ex, transform=False)
prec = res1.predict(which="precision")
# todo: prec6 wrong exog if not used as keyword, no exception raised
prec6 = res1.predict(exog_precision=ex_prec, which="precision",
transform=False)
var6 = res1.model._predict_var(res1.params, exog=ex,
exog_precision=ex_prec)
assert_allclose(mean6, mean[:n], rtol=1e-13)
assert_allclose(prec6, prec[:n], rtol=1e-13)
assert_allclose(var6, var_[:n], rtol=1e-13)
assert_allclose(var6, var_r6, rtol=1e-7)
distr6 = res1.model.get_distribution(res1.params,
exog=ex, exog_precision=ex_prec)
m26, v26 = distr6.stats()
assert_allclose(m26, m2[:n], rtol=1e-13)
assert_allclose(v26, v2[:n], rtol=1e-13)
distr6f = res1.get_distribution(exog=ex, exog_precision=ex_prec,
transform=False)
m26, v26 = distr6f.stats()
assert_allclose(m26, m2[:n], rtol=1e-13)
assert_allclose(v26, v2[:n], rtol=1e-13)
# check formula transform works for predict, currently mean only
df6 = methylation.iloc[:6]
mean6f = res1.predict(df6)
# todo: prec6 wrong exog if not used as keyword, no exception raised
# formula not supported for exog_precision in predict
# prec6f = res1.predict(exog_precision=ex_prec, which="precision")
assert_allclose(mean6f, mean[:n], rtol=1e-13)
# assert_allclose(prec6f, prec[:n], rtol=1e-13)
distr6f = res1.get_distribution(exog=df6, exog_precision=ex_prec)
m26, v26 = distr6f.stats()
assert_allclose(m26, m2[:n], rtol=1e-13)
assert_allclose(v26, v2[:n], rtol=1e-13)
# check that we don't have pandas in distr
assert isinstance(distr6f.args[0], np.ndarray)
# minimal checks for get_prediction
pma = res1.get_prediction(which="mean", average=True)
dfma = pma.summary_frame()
assert_allclose(pma.predicted, mean.mean(), rtol=1e-13)
assert_equal(dfma.shape, (1, 4))
pm = res1.get_prediction(exog=df6, which="mean", average=False)
dfm = pm.summary_frame()
assert_allclose(pm.predicted, mean6, rtol=1e-13)
assert_equal(dfm.shape, (6, 4))
pv = res1.get_prediction(exog=df6, exog_precision=ex_prec,
which="var", average=False)
dfv = pv.summary_frame()
assert_allclose(pv.predicted, var6, rtol=1e-13)
assert_equal(dfv.shape, (6, 4))
# smoke tests
res1.get_prediction(which="linear", average=False)
res1.get_prediction(which="precision", average=True)
res1.get_prediction(exog_precision=ex_prec, which="precision",
average=False)
res1.get_prediction(which="linear-precision", average=True)
# test agg_weights
pm = res1.get_prediction(exog=df6, which="mean", average=True)
dfm = pm.summary_frame()
aw = np.zeros(len(res1.model.endog))
aw[:6] = 1
aw /= aw.mean()
pm6 = res1.get_prediction(exog=df6, which="mean", average=True)
dfm6 = pm6.summary_frame()
pmw = res1.get_prediction(which="mean", average=True, agg_weights=aw)
dfmw = pmw.summary_frame()
assert_allclose(pmw.predicted, pm6.predicted, rtol=1e-13)
assert_allclose(dfmw, dfm6, rtol=1e-13)
class TestBetaIncome():
@classmethod
def setup_class(cls):
formula = "I(food/income) ~ income + persons"
exog_prec = patsy.dmatrix("~ persons", income)
mod_income = BetaModel.from_formula(
formula,
income,
exog_precision=exog_prec,
link_precision=links.Log()
)
res_income = mod_income.fit(method="newton")
mod_restricted = BetaModel.from_formula(
formula,
income,
link_precision=links.Log()
)
res_restricted = mod_restricted.fit(method="newton")
cls.res1 = res_income
cls.resr = res_restricted
def test_score_test(self):
res1 = self.res1
resr = self.resr
params_restr = np.concatenate([resr.params, [0]])
r_matrix = np.zeros((1, len(params_restr)))
r_matrix[0, -1] = 1
exog_prec_extra = res1.model.exog_precision[:, 1:]
from statsmodels.base._parameter_inference import score_test
sc1 = score_test(res1, params_constrained=params_restr,
k_constraints=1)
sc2 = score_test(resr, exog_extra=(None, exog_prec_extra))
assert_allclose(sc2[:2], sc1[:2])
sc1_hc = score_test(res1, params_constrained=params_restr,
k_constraints=1, r_matrix=r_matrix, cov_type="HC0")
sc2_hc = score_test(resr, exog_extra=(None, exog_prec_extra),
cov_type="HC0")
assert_allclose(sc2_hc[:2], sc1_hc[:2])
def test_influence(self):
# currently only smoke test
res1 = self.res1
from statsmodels.stats.outliers_influence import MLEInfluence
influ0 = MLEInfluence(res1)
influ = res1.get_influence()
attrs = ['cooks_distance', 'd_fittedvalues', 'd_fittedvalues_scaled',
'd_params', 'dfbetas', 'hat_matrix_diag', 'resid_studentized'
]
for attr in attrs:
getattr(influ, attr)
frame = influ.summary_frame()
frame0 = influ0.summary_frame()
assert_allclose(frame, frame0, rtol=1e-13, atol=1e-13)