2D (kde2d) contour plots with conditions - r

I have 4 variables x1,x2 y1,y2 (365 values for each variable). I want to plot the 2d kernel density with specific contour levels. I need to overlay the density plots (x1 vs y1) and (x2 vs y2).
x1 <- c(772.522, 1806.75, 2388.73, 2619.04, 2695.6, 2747.14, 2772.58,
2773.86, 2812.93, 3338.98, 3299.18, 3269.85, 3179.74, 3185.36,
3274.99, 3391.08, 3541.91, 3563.56, 3551.63, 3626.92, 3602.07,
3535.31, 3482.09, 3567.54, 3502.1, 3440.78, 3437.95, 3722.05,
3702.45, 3636.89, 3565.1, 3485.51, 3398.42, 3311, 3231.97, 3129.51,
3055.22, 2968.45, 3435.38, 3605.31, 3468.35, 3845.2, 3858.71,
4388.68, 5056.55, 5601.96, 5968.48, 6033.75, 5938.22, 5807.13,
5671.36, 5612.84, 5475.63, 5329.19, 5179.73, 5239.82, 5264.78,
5553.4, 5478.35, 5352.85, 5227.08, 5213.33, 5160.05, 5399.89,
5554.96, 5592.91, 5541.88, 5517.83, 5614.53, 5522.72, 5410.01,
5289.24, 5154.86, 5014.21, 4868.89, 4732.69, 4608.15, 4457.99,
4299.06, 4142.57, 3991.74, 3841.69, 3695.19, 3552.06, 3436.21,
3308.64, 3178.24, 3056.39, 2938.67, 2824.59, 2714.82, 2610.78,
2515.79, 2424.83, 2346.9, 2274.12, 2202.44, 2132.47, 2068.17,
1986.15, 1905.02, 1828.44, 1754.68, 1685.86, 1621.62, 1560.92,
1504.27, 1450.55, 1400.78, 1352.88, 1304.74, 1257.36, 1219.04,
1213.48, 1202.94, 1423.37, 1542.41, 1494.66, 1482.53, 1599.09,
1544, 1482.98, 1446.54, 1395.88, 1346.6, 1295.43, 1248.17, 1206.5,
1161.74, 1142.75, 1304.01, 1261.43, 1221.17, 1339.85, 1382.48,
1333.32, 1298.32, 1269.32, 1259.52, 1236.89, 1268.37, 1327.74,
1459.69, 1451.84, 1418.96, 1390, 1609.57, 1638.19, 1610.33, 1624.47,
1575.08, 1526.3, 1487.86, 1474.29, 1497.28, 1457.82, 1444.52,
1448.25, 1458.49, 1496.27, 1534.7, 1593.66, 1636.95, 1632.44,
1660.17, 1738.57, 1765.32, 1784.72, 2015.57, 2050.61, 2051.55,
2045.69, 2044.79, 2050.25, 2038.62, 2016.73, 1996.23, 1986.9,
1963.9, 1929.55, 1886.8, 1834.12, 1780.86, 1732.32, 1680.39,
1624.13, 1568.53, 1519.12, 1474.84, 1428.67, 1380.09, 1334.61,
1290.76, 1247.5, 1212.04, 1183.16, 1152.2, 1171.52, 1130.61,
1092.57, 1091.14, 1054.6, 1020.15, 988.19, 1027.7, 1014.29, 979.729,
947.145, 915.957, 1002.37, 1161.34, 1130.55, 1168.49, 1126.99,
1086.23, 1048.46, 1011.48, 976.161, 942.963, 968.045, 1072.01,
1075.4, 1059.16, 1043.81, 1176.16, 1140.94, 1101.78, 1078.93,
1043.95, 1004.95, 968.521, 934.568, 904.955, 878.469, 849.94,
821.994, 795.893, 770.1, 745.538, 722.857, 701.089, 680.118,
660.585, 667.87, 666.708, 646.888, 626.794, 607.768, 591.769,
635.32, 738.938, 717.112, 732.378, 891.413, 1165.41, 1137.85,
1345.26, 1373.03, 1341.85, 1381.03, 1332.81, 1279.92, 1261.64,
1448.94, 1417.41, 1399.06, 1365.79, 1312.99, 1262.5, 1215.59,
1173.54, 1130.01, 1322.27, 1411.67, 1357, 1304.07, 1252.96, 1204.73,
1159.53, 1116, 1081.3, 1042.57, 1003.76, 967.089, 932.187, 897.657,
864.375, 832.293, 801.206, 771.326, 742.13, 716.694, 690.45,
664.076, 639.827, 617.01, 593.567, 570.818, 551.133, 593.432,
833.715, 871.919, 845.388, 865.802, 937.158, 972.532, 1030.36,
1006.08, 974.112, 937.399, 902.049, 872.061, 886.442, 892.396,
859.156, 825.958, 793.783, 762.704, 758.36, 999.93, 967.713,
961.368, 1012.97, 998.855, 1197.95, 1163.77, 1122.32, 1213.45,
1302.05, 1281.74, 1254.06, 1204.14, 1155.98, 1109.55, 1064.83,
1021.78, 980.367, 940.548, 925.483, 1144.38, 1125.92, 1109.17,
1222.15, 1503.71, 2656.42, 2550.13, 2446.94, 2358.74, 2263.33,
2171.81, 2248.6, 2316.71, 2675.05, 3015.03, 3716.48, 4441.43,
4742.74, 5476.79, 5313.57, 5106.1, 5178.79, 5160.45, 5020.48,
4825.68, 4730.04)
y1 <- c(0.127958331257105, 0.010291666626775, 0.0578749990284753, 0.830833333233992,
-0.0829583332330609, -0.217708332619319, 0.172125002286824, 0.232208333676681,
0.235375001948948, 0.0380416669261952, 0.0393333347359051, -0.0440416663574676,
0.162666665079693, -0.0932500026344011, -0.0905833330471069,
-0.305250000208616, 1.0349166871359, 0.334833333579202, -0.0301250003588696,
-0.175166667904705, -0.0697083329238618, 0.824125001827876, -0.532083340920508,
0.233000000123866, 0.0752083340097063, 0.409375000745058, 0.114333332865499,
0.359583331989901, -0.189749999437481, -0.164124998962507, -0.250208334065974,
0.694499998974303, -0.00312500035700699, 0.210833334363997, -0.0586666659607242,
0.305125000498568, 0.188458332403873, -0.101833333649362, 0.09737500102104,
0.273249999930461, -0.0283333340194076, 0.320541665268441, -0.0570416667421038,
-0.16370833478868, 0.0965000004313576, 0.156541665977178, 0.000791666388977319,
-0.17350000096485, 0.204625002418955, -0.175041667728995, -0.776166667540868,
0.0604166665192073, -0.0879583329757831, 0.357666667240361, 0.425541667888562,
-0.0276250006475796, 0.116624999713774, 0.044666666809159, -0.0109583338732288,
0.398333337565418, 0.201500000820185, -0.273708331709107, -0.126250000049671,
0.223624998082717, -0.0117499992872278, -0.0997916681614394,
0.121583334170282, 0.0962499987799674, -0.17191666799287, 0.002666666599301,
-0.340916665426145, 0.132625000396123, 0.32058333295087, 0.254250001162291,
0.372083335435794, -0.0369166672850649, 0.662124995142221, -0.0916666652386387,
0.0278750000870787, 0.0751666669190551, 0.620958338181178, 0.751416672021151,
-0.130499999620952, 0.170041667142262, 0.691666666107873, -0.0391250009512684,
0.294833332921068, -0.0795000011567026, 0.115291667714094, 0.0676250006072223,
0.318208330931763, -0.311458331843217, 0.45366666217645, 0.232166665392773,
0.117749998811632, 0.207750001301368, 0.92275000611941, -0.272541665161649,
0.103125000217309, 0.220291670741669, -0.191500000655651, 1.05833334475756,
0.671833337595065, -0.0487916663405485, -0.0473333336703945,
-0.169916665491958, -0.100500000247848, 0.0271666669577826, -0.10191666687994,
0.0568750000869234, 0.14375000144355, 0.108666666705782, 0.388583331524084,
-0.147958333914479, -0.103041666346447, -0.491375003010035, 0.0465833337899918,
0.286458336282521, 0.00633333355654031, 0.0260416660748888, -0.112708333239425,
-0.548541671286027, 0.0103333332614663, 0.148666666975866, -0.157583331689239,
0.325874996837229, -0.143708332757039, 0.0945833313356464, 0.0853333330742316,
0.313833336035411, -0.352624999048809, -0.136625000392087, -0.29474999755621,
-0.549458327392737, -0.0799166670185514, -0.0107916667620884,
-0.169333333459993, 0.321541666053236, 0.07195833309864, 0.146708333787198,
-0.246458334848285, 0.368250001221895, -0.159666667692363, -0.00275000064478566,
-0.0460416663748523, -0.138958334340714, -0.0874166679180538,
-0.0167500003784274, 0.091583332628943, 0.00845833330337579,
-0.0542083333760578, 0.112666667555459, -0.138541666480402, 0.259916665653388,
0.0581666673533618, -0.134541667697097, 0.525916664550702, 0.0101249999473415,
-0.127000000327826, -0.0889166663400829, -0.190124999731779,
-0.108375000612189, -0.107916666815678, 0.0988750007624428, 0.0848750000974784,
0.0244583335976737, -0.0702916663188565, -0.0600416688297022,
0.0206666665617377, 0.329208332424362, -0.0249166667636018, -0.167916666561117,
0.11137499815474, 0.00529166660271585, -0.412708333383004, 0.155208332464099,
0.322999999547998, -0.153541666455567, -0.0445416663618137, 0.0242500004387693,
-0.115666666689018, 0.0627916665980592, 0.10774999926798, -0.242875003643955,
-0.1862083322679, 0.0298750002645344, -0.059916666985373, -0.0553333335216545,
0.124124999691655, 0.215458335238509, -0.0642499998599912, -0.0367083334034154,
0.203250000505553, -0.0517083338151375, -0.0830416663084179,
-0.033833333698567, 0.272166667544904, 0.294208334758878, -0.234416666751107,
0.0510000000552585, -0.0260000005364418, 0.00383333330197881,
0.214041665196419, 0.212249997537583, -0.0273749998110967, 0.0852083338735004,
-0.133291667327285, -0.15349999970446, -0.0748333332982535, -0.0968749993480742,
0.0880833331029862, 0.190416667843238, -0.00887500051370201,
-0.0115416667006987, 0.149958331448336, -0.274749999245008, -0.0932916667855655,
0.109999999869615, -0.135416666356226, 0.0456666671185909, 0.135458334514018,
-0.073291666728134, 0.0852083340287209, 0.0665000005683396, 0.104958332454165,
-0.0821666670963168, -0.168583333181838, 0.178333333072563, 0.0781666664018606,
-0.175666667210559, -0.0343750003861108, 0.0142083335570836,
-0.0451250005474625, -0.154000000096858, -0.0315833336208016,
-0.0986250000860309, 0.201541664127338, -0.000624999937523777,
-0.0668333338884016, -0.0365833334314326, 0.0162083323860619,
-0.161374998899798, -0.0683333337462197, 0.0342499999824213,
-0.0376666667483126, -0.13674999990811, 0.0712083332861463, -0.0789166667188207,
0.0838333335850621, -0.107625000178814, -0.15395833303531, 0.151750000969817,
0.0107083340020229, 0.0111666666537834, 0.0764583332881254, 0.12216666713357,
-0.135750001917283, -0.139166665884356, -0.0763333337381482,
0.0223750005534384, 0.239708331103126, -0.121791667304933, 0.183583331371968,
-0.173791667446494, -0.00875000042530398, -0.107416666268061,
-0.00929166671994608, 0.0561666658128767, 0.082166666785876,
-0.0237500001627874, -0.048374999819013, 0.17375000162671, -0.15087499966224,
0.187791665395101, -0.0918750003135453, 0.309750000635783, -0.231125000243386,
-0.14383333416481, -0.0552083337291454, -0.121250000433065, 0.202124998904765,
-0.193333331495523, -0.0752083341746281, -0.153416666667908,
-0.0242500006376455, 0.0107499997441967, 0.0742916671248774,
-0.0477500005896824, -0.00087499994939814, -0.120625000757476,
0.22333333392938, 0.0522916664000756, -0.0239999999369805, 0.413791667670012,
0.00141666718991473, 0.162708333072563, 0.0484583335734593, 0.0710833334984879,
0.078208333812654, -0.0702916664692263, -0.108500000399848, -0.180708333849907,
0.123083333640049, 0.0157916666357778, 0.0192083331833904, -0.205250000581145,
0.0680416667601094, 0.0161666665517259, -0.11483333290865, -0.173625001683831,
-0.0131666665741553, -0.130791667072723, 0.209041668102145, -0.0475416670863827,
-0.101625000592321, -0.0217083335834711, 0.0751250004007791,
-0.0733333341777325, 0.0290416674300407, -0.136833332479, -0.0747916662755112,
-0.0304166664670144, 0.0384583333798219, -0.0781250001552204,
0.0489166672729577, 0.000500000169267878, -0.14054166796753,
0.0298750003178914, 0.00916666674796337, 0.0164583334699273,
0.0552083333604969, 0.0388333338196389, 0.359333331075807, 0.205291667332252,
-0.026708333355297, -0.0674583336221986, 0.0282916666183155,
-0.0927500004569689, -0.0379166668280959, -0.0953750004215787,
0.0110416668661249, -0.120208332935969, 0.0384999999660067, -0.0578333336549501,
0.0397500003067156, 0.0279166665568482, -0.0609166669504096,
0.104874998796731, -0.156874999403954, -0.0550833336698512, 0.195958332469066,
0.055291667037333, 0.0537499998608837, 0.145833333333333, 0.0199999999992239,
0.0791666666045785, -0.0392083331826143, 0.306416667997837, -0.00125000059294204,
0.124166667150954, -0.0162083334774555, 0.141874998798206, -0.0859166665468365,
-0.185750000178814, 0.0495833333213037)
x2 <- c(307.991, 460.697, 579.639, 1297.73, 2091.27, 3334.57, 3675.05,
3772.43, 3675.89, 3604.88, 3584.83, 3669.77, 3649.38, 3546.33,
3425.51, 3306.32, 3194.85, 3080.73, 2973.95, 2871.36, 2759.01,
2653.29, 2548.64, 2470.45, 2399.17, 2443.32, 2642.11, 2708.22,
2811.78, 2907.94, 3031.58, 3127.1, 3160.46, 3210.85, 3181.56,
3243.83, 3712.01, 3913.5, 3927.51, 3958.53, 3920.48, 3864.41,
3796.78, 3722.65, 3691.73, 3644.18, 3543.42, 3438.32, 3330.14,
3220.07, 3109.24, 3004.57, 2895.68, 2787.51, 2681.53, 2578.11,
2477.52, 2379.95, 2813.87, 2788.22, 2728.48, 2756.85, 2786.68,
2694.65, 2608.24, 2597.77, 2545.36, 2491.73, 2412.97, 2336.46,
2271.19, 2188.86, 2108.19, 2040.78, 1986.68, 1936.91, 1878.75,
1806.1, 1738.22, 1677.78, 1629.61, 1576.72, 1522.31, 1468.47,
1415.22, 1360.73, 1310.14, 1263.29, 1220.5, 1186.29, 1176.45,
1146.52, 1296.16, 1402.02, 1400.11, 1564.91, 1585.36, 1550.73,
1527.26, 1554.59, 1681.56, 1809.45, 1922.11, 1888.08, 1883.8,
1838.53, 1792.08, 1752.16, 1755.79, 1801.08, 1750.14, 1704.65,
1660.78, 1738.31, 1814.29, 1946.35, 1915.42, 1874.03, 1837.08,
1797.03, 1745.39, 1692.97, 1638.4, 1582.78, 1528, 1482.9, 1446,
1392.06, 1368.92, 1336.07, 1295.59, 1252.26, 1219.42, 1217.08,
1189.72, 1160.78, 1136.55, 1102.22, 1069.61, 1046.33, 1042.26,
1049.2, 1077.69, 1137.23, 1279.42, 1384.82, 1535.59, 1751.06,
1776.16, 1795.9, 1942.66, 2397.41, 3508.54, 3446.5, 3360.68,
3272.21, 3181.58, 3183.02, 3075.52, 2966.5, 2869.19, 2861.11,
2968.42, 3074.72, 2981.29, 2918.92, 2917.28, 2839.04, 2769.58,
2867.63, 3091.58, 2993.72, 2907.2, 2821.7, 2742.23, 3034.28,
3000.26, 2992.62, 2916.74, 3065.56, 3032.59, 3069.44, 3078.66,
3155.65, 3345.97, 3270.34, 3191.47, 3111.74, 3031.16, 2946.79,
2871.31, 2786.59, 2712.88, 2626.39, 2538.42, 2452.23, 2536.5,
2446.21, 2359.14, 2427.6, 2337.26, 2268.88, 2239.2, 2159.32,
2079.14, 2017.22, 2101.43, 2035.56, 1974.59, 1963.55, 2463.37,
2592.44, 2496.95, 2406.56, 2399.59, 2719.11, 2627.14, 2532.03,
2441.72, 2355.8, 2273.24, 2212.13, 2131.78, 2054.68, 2021.56,
1944.85, 1871.6, 1822.82, 1763.29, 1694.74, 1629.67, 1569.39,
1511.37, 1454.11, 1400.78, 1350.58, 1320.89, 1524.41, 1844.56,
1984.72, 3024.6, 2953.2, 2836.92, 2725.89, 2620.15, 2518.29,
2421.03, 2328, 2237.87, 2152.21, 2071.36, 1994.57, 1923.34, 1965.91,
1906.98, 1910.02, 1870.62, 1815.72, 1748.49, 1702.61, 1739.4,
1785.07, 1873.86, 2378.29, 2494.53, 2612.01, 2858.16, 2788.6,
2696.15, 2610.24, 2520.25, 2431.5, 2343.59, 2259.04, 2176.11,
2096.57, 2019.08, 1944.45, 1872.69, 1803.19, 1737.54, 1673.17,
1609.63, 1587.49, 1669.8, 1657.65, 1657.05, 1594.35, 1532.6,
1475, 1416.77, 1360.61, 1306.33, 1253.97, 1203.53, 1155.17, 1114.4,
1075.4, 1034.59, 993.862, 957.333, 918.364, 880.908, 845.121,
814.763, 781.644, 749.727, 719.079, 689.992, 666.463, 658.674,
639.19, 617.655, 595.126, 573.268, 551.763, 530.933, 514.663,
493.969, 473.986, 454.894, 436.422, 418.687, 402.434, 404.804,
422.748, 411.777, 527.699, 511.651, 490.849, 536.02, 555.457,
532.754, 510.963, 490.056, 469.998, 450.755, 432.295, 414.587,
397.6, 381.307, 365.679, 350.69, 336.315, 328.3, 664.914, 1045.6,
1086.51, 1042.35, 999.99, 959.336, 922.295, 889.513, 854.952,
820.273, 802.777, 839.017, 809.869, 776.747, 744.953, 733.373,
1046.14, 1004.25, 963.686, 924.941)
y2<-c(-0.0143333336454816, -0.130041667725891, 0.205333333889333,
0.0751666662593683, -0.567708330228925, 0.00870833483835061,
0.108500000167017, -0.152333330673476, 0.0720833349041641, 0.0236249993322417,
-0.00183332874439657, 0.633374993999799, 0.0230833344782392,
0.17537499712004, 0.126000000241523, 0.0728333333196739, 0.24050000286176,
0.470958332220713, 0.00229166596060774, -0.110000000180056, 0.159374999910748,
0.165541665841981, 0.204583332020169, -0.173458332836162, -0.0836250004940666,
-0.207041666842997, 0.191458333438883, -0.231000000378117, -0.450666667272647,
0.000625000917352736, 0.0672916673744718, -0.0514583328040317,
0.447916670391957, -0.0139166663090388, -0.143041666325492, 0.0312916650048768,
-0.245958331235064, -0.329958332081636, 0.304333332712607, -0.0889166676594565,
-0.361833333348234, 0.0753333327205231, 0.695874998966853, 0.41166666833063,
-0.18824999841551, 0.0396249986952171, 1.06683334087332, 0.0413749999182376,
0.0123749998650358, 0.229791667860506, 0.549791666368643, -0.164916665758938,
-0.135374999294678, 0.273583333939314, -0.0588750006087745, 0.277958332871397,
-0.313208335389694, 0.689124989633759, 0.094624999522542, -0.269583333283663,
0.191708333479861, 0.664500000576178, -0.137416665190055, 0.642000003407399,
0.450583333459993, 0.0582499998854473, 0.336791667776803, 0.0301666681965192,
0.29837500040109, -0.201166667509824, 0.451166668285926, 0.224791664397344,
-0.0301666668674443, 0.363333332662781, -0.104125000148391, -0.342625002066294,
0.846166675289472, 0.054874999797903, 0.338583329808898, 0.218583332529912,
0.195208333122234, 0.4053333333383, -0.247833332667748, -0.146250000533958,
0.185249998471894, -0.584749998602395, 0.0963333349985381, 0.755874996383985,
0.496833334366481, 0.0993333334918134, -0.292916670752068, -0.0159166666465656,
0.00379166667698883, -0.0822083334545217, 0.0154583335776503,
-0.207333335032066, 0.0127083321179574, -0.174791666586922, -0.0755833332271626,
0.549208330145727, 0.0531666671546797, -0.142875001144906, -0.123333334001169,
-0.0901666677576334, 0.037708332509889, -0.0903749998348455,
-0.195166666681568, 0.60275000333786, -0.194000001375874, -0.0709583333227783,
-0.0380833333668609, -0.0306666662266556, -0.0302083338416802,
-0.266958334483206, 0.337416667491198, 0.065041667073577, -0.238083333087464,
-0.285499998989205, -0.214749998723467, 0.189666667991939, -0.00158333376748487,
-0.137958332993245, -0.0680416666873498, 0.0718749998292575,
0.119708333474894, 0.0152916668060546, -0.0815833330949924, -0.122666667215526,
-0.0450416663031016, -0.157999999200304, 0.0971250010964771,
-0.021208333215327, 0.359666664153337, 0.313999998693665, 0.920874993006388,
0.199916666451221, -0.229291666299105, 0.765291665991147, -0.136083332821727,
-0.216124999336898, -0.532875002051393, -0.0467916677395503,
-0.1334166660284, 0.110416666216527, -0.0878749993862584, 0.380500002764165,
-0.039708333836946, -0.498291670034329, 0.275583331162731, 0.0325000000642225,
-0.127666668326128, -0.184624999257115, 0.0896250005656232, 0.239999998981754,
0.213041666895151, -0.0553750009275973, -0.0588333333532015,
-0.0314583331734563, -0.135000001328687, 0.0435416668624384,
0.0690833330930521, -0.100416666731083, -0.0135416674311273,
0.0191666668833932, -0.205666666850448, -0.136083332511286, 0.108666666705782,
0.0719166641841487, -0.0831250000434617, -0.0324166665765612,
0.28095833491534, -0.172041665762663, 0.19295833275343, -0.217958332970738,
0.137416667576569, -0.103708333956699, 0.493125003452102, 0.0395833332634841,
0.0919583337381482, -0.0902499996591359, -0.251624997705221,
-0.163791666428248, -0.0290000005625188, -0.0968750004443185,
0.15054166658471, -0.0782916670044263, -0.13729166580985, -0.115583334118128,
-0.116708333060766, -0.03329166630283, -0.0244583334521546, -0.0325416672664384,
-0.109916667609165, -0.129333334043622, -0.166249999466042, -0.0641666658145065,
-0.0281249999146288, -0.000416666768918124, 0.0460833331938678,
-0.00325000062972928, 0.0692916658784573, 0.0606250003523504,
0.0774999997229315, -0.071875000372529, 0.0102500002346157, 0.124166666607683,
0.134333334164694, 0.178166668862104, -0.245958332593242, 0.170708333665971,
-0.0618749993154779, 0.0354166668791246, -0.0117500002719074,
0.0573333327968915, 0.142208333127201, -0.0767499993477638, -0.101708334404975,
-0.139833334367722, 0.0271666664242124, -0.046666666942959, 0.00725000006301949,
0.223541667995354, -0.146083333219091, 0.059000000396433, -0.178999999538064,
-0.109958333428949, 0.220708332955837, -0.11587499982367, -0.176041666728755,
0.0539166663462917, 0.0158333336682214, 0.0103333337465301, -0.145249998817841,
0.0191249998752028, -0.0938750004085402, 0.108333333240201, -0.000708333022582034,
-0.0461666665166073, -0.0394166663754731, 0.349708331748843,
0.0017500000152116, -0.00470833342599993, -0.00558333326383339,
-0.131083334175249, 0.0782916669268161, -0.0562916661583586,
0.157583333532481, -0.153416668064892, 0.0437916667627481, -0.00499999996100087,
0.126625000266358, 0.104541668260936, 0.105791667068843, -0.034624999971129,
-0.00670833386053952, -0.0937916667123015, -0.107750000276913,
-0.410083334892988, 0.0678333326165254, -0.04479166752814, -0.0690416670404375,
0.0705833329605715, 0.0290416665714777, 0.186249999019007, 0.0559583333670162,
0.114208333194256, -0.054666666740862, -0.0615833334159106, 0.0185416670477328,
0.0032500000767565, -0.0410000003563861, -0.0481250003213063,
0.026041666555102, -0.00766666660395761, -0.0269166667906878,
-0.129833333194256, 0.044458333014821, -0.128583333707259, 0.158416667642693,
-0.0620416668243706, 0.0518333335445883, -0.0877500008791685,
-0.079041665730377, -0.200249998519818, -0.0592916671497126,
-0.0573333334953835, -0.0637916669559975, 0.0492916666747381,
0.077958333849286, 0.084416666252461, 0.219999999467594, 0.0175416672379167,
-0.0620000003837049, -0.10549999990811, -0.129083334002644, 0.0092500001580144,
0.050750000407182, -0.21812499811252, 0.0312500000776102, -0.0962083325721323,
0.0855000005103648, -0.0114583335089264, -0.0704583334348475,
0.0142083335279798, -0.108124999639889, -0.0675416669497887,
0.151958333017925, 0.00258333289821167, 0.116416666695538, 0.0430000008394321,
-0.107999999769769, 0.214999997988343, -0.048625000345055, -0.076583333623906,
0.039708333555609, -0.0127500006735014, 0.0430000002185504, -0.116583333661159,
0.0247500000793176, -0.00983333304369201, -0.011666667201401,
0.00229166702289755, -0.066125000443814, 0.129791667646108, 0.239958334112695,
0.197666665655561, -0.0584583321372823, -0.112875000263254, -0.13483333401382,
-0.00395833318179939, -0.0888750000546376, -0.136249998196339,
0.0827499999043842, -0.0271666669286788, 0.109333333559334, -0.193041666100423,
0.0270833332372907, 0.0983333326876163, -0.120541666634381, 0.078583334106952,
-0.0511249999593322, -0.00595833334470323, -0.0132916665170342,
0.0407916669549498, 0.139541667420417, -0.154333331932624, 0.0679166668560356,
-0.146000001269082, -0.0325416667280175, -0.017791666793831,
-0.0484999995484638, -0.0911666670193275, -0.00124999980713862,
0.0328333332242134, 0.0209583333150173, -0.0675416666393479,
0.0457916669547558, -0.0136249999874659, 0.498083334416151, -0.0294999997471071,
0.00112500010194102, 0.0847083332676751, 0.0993749999712842,
0.0766666668932885, -0.161374999520679)
I have a function(contlevels) that uses the MASS package and calculates the density(kde2d) of the two time series and also gives the specific contour level densities. The function calculates the density and returns the cumulative densities for the specific contour levels.
#####################################################
contlevels <- function(x,y,xmin,xmax,ymin,ymax,clev){
#####################################################
dd <- kde2d(x,y,n=c(60,60),lims=c(xmin,xmax,ymin,ymax))
xx <- dd$x
yy <- dd$y
zz <- dd$z
zsort <- sort(zz,decreasing=T)
p <- zz/sum(zz)
ps <- sort(p, decreasing=T)
n <- length(zz)
pscum <- array(0,dim=n)
pscum[1]<-ps[1]
pscum
for (i in 2:n){
pscum[i]<-pscum[i-1]+ps[i]
}
nlev <- length(clev)
cumlev <- array(0,dim=nlev)
for (ilev in 1:nlev){
for (i in 1:(n-1)){
if(pscum[i] >= clev[ilev]){
zsect <- (clev[ilev] - pscum[i])/(pscum[i+1]-pscum[i])
cumlev[ilev] <- zsort[i] + zsect*(zsort[i+1]-zsort[i])
break
}
}
}
contlevels <- list(xx=xx,yy=yy,zz=zz,cumlev=cumlev)
}
##########################################################################
Followings are the plotting initials
xmin=0
xmax=10000
ymin=-1
ymax=1
clev <- c(0.5,0.7,0.8) ## these are the contour levels I need to plot.
Segregating the variables from the function
cl1<-contlevels(x1,y1,xmin,xmax,ymin,ymax,clev)
xx <- cl1$x
yy <- cl1$y
zz <- cl1$z
cumlev1 <- cl1$cumlev
cl2<-contlevels(x2,y2,xmin,xmax,ymin,ymax,clev)
xxx <- cl2$x
yyy <- cl2$y
zzz <- cl2$z
cumlev2 <- cl2$cumlev
Plotting the distribution
plot(x1,y1,pch=20,cex=1,xlim=c(xmin,xmax),ylim=c(ymin,ymax),xlab="X",ylab="Y")
for (ilev in length(clev):2){
.filled.contour(xx,yy,zz,levels=c(cumlev1[ilev],cumlev1[ilev-1]),col="red")
.filled.contour(xxx,yyy,zzz,levels=c(cumlev2[ilev],cumlev2[ilev-1]),col="white")
}
Contour plots
contour(xx,yy,zz,add=T,col="black",lwd=2,levels=cumlev1,labels=clev)
contour(xxx,yyy,zzz,add=T,col="grey",lwd=1,levels=cumlev2,drawlabels=F)
Running this code will result in the above graph. where the 2nd distribution(white color i.e. x2 vs y2) is overlayed over the 1st distribution (red color, x1,y1). The red color will only pop up if the 2nd distribution is less that 1st. However, I also need the other way around. If the 2nd distribution is greater than the 1st distribution, I want it to be colored blue.
Could anyone of you help me with this?

Related

How to get a probability density function from vector?

I have a vector that I want to transform into a probability density function. The mean is 1. How do I plot this?
The vector:
x <-
c(0.7601401, 0.8607037, 0.8748152, 0.885415, 0.8904619, 0.899021,
0.9034128, 0.9050411, 0.9093876, 0.9141021, 0.9172803, 0.9209636,
0.9238607, 0.9268591, 0.9293789, 0.9313833, 0.9335163, 0.9360798,
0.9406245, 0.9427261, 0.9441703, 0.9473808, 0.9502454, 0.9518683,
0.9540568, 0.955987, 0.9580035, 0.9617511, 0.9635325, 0.964507,
0.9674928, 0.9692979, 0.9705296, 0.9732977, 0.9754498, 0.977204,
0.9793093, 0.9821249, 0.9841156, 0.9864521, 0.9873941, 0.9883275,
0.9904071, 0.9920552, 0.9946789, 0.9967097, 0.997695, 0.9992215,
1.001643, 1.0038606, 1.006269, 1.0077312, 1.0091087, 1.0100767,
1.0113615, 1.0124576, 1.0154025, 1.017386, 1.0189122, 1.021932,
1.0238598, 1.0258631, 1.0273012, 1.0294901, 1.031085, 1.0336801,
1.0371085, 1.0387533, 1.0406862, 1.0436292, 1.0453442, 1.0471563,
1.0514885, 1.0531803, 1.055339, 1.059578, 1.0643068, 1.0668389,
1.0694237, 1.073174, 1.0759322, 1.0786821, 1.0846407, 1.0904819,
1.0968733, 1.1039872, 1.1081845, 1.1144191, 1.124116, 1.1378536,
1.1631801, 0.8238456, 0.8621417, 0.8750536, 0.8864652, 0.8913426,
0.899054, 0.9034444, 0.9052496, 0.9096515, 0.9141042, 0.9174039,
0.9215185, 0.9240734, 0.9272829, 0.9294991, 0.9315397, 0.9335967,
0.9370766, 0.9408574, 0.9427551, 0.9444246, 0.9474299, 0.9503871,
0.9520593, 0.9541102, 0.9560759, 0.9586173, 0.9618885, 0.9636027,
0.9653304, 0.9677295, 0.9693085, 0.9706549, 0.9735909, 0.9757686,
0.9772445, 0.9795081, 0.9823502, 0.9843492, 0.9866112, 0.9874782,
0.9883432, 0.9904612, 0.99227, 0.9948917, 0.9968164, 0.9979785,
0.999409, 1.0017522, 1.0038956, 1.0064009, 1.007936, 1.0092714,
1.0101577, 1.0113745, 1.0124722, 1.015455, 1.0174442, 1.0190047,
1.0221244, 1.0241163, 1.0262672, 1.0274717, 1.0295358, 1.0311976,
1.0337105, 1.0376287, 1.0391993, 1.0412049, 1.043784, 1.0458161,
1.0471989, 1.0515136, 1.0532311, 1.0553901, 1.0598511, 1.0647286,
1.0674053, 1.0695112, 1.0731966, 1.0765993, 1.0804314, 1.0846581,
1.0915069, 1.0983415, 1.1041094, 1.1087707, 1.1153954, 1.1244647,
1.1387218, 1.1631806, 0.8268138, 0.8625675, 0.8751377, 0.886809,
0.8920388, 0.8991269, 0.9034886, 0.9060083, 0.9102798, 0.9143602,
0.9178468, 0.9221248, 0.9241217, 0.9273233, 0.929575, 0.9316477,
0.9337809, 0.9374138, 0.9410309, 0.9429906, 0.9455161, 0.9475521,
0.9506105, 0.9522978, 0.9541801, 0.9567138, 0.9588403, 0.961889,
0.9637248, 0.9658144, 0.9678051, 0.9694083, 0.9708232, 0.9737623,
0.9757794, 0.9772462, 0.9799384, 0.9826819, 0.9844438, 0.9866957,
0.9875501, 0.9884927, 0.9905356, 0.992504, 0.9952807, 0.9970651,
0.9979877, 0.9996339, 1.0018148, 1.0039266, 1.0064778, 1.0080148,
1.0093728, 1.0101958, 1.0115577, 1.0128605, 1.0155767, 1.0176005,
1.0191159, 1.0222069, 1.0241286, 1.0263724, 1.0275547, 1.0298965,
1.0314567, 1.0347959, 1.0377489, 1.0392566, 1.0413151, 1.043814,
1.0462065, 1.0472742, 1.0516567, 1.0533239, 1.0556568, 1.0599784,
1.0648656, 1.0674582, 1.0695187, 1.0737822, 1.0767733, 1.0805175,
1.085116, 1.0919541, 1.0987864, 1.1045691, 1.1090898, 1.1155974,
1.1244743, 1.1403648, 1.1653051, 0.8287487, 0.8632563, 0.8783957,
0.8872595, 0.8921496, 0.8991388, 0.9038431, 0.9063199, 0.9106785,
0.9144, 0.9189027, 0.9223262, 0.924352, 0.9275484, 0.9296723,
0.932303, 0.9340644, 0.9375086, 0.9410767, 0.9431117, 0.9455282,
0.9476748, 0.9506839, 0.9524355, 0.9542676, 0.9570338, 0.9591047,
0.9620121, 0.9638592, 0.9660401, 0.9678991, 0.9695856, 0.9710773,
0.9740787, 0.9760428, 0.9773099, 0.9800677, 0.9830478, 0.9845491,
0.9868047, 0.9876641, 0.9885819, 0.990765, 0.9929082, 0.9953852,
0.9972524, 0.9980094, 0.999655, 1.0019781, 1.0041123, 1.0065022,
1.0080436, 1.0093745, 1.0102597, 1.011591, 1.0133388, 1.0160004,
1.0177403, 1.0197461, 1.0223301, 1.0243601, 1.0264419, 1.0277154,
1.0300746, 1.0315714, 1.0348406, 1.0377535, 1.0396123, 1.0416248,
1.0438679, 1.0463796, 1.0473053, 1.0518621, 1.0535013, 1.0566508,
1.0602571, 1.0649945, 1.0675837, 1.0696383, 1.0737915, 1.0768286,
1.0807683, 1.0866947, 1.0922428, 1.0993173, 1.1053873, 1.1097462,
1.1160662, 1.1245894, 1.1439087, 1.1653756, 0.8336881, 0.8641065,
0.8801013, 0.8873061, 0.892528, 0.8992721, 0.9040462, 0.9064932,
0.9118009, 0.9147806, 0.9194353, 0.922346, 0.924704, 0.9279243,
0.9298283, 0.9325862, 0.9345334, 0.9376213, 0.9413217, 0.9435098,
0.9457126, 0.948086, 0.9507289, 0.9526298, 0.9544503, 0.9570495,
0.9594515, 0.9622223, 0.9639176, 0.9664818, 0.9681109, 0.9697204,
0.9715772, 0.974512, 0.9761773, 0.9774122, 0.9801115, 0.9830508,
0.9848412, 0.9868423, 0.987876, 0.9886175, 0.9911154, 0.9930527,
0.995429, 0.9972859, 0.9980303, 1.000341, 1.0023467, 1.0041273,
1.0066877, 1.0081464, 1.0094208, 1.0103294, 1.0117416, 1.0134278,
1.0162053, 1.0179561, 1.0202328, 1.0227929, 1.0244661, 1.0266619,
1.0278932, 1.0301724, 1.0318422, 1.034844, 1.0378449, 1.0396893,
1.0416388, 1.0441611, 1.0464143, 1.0485936, 1.0520624, 1.0535133,
1.0568916, 1.0602833, 1.0652996, 1.0678024, 1.0700347, 1.0739087,
1.0768747, 1.0811584, 1.08706, 1.092342, 1.0994397, 1.1057555,
1.1101622, 1.1197734, 1.1260845, 1.144113, 1.1656149, 0.8364483,
0.8665228, 0.8801799, 0.8876104, 0.8951142, 0.9004983, 0.9041605,
0.9067967, 0.9123546, 0.9151016, 0.9195613, 0.9224414, 0.9250538,
0.9280133, 0.9299708, 0.9326035, 0.9346515, 0.9380998, 0.9414107,
0.9435515, 0.9461568, 0.9482194, 0.9508463, 0.9527514, 0.9546165,
0.9571445, 0.9596505, 0.9624602, 0.963954, 0.9665085, 0.9682382,
0.9699198, 0.9716006, 0.974844, 0.9761914, 0.9775793, 0.9801981,
0.9835029, 0.9848844, 0.9869101, 0.9878904, 0.988621, 0.9913567,
0.9933158, 0.9955091, 0.9973969, 0.9982784, 1.0004438, 1.0024634,
1.0043027, 1.006941, 1.0081515, 1.0094608, 1.0103653, 1.0117473,
1.0142556, 1.0165854, 1.0181703, 1.0205428, 1.022822, 1.0245166,
1.02681, 1.0278956, 1.0302434, 1.032, 1.0355287, 1.037906, 1.0401162,
1.041886, 1.0442367, 1.0464702, 1.0486031, 1.0521055, 1.0540157,
1.0570109, 1.0605447, 1.0654882, 1.0679469, 1.0700915, 1.0746908,
1.076962, 1.0811779, 1.0880499, 1.0925217, 1.1000415, 1.1068352,
1.1103446, 1.1198258, 1.1278557, 1.144615, 1.1659478, 0.8428518,
0.8685433, 0.8806388, 0.8878492, 0.8957898, 0.9008499, 0.9041908,
0.907718, 0.9124535, 0.9154017, 0.9195873, 0.9228693, 0.9252186,
0.9280587, 0.9302431, 0.9327066, 0.9346733, 0.9382416, 0.9415437,
0.943858, 0.9463773, 0.9482644, 0.9510351, 0.9529947, 0.9548508,
0.9571599, 0.9597816, 0.9632479, 0.9640826, 0.9667552, 0.9688842,
0.9699332, 0.972455, 0.9748674, 0.9765135, 0.9782475, 0.9804558,
0.9835081, 0.9849378, 0.9869651, 0.9879891, 0.9886996, 0.9913707,
0.9933895, 0.9958194, 0.9974753, 0.9984636, 1.0005798, 1.0027019,
1.0043733, 1.007001, 1.008266, 1.0097909, 1.0104785, 1.0119673,
1.0145991, 1.0166569, 1.0182844, 1.0211453, 1.0231898, 1.0245254,
1.0268803, 1.0279336, 1.0304433, 1.0322581, 1.035589, 1.0382374,
1.0401349, 1.0422173, 1.0444101, 1.0465514, 1.0486237, 1.0521174,
1.054423, 1.057825, 1.0606672, 1.0656468, 1.0684325, 1.0709319,
1.0749488, 1.0770775, 1.0820547, 1.0881332, 1.0925439, 1.1000816,
1.1069162, 1.1106217, 1.120701, 1.1302275, 1.1459233, 1.168602,
0.8488214, 0.8702316, 0.8809238, 0.8890422, 0.8958309, 0.9019966,
0.9042307, 0.9079107, 0.9132285, 0.9154252, 0.9198471, 0.9230071,
0.9253286, 0.9283751, 0.9304839, 0.9327088, 0.9348709, 0.9382659,
0.9417193, 0.943864, 0.9466926, 0.9485074, 0.9511567, 0.9532046,
0.9554877, 0.9574181, 0.9600951, 0.963362, 0.9643226, 0.9667904,
0.9689357, 0.9699377, 0.9726418, 0.9749534, 0.9766888, 0.9786503,
0.9816446, 0.9836604, 0.9850502, 0.9869678, 0.9880833, 0.9894534,
0.9914227, 0.9937725, 0.9962026, 0.9975144, 0.9987734, 1.0006365,
1.0029989, 1.0047337, 1.0071024, 1.0086273, 1.0098207, 1.0110381,
1.0119714, 1.01463, 1.0166717, 1.0183924, 1.0212439, 1.0234931,
1.0245751, 1.0269182, 1.0286172, 1.0306589, 1.0322592, 1.0359487,
1.038269, 1.0402549, 1.0422949, 1.0445157, 1.0466529, 1.0487325,
1.0523088, 1.0546675, 1.0584369, 1.0618338, 1.0658283, 1.0687319,
1.0712981, 1.0750357, 1.0777228, 1.082814, 1.0896652, 1.092878,
1.1002284, 1.1072211, 1.1112157, 1.1210507, 1.1331503, 1.1510694,
1.1729349, 0.8533762, 0.8705291, 0.882901, 0.8898704, 0.8964921,
0.9026909, 0.9043496, 0.9082536, 0.9132482, 0.9167392, 0.9200439,
0.923801, 0.9257428, 0.9287926, 0.9310369, 0.9327569, 0.935825,
0.9396949, 0.9418288, 0.9439139, 0.9468012, 0.9487367, 0.9513136,
0.9534568, 0.9557201, 0.9577258, 0.9606246, 0.9634036, 0.9644277,
0.9668756, 0.9689947, 0.9699737, 0.9726901, 0.9749863, 0.9768128,
0.9790117, 0.9817103, 0.9837448, 0.9853122, 0.98713, 0.9881006,
0.9896077, 0.9918675, 0.9939561, 0.9962435, 0.9975984, 0.9988964,
1.0007611, 1.0032765, 1.0052762, 1.0072548, 1.008838, 1.0098927,
1.011057, 1.0120007, 1.0153072, 1.0167114, 1.0183976, 1.0217836,
1.0235315, 1.0250021, 1.0270587, 1.0287792, 1.0308106, 1.032815,
1.0363681, 1.0384448, 1.0403337, 1.0423298, 1.0446048, 1.046717,
1.0487547, 1.0527611, 1.0548012, 1.0586172, 1.0622363, 1.0665121,
1.0690857, 1.0720846, 1.0755489, 1.0784088, 1.0840459, 1.089944,
1.093356, 1.1004089, 1.1073085, 1.1124143, 1.1211267, 1.1339292,
1.1517573, 1.198363, 0.8571564, 0.8726188, 0.8845936, 0.8898835,
0.8980876, 0.9028112, 0.9044216, 0.9086289, 0.9133134, 0.9168552,
0.9203877, 0.9238087, 0.926413, 0.929035, 0.9313117, 0.9330642,
0.9358536, 0.9400013, 0.9420459, 0.9439535, 0.9469293, 0.9491097,
0.9513609, 0.9535177, 0.9557438, 0.9577505, 0.9608692, 0.9634749,
0.9644502, 0.9669999, 0.9690555, 0.9703173, 0.9727357, 0.9750629,
0.9769616, 0.9790537, 0.9817755, 0.9837511, 0.9856411, 0.9872352,
0.9882029, 0.990218, 0.9919514, 0.9941591, 0.9965548, 0.9976154,
0.9990174, 1.0010466, 1.003395, 1.0055957, 1.007304, 1.0089384,
1.0099392, 1.0112263, 1.012146, 1.0153451, 1.0171438, 1.0186295,
1.0217893, 1.0236026, 1.0256126, 1.0271073, 1.0289151, 1.0309176,
1.033115, 1.036525, 1.0385212, 1.0406626, 1.0429921, 1.0447711,
1.0468007, 1.0501243, 1.0527771, 1.0549067, 1.0590568, 1.0635208,
1.066646, 1.0691815, 1.0725159, 1.0756145, 1.0784323, 1.0844119,
1.0900761, 1.0937593, 1.1018746, 1.1080635, 1.112721, 1.1223554,
1.1342245, 1.1589387, 1.3267105, 0.8593686, 0.8738442, 0.8847164,
0.8900729, 0.8985823, 0.9030722, 0.9047745, 0.9089145, 0.9133781,
0.9170319, 0.9205633, 0.9238323, 0.92677, 0.929173, 0.931353,
0.933437, 0.9359658, 0.9403774, 0.9424343, 0.9441537, 0.9472636,
0.9497636, 0.9514515, 0.9539961, 0.955913, 0.9577903, 0.9613333,
0.9635, 0.9644766, 0.9672279, 0.9690912, 0.9704478, 0.9730493,
0.975256, 0.9771195, 0.9792525, 0.982091, 0.9839065, 0.9862609,
0.9872484, 0.9882653, 0.9902789, 0.9919861, 0.9944648, 0.996593,
0.9976709, 0.9992019, 1.0012796, 1.0036569, 1.0061553, 1.0075918,
1.0089733, 1.0100455, 1.0112892, 1.0124005, 1.0153452, 1.0172939,
1.0186304, 1.0218203, 1.0238237, 1.0256419, 1.0272337, 1.0289253,
1.0310775, 1.0333971, 1.0365301, 1.0386841, 1.0406816, 1.04333,
1.0448819, 1.0471028, 1.0501926, 1.0528722, 1.0551719, 1.059271,
1.0638416, 1.0667384, 1.0691885, 1.0729292, 1.0756769, 1.0786645,
1.0844603, 1.0902495, 1.0940123, 1.1037544, 1.1080977, 1.1140658,
1.1234296, 1.1354923, 1.1600791)
You can get a nonparametric estimate by using the ?density function to compute the kernel density estimate, with default Gaussian kernel.
x <- density(vector)
plot(x)
Note that you can also generate an empirical cdf with the base ecdf function. That allows you to calculate F(x) for any x. E.g.
x <- rnorm(1000)
cdf <- ecdf(x)
plot(cdf)
f <- cdf(0.5)
f
[1] 0.692

R: The 61928th question about the "singular gradient matrix at initial parameter estimates" error message

I have the following data:
479117.562500000 -100.366333008
479117.625000000 -100.292800903
479117.687500000 -100.772460937
479117.750000000 -101.344261169
479117.812500000 -102.828948975
479117.875000000 -103.842330933
479117.937500000 -102.289733887
479118.000000000 -101.856155396
479118.062500000 -101.972282410
479118.125000000 -101.272254944
479118.187500000 -101.042846680
479118.250000000 -101.957427979
479118.312500000 -101.363922119
479118.375000000 -101.065864563
479118.437500000 -99.710098267
479118.500000000 -98.789115906
479118.562500000 -99.854644775
479118.625000000 -100.956558228
479118.687500000 -100.456512451
479118.750000000 -100.779090881
479118.812500000 -101.598800659
479118.875000000 -100.329147339
479118.937500000 -100.486946106
479119.000000000 -102.275772095
479119.062500000 -103.128715515
479119.125000000 -103.075996399
479119.187500000 -103.266349792
479119.250000000 -102.390190125
479119.312500000 -101.386428833
479119.375000000 -102.008850098
479119.437500000 -103.579475403
479119.500000000 -103.382720947
479119.562500000 -100.842361450
479119.625000000 -98.478569031
479119.687500000 -98.745864868
479119.750000000 -99.653961182
479119.812500000 -100.032035828
479119.875000000 -99.955345154
479119.937500000 -99.842536926
479120.000000000 -100.187896729
479120.062500000 -100.456726074
479120.125000000 -101.258850098
479120.187500000 -102.649017334
479120.250000000 -104.833518982
479120.312500000 -102.760551453
479120.375000000 -101.653732300
479120.437500000 -102.729179382
479120.500000000 -102.752014160
479120.562500000 -103.103675842
479120.625000000 -102.842521667
479120.687500000 -102.692077637
479120.750000000 -102.499221802
479120.812500000 -101.806587219
479120.875000000 -102.124893188
479120.937500000 -101.700584412
479121.000000000 -101.385307312
479121.062500000 -101.242889404
479121.125000000 -100.172935486
479121.187500000 -100.230110168
479121.250000000 -100.861007690
479121.312500000 -101.013366699
479121.375000000 -100.585502625
479121.437500000 -100.897743225
479121.500000000 -101.453987122
479121.562500000 -102.233383179
479121.625000000 -102.231163025
479121.687500000 -99.512817383
479121.750000000 -97.662391663
479121.812500000 -97.647987366
479121.875000000 -100.217674255
479121.937500000 -102.411224365
479122.000000000 -101.892311096
479122.062500000 -102.475875854
479122.125000000 -103.164466858
479122.187500000 -103.406997681
479122.250000000 -104.319549561
479122.312500000 -102.138801575
479122.375000000 -99.946632385
479122.437500000 -100.355888367
479122.500000000 -101.683120728
479122.562500000 -101.582458496
479122.625000000 -99.907981873
479122.687500000 -100.329666138
479122.750000000 -100.243255615
479122.812500000 -100.713218689
479122.875000000 -102.436210632
479122.937500000 -103.173072815
479123.000000000 -103.720008850
479123.062500000 -105.225852966
479123.125000000 -104.841903687
479123.187500000 -103.589698792
479123.250000000 -101.543907166
479123.312500000 -101.051879883
479123.375000000 -103.181671143
479123.437500000 -104.825492859
479123.500000000 -103.848281860
479123.562500000 -102.969032288
479123.625000000 -101.002128601
479123.687500000 -100.698005676
479123.750000000 -102.078453064
479123.812500000 -103.582519531
479123.875000000 -105.085006714
479123.937500000 -103.349472046
479124.000000000 -100.479156494
479124.062500000 -100.558197021
479124.125000000 -101.563316345
479124.187500000 -101.261054993
479124.250000000 -102.108535767
479124.312500000 -104.861206055
479124.375000000 -105.044944763
479124.437500000 -105.712318420
479124.500000000 -105.045219421
479124.562500000 -104.131736755
479124.625000000 -104.060478210
479124.687500000 -103.435829163
479124.750000000 -103.167121887
479124.812500000 -102.186767578
479124.875000000 -101.180900574
479124.937500000 -101.686195374
479125.000000000 -102.167709351
479125.062500000 -102.771011353
479125.125000000 -103.367576599
479125.187500000 -103.127212524
479125.250000000 -103.924591064
479125.312500000 -103.187667847
479125.375000000 -102.220222473
479125.437500000 -102.674034119
479125.500000000 -101.717445374
479125.562500000 -100.879615784
479125.625000000 -100.964996338
479125.687500000 -102.864616394
479125.750000000 -102.009140015
479125.812500000 -99.761398315
479125.875000000 -99.798591614
479125.937500000 -101.713653564
479126.000000000 -103.273422241
479126.062500000 -102.664245605
479126.125000000 -101.682983398
479126.187500000 -101.853103638
479126.250000000 -103.193588257
479126.312500000 -104.359184265
479126.375000000 -105.037651062
479126.437500000 -104.446434021
479126.500000000 -103.674736023
479126.562500000 -103.374031067
479126.625000000 -102.921363831
479126.687500000 -103.374008179
479126.750000000 -104.299362183
479126.812500000 -104.015937805
479126.875000000 -103.758834839
479126.937500000 -103.698440552
479127.000000000 -103.501396179
479127.062500000 -101.677307129
479127.125000000 -101.010841370
479127.187500000 -103.159111023
479127.250000000 -105.232284546
479127.312500000 -105.949432373
479127.375000000 -104.999694824
479127.437500000 -104.207763672
479127.500000000 -103.822082520
479127.562500000 -103.189147949
479127.625000000 -102.943603516
479127.687500000 -102.586914062
479127.750000000 -102.973297119
479127.812500000 -104.049942017
479127.875000000 -106.436325073
479127.937500000 -105.395500183
479128.000000000 -106.032653809
479128.062500000 -106.538482666
479128.125000000 -105.961471558
479128.187500000 -106.049240112
479128.250000000 -104.937507629
479128.312500000 -104.842300415
479128.375000000 -104.720268250
479128.437500000 -105.791313171
479128.500000000 -106.022468567
479128.562500000 -103.848289490
479128.625000000 -103.887428284
479128.687500000 -104.258583069
479128.750000000 -105.152420044
479128.812500000 -107.673591614
479128.875000000 -107.705734253
479128.937500000 -105.925376892
479129.000000000 -105.528671265
479129.062500000 -106.021476746
479129.125000000 -107.750610352
479129.187500000 -108.693489075
479129.250000000 -108.675323486
479129.312500000 -109.919746399
479129.375000000 -110.940391541
479129.437500000 -109.279312134
479129.500000000 -108.321495056
479129.562500000 -107.995155334
479129.625000000 -109.164222717
479129.687500000 -111.977653503
479129.750000000 -113.194961548
479129.812500000 -114.239585876
479129.875000000 -115.780212402
479129.937500000 -116.979713440
479130.000000000 -117.042602539
479130.062500000 -116.658126831
479130.125000000 -116.624031067
479130.187500000 -116.923446655
479130.250000000 -118.727882385
479130.312500000 -120.354904175
479130.375000000 -121.513587952
479130.437500000 -121.322601318
479130.500000000 -121.338325500
479130.562500000 -120.500923157
479130.625000000 -116.656593323
479130.687500000 -113.295486450
479130.750000000 -111.713729858
479130.812500000 -111.394592285
479130.875000000 -109.731071472
479130.937500000 -108.571876526
479131.000000000 -109.059860229
479131.062500000 -106.810707092
479131.125000000 -106.095306396
479131.187500000 -106.258293152
479131.250000000 -106.243156433
479131.312500000 -106.613525391
479131.375000000 -105.910820007
479131.437500000 -104.405731201
479131.500000000 -102.325592041
479131.562500000 -101.502128601
479131.625000000 -103.445144653
479131.687500000 -105.970573425
479131.750000000 -105.379684448
479131.812500000 -102.992294312
479131.875000000 -100.679176331
479131.937500000 -99.553001404
479132.000000000 -100.532035828
479132.062500000 -102.480346680
479132.125000000 -104.630592346
479132.187500000 -103.669296265
479132.250000000 -101.364990234
479132.312500000 -100.193199158
479132.375000000 -98.483375549
479132.437500000 -98.084083557
479132.500000000 -100.955741882
479132.562500000 -102.788536072
479132.625000000 -102.540054321
479132.687500000 -102.550140381
479132.750000000 -101.182907104
479132.812500000 -100.926239014
479132.875000000 -100.933807373
479132.937500000 -101.358642578
479133.000000000 -100.544723511
479133.062500000 -99.536102295
479133.125000000 -99.533355713
479133.187500000 -100.520698547
479133.250000000 -99.944213867
479133.312500000 -100.118461609
479133.375000000 -101.425323486
479133.437500000 -102.523521423
479133.500000000 -102.540794373
479133.562500000 -101.491882324
479133.625000000 -100.919067383
479133.687500000 -100.623329163
479133.750000000 -99.431541443
479133.812500000 -99.252487183
479133.875000000 -101.166763306
479133.937500000 -102.311378479
479134.000000000 -101.306701660
479134.062500000 -100.665534973
479134.125000000 -100.248069763
479134.187500000 -99.179161072
479134.250000000 -100.506088257
479134.312500000 -101.349990845
479134.375000000 -101.028564453
479134.437500000 -101.089591980
479134.500000000 -100.819961548
479134.562500000 -100.899681091
479134.625000000 -102.236335754
479134.687500000 -101.911392212
479134.750000000 -101.253051758
479134.812500000 -102.417984009
479134.875000000 -101.647750854
479134.937500000 -100.494926453
479135.000000000 -99.920089722
479135.062500000 -101.046142578
479135.125000000 -102.893470764
479135.187500000 -102.895072937
479135.250000000 -103.607261658
479135.312500000 -104.568321228
479135.375000000 -104.253341675
479135.437500000 -102.952842712
479135.500000000 -101.928634644
479135.562500000 -101.746994019
479135.625000000 -102.218338013
479135.687500000 -102.627662659
479135.750000000 -102.185234070
479135.812500000 -103.266464233
479135.875000000 -104.480552673
479135.937500000 -102.991035461
479136.000000000 -101.333572388
479136.062500000 -102.019165039
479136.125000000 -100.434211731
479136.187500000 -99.072113037
479136.250000000 -100.616592407
479136.312500000 -101.648803711
479136.375000000 -102.449073792
479136.437500000 -103.141990662
479136.500000000 -101.611976624
479136.562500000 -101.742187500
479136.625000000 -102.974266052
479136.687500000 -101.894943237
479136.750000000 -101.637077332
479136.812500000 -101.545288086
479136.875000000 -101.042068481
479136.937500000 -101.836784363
479137.000000000 -103.539382935
479137.062500000 -105.681159973
479137.125000000 -102.126953125
479137.187500000 -98.450904846
479137.250000000 -98.859046936
479137.312500000 -102.353157043
479137.375000000 -105.606437683
479137.437500000 -104.589866638
479137.500000000 -103.607994080
479137.562500000 -102.202362061
479137.625000000 -101.861511230
479137.687500000 -101.010215759
479137.750000000 -100.456481934
479137.812500000 -101.639465332
479137.875000000 -102.876907349
479137.937500000 -103.880729675
479138.000000000 -105.811225891
479138.062500000 -106.915206909
479138.125000000 -108.233901978
479138.187500000 -106.625434875
479138.250000000 -103.686866760
479138.312500000 -102.977874756
479138.375000000 -105.153343201
479138.437500000 -106.966751099
479138.500000000 -104.752532959
479138.562500000 -104.894256592
479138.625000000 -105.125381470
479138.687500000 -102.721633911
479138.750000000 -102.299125671
479138.812500000 -102.762176514
479138.875000000 -101.316398621
479138.937500000 -100.695121765
479139.000000000 -101.257949829
479139.062500000 -102.382209778
479139.125000000 -104.331405640
479139.187500000 -106.033081055
479139.250000000 -105.467399597
479139.312500000 -104.492301941
479139.375000000 -104.413681030
479139.437500000 -103.263702393
479139.500000000 -103.199569702
479139.562500000 -104.447860718
479139.625000000 -104.169952393
479139.687500000 -105.357246399
479139.750000000 -105.624694824
479139.812500000 -104.329673767
479139.875000000 -104.890480042
479139.937500000 -103.739471436
479140.000000000 -102.343170166
479140.062500000 -102.630371094
479140.125000000 -103.861930847
479140.187500000 -102.614120483
479140.250000000 -102.544586182
479140.312500000 -103.947563171
479140.375000000 -104.194770813
479140.437500000 -103.187141418
479140.500000000 -102.442695618
479140.562500000 -103.064849854
479140.625000000 -104.047111511
479140.687500000 -103.641082764
479140.750000000 -104.192665100
479140.812500000 -105.001426697
479140.875000000 -106.180221558
479140.937500000 -106.504646301
479141.000000000 -104.772674561
479141.062500000 -104.167114258
479141.125000000 -102.925132751
479141.187500000 -102.731872559
479141.250000000 -104.101806641
479141.312500000 -104.532470703
479141.375000000 -103.677726746
479141.437500000 -103.467483521
479141.500000000 -104.314605713
479141.562500000 -106.088348389
479141.625000000 -105.849678040
479141.687500000 -104.784294128
479141.750000000 -104.685859680
479141.812500000 -102.816184998
479141.875000000 -103.009178162
479141.937500000 -105.581695557
479142.000000000 -104.964607239
479142.062500000 -103.978279114
479142.125000000 -104.709609985
479142.187500000 -105.373786926
479142.250000000 -105.477348328
479142.312500000 -107.076698303
479142.375000000 -108.599830627
479142.437500000 -107.518699646
To which I want to fit the function
While the formula is kind of a beast, it has physical meaning, so I would like to not change it.
I have the following code:
index_min <- which(mydf[,2] == min(mydf[,2]))[1]
n0start <- -119
n1start <- 16
df0start <- 120
df1start <- 1
f0start <- mydf[index_min,1]
f1start <- mydf[index_min,1]
plot(x=mydf[,1],y=mydf[,2])
eq = function(f,n0, n1, f0, f1, df0, df1){ n0+n1*4*(f-f1)^2/(4*(f-f1)^2+(4*((f-f0)/df0)*(f-f1)-df1)^2)}
lines(mydf[,1], eq(mydf[,1],n0start, n1start, f0start, f1start, df0start, df1start), col="red" )
res <- try(nlsLM( y ~ n0+n1*4*(f-f1)^2/(4*(f-f1)^2+(4*((f-f0)/df0)*(f-f1)-df1)^2),
start=c(n0=n0start, n1=n1start,f0=f0start,df0=df0start,f1=f1start,df1=df1start) , data = mydf))
coef(res)
As you can see, the starting values look rather decent, but I get the "singular gradient matrix at initial parameter estimates" error. I have looked through all the other posts, however, I don't see why my formula is overdetermined or why the starting values should be bad.
Okay, I figured out the mistake. nlsLM requires data to be a data-frame and not just a bare matrix. The error message is simply misleading.

Calculate moments based on a probability distribution

I have a probability density distribution that I calculated dividing the ending probabilities by the difference in returns:
deltaR <- c(NA)
for (i in 2:204) {
deltaR[i - 1] = (R[i + 1] - R[i - 1]) / 2
}
for (i in 1:204) {
probability_density[i] = End_Probabilities[i + 1] / deltaR[i]
}
Now I should be able to calculate the moments (theoretically) by integrating the probability density function from -Inf to Inf and multiplying it with x**j. How do I implement this last step in R? I had a look at the package moments and this requires another type of input, than a density function. Here is my calculated probability density:
c(1.060127e-01, 7.808639e-02, 5.351772e-02, 3.271984e-02, 1.653464e-02, 6.228544e-03, 1.406439e-03, 9.808728e-05, 2.659169e-09, 1.526135e-05,
2.540583e-04, 9.029513e-04, 1.695233e-03, 2.376100e-03, 2.854467e-03, 3.152196e-03, 3.332074e-03, 3.391327e-03, 3.314459e-03, 3.103407e-03,
2.782234e-03, 2.421864e-03, 2.095342e-03, 1.866990e-03, 1.799232e-03, 1.995382e-03, 2.643171e-03, 4.140963e-03, 7.222687e-03, 1.290895e-02,
2.261961e-02, 3.847810e-02, 6.267389e-02, 9.368153e-02, 1.257818e-01, 1.508366e-01, 1.633405e-01, 1.614039e-01, 1.503522e-01, 1.369496e-01,
1.256595e-01, 1.203709e-01, 1.266565e-01, 1.518232e-01, 2.052942e-01, 3.027602e-01, 4.690844e-01, 7.386214e-01, 1.145504e+00, 1.716563e+00,
2.443353e+00, 3.283689e+00, 4.184745e+00, 5.080073e+00, 5.893442e+00, 6.546659e+00, 6.980054e+00, 7.150451e+00, 7.039760e+00, 6.653884e+00,
6.033344e+00, 5.240736e+00, 4.364490e+00, 3.488565e+00, 2.677145e+00, 1.975665e+00, 1.411421e+00, 9.921453e-01, 7.066775e-01, 5.266718e-01,
4.271196e-01, 3.924719e-01, 4.133705e-01, 4.695568e-01, 5.348714e-01, 5.759546e-01, 5.631329e-01, 5.025344e-01, 4.130699e-01, 3.141471e-01,
2.215556e-01, 1.447194e-01, 8.790208e-02, 5.098624e-02, 3.014762e-02, 1.910260e-02, 1.344742e-02, 1.065112e-02, 9.321387e-03, 8.835730e-03,
8.816743e-03, 8.942431e-03, 8.948472e-03, 8.794572e-03, 8.501278e-03, 8.093566e-03, 7.602140e-03, 7.072520e-03, 6.550003e-03, 6.074361e-03,
5.673101e-03, 5.343198e-03, 5.075543e-03, 4.861257e-03, 4.688752e-03, 4.544127e-03, 4.404867e-03, 4.250920e-03, 4.077948e-03, 3.889586e-03,
3.704711e-03, 3.541290e-03, 3.403317e-03, 3.289065e-03, 3.187416e-03, 3.087250e-03, 2.984974e-03, 2.880152e-03, 2.777254e-03, 2.680905e-03, 2.592347e-03, 2.511498e-03, 2.436366e-03, 2.364864e-03, 2.296123e-03, 2.229745e-03, 2.165964e-03, 2.105085e-03, 2.047108e-03, 1.991933e-03, 1.939349e-03, 1.889138e-03, 1.841124e-03, 1.795147e-03, 1.751063e-03, 1.708734e-03, 1.668043e-03, 1.628947e-03, 1.591417e-03, 1.555428e-03,
1.520928e-03, 1.487760e-03, 1.455745e-03, 1.424711e-03, 1.394546e-03, 1.365347e-03, 1.337263e-03, 1.310441e-03, 1.284943e-03, 1.260516e-03,
1.236840e-03, 1.213614e-03, 1.190628e-03, 1.167988e-03, 1.145885e-03, 1.124552e-03, 1.104209e-03, 1.084995e-03, 1.067065e-03, 1.050736e-03,
1.035943e-03, 1.020968e-03, 1.003863e-03, 9.833325e-04, 9.592756e-04, 9.355316e-04, 9.172070e-04, 9.110385e-04, 9.202415e-04, 9.318257e-04,
9.283292e-04, 8.961524e-04, 8.376603e-04, 7.670913e-04, 7.256675e-04, 7.485672e-04, 8.356126e-04, 9.654478e-04, 1.042324e-03, 9.663562e-04,
7.592500e-04, 5.156526e-04, 3.910638e-04, 4.753052e-04, 8.290892e-04, 1.517836e-03, 2.148325e-03, 2.052454e-03, 1.269326e-03, 4.111317e-04,
8.685183e-05, 1.546110e-04, 9.204908e-04, 3.439569e-03, 6.646307e-03, 7.001711e-03, 4.076310e-03, 8.055459e-04, 6.350488e-10, 2.312147e-06,
1.584547e-03, 1.315706e-02, 4.601747e-02, NA)
and this is my return:
c(-0.935414347, -0.908840790, -0.882955147, -0.857722698, -0.833111287, -0.809091076, -0.785634328, -0.762715212, -0.740309633, -0.718395083,
-0.696950500, -0.675956149, -0.655393513, -0.635245193, -0.615494824, -0.596126988, -0.577127150, -0.558481585, -0.540177322, -0.522202092,
-0.504544274, -0.487192852, -0.470137374, -0.453367914, -0.436875037, -0.420649768, -0.404683560, -0.388968270, -0.373496135, -0.358259744,
-0.343252021, -0.328466203, -0.313895825, -0.299534697, -0.285376894, -0.271416740, -0.257648791, -0.244067828, -0.230668838, -0.217447010,
-0.204397720, -0.191516523, -0.178799144, -0.166241467, -0.153839531, -0.141589522, -0.129487761, -0.117530703, -0.105714928, -0.094037138,
-0.082494145, -0.071082874, -0.059800353, -0.048643708, -0.037610161, -0.026697027, -0.015901704, -0.005221677, 0.005345492, 0.015802162,
0.026150621, 0.036393085, 0.046531703, 0.056568562, 0.066505681, 0.076345025, 0.086088499, 0.095737954, 0.105295185, 0.114761940,
0.124139915, 0.133430760, 0.142636079, 0.151757433, 0.160796339, 0.169754274, 0.178632677, 0.187432947, 0.196156448, 0.204804506,
0.213378417, 0.221879440, 0.230308804, 0.238667708, 0.246957319, 0.255178777, 0.263333194, 0.271421653, 0.279445214, 0.287404910,
0.295301748, 0.303136715, 0.310910773, 0.318624860, 0.326279895, 0.333876775, 0.341416378, 0.348899561, 0.356327161, 0.363699998,
0.371018874, 0.378284573, 0.385497862, 0.392659493, 0.399770198, 0.406830699, 0.413841698, 0.420803885, 0.427717934, 0.434584508,
0.441404253, 0.448177805, 0.454905784, 0.461588799, 0.468227448, 0.474822316, 0.481373976, 0.487882992, 0.494349914, 0.500775283,
0.507159631, 0.513503477, 0.519807332, 0.526071697, 0.532297065, 0.538483916, 0.544632726, 0.550743959, 0.556818072, 0.562855512,
0.568856721, 0.574822129, 0.580752162, 0.586647238, 0.592507765, 0.598334146, 0.604126777, 0.609886046, 0.615612336, 0.621306023, 0.626967475, 0.632597055, 0.638195120, 0.643762022, 0.649298104, 0.654803707, 0.660279164, 0.665724804, 0.671140949, 0.676527917,
0.681886022, 0.687215570, 0.692516865, 0.697790204, 0.703035881, 0.708254184, 0.713445397, 0.718609802, 0.723747672, 0.728859279,
0.733944890, 0.739004769, 0.744039175, 0.749048362, 0.754032582, 0.758992083, 0.763927108, 0.768837899, 0.773724691, 0.778587719,
0.783427212, 0.788243398, 0.793036498, 0.797806735, 0.802554324, 0.807279480, 0.811982414, 0.816663334, 0.821322445, 0.825959950,
0.830576047, 0.835170933, 0.839744804, 0.844297849, 0.848830257, 0.853342216, 0.857833908, 0.862305516, 0.866757217, 0.871189188, 0.875601603, 0.879994635, 0.884368452, 0.888723222, 0.893059110, 0.897376280, 0.901674891, 0.905955104, 0.910217074, 0.914460957, 0.918686906, 0.922895071, 0.927085602, 0.931258645, 0.935414347)
The return is longer than the density, since I divided by the difference above.

Bootstrap p value contradicts p value for likelihood ratio test

I have the same problem as the one posted by #soapsuds here. I did not want to ask a duplicate question but when I tried to edit the original question to provide the reproducible example that was missing in the original post my edits got rejected. Since the reproducible example has a lot of elements, I could not write it as a comment to the original question either, so I provide my code and my reproducible data here, as a separate question.
I am trying to compare two models using the likelihood ratio test. From bootstrapping I get a set of 1000 p-values. Here are the numbers I get:
chi2 <- c(41.83803376, 69.23970174, 42.5479637, 50.90208302, 39.18366824, 78.88589665, 28.88469406, 34.99980796, 85.80860848, 66.01750186, 29.06286, 46.43221576, 46.50523792, 59.87362884, 46.17274808, 77.97429928, 48.04404216, 12.88592623, 43.1883816, 33.24251471, 53.27310465, 56.92595147, 47.99838583, 46.0718587, 49.0760042, 29.70866297, 66.80696553, 66.61091741, 37.82375112, 50.19760846, 30.99961864, 27.17687828, 37.46944206, 66.36226432, 48.30737714, 43.64410333, 23.78480451, 42.52842793, 60.49309556, 46.29154, 26.96744296, 32.21561396, 48.20316788, 38.73153704, 67.80328765, 55.00664931, 36.74645735, 23.3647159, 56.35290442, 38.11055268, 58.3316501, 36.00500638, 41.36949956, 49.09067881, 64.42712507, 23.97787069, 54.5394799, 87.02114296, 26.01402166, 50.47426712, 38.58006084, 48.47626864, 22.28809699, 58.87590487, 17.59264288, 33.32650413, 67.77868338, 60.95427815, 37.19931376, 36.23280256, 53.54379697, 70.06479334, 41.3482703, 34.54099647, 55.99585144, 30.60500406, 32.02745276, 37.92670127, 44.23450124, 40.38607671, 44.02263294, 40.89874789, 62.74174279, 50.95137406, 47.12851204, 26.03848394, 36.6202765, 61.06296311, 50.17094183, 35.93242228, 41.8913277, 35.19089913, 38.88574534, 66.075866, 26.34296242, 49.99887059, 42.97123036, 34.89006324, 66.5460019, 67.61855859, 48.52166614, 41.41324193, 46.76294302, 14.87650733, 24.11661382, 62.28747719, 43.94865019, 44.20328393, 41.17756328, 43.74055584, 49.46236395, 38.59558107, 42.85073398, 49.81046036, 36.60331917, 39.85328124, 59.31376822, 61.36038822, 52.56707689, 29.19196892, 46.473958, 39.12904163, 38.75057931, 36.32493909, 49.61088785, 33.42904297, 34.73661836, 33.97736002, 37.44094284, 57.73605417, 43.14773064, 42.78707831, 26.84112684, 48.47832871, 45.94043053, 71.13563773, 46.28614795, 42.33386157, 59.31216832, 46.72946806, 47.76027545, 52.45174304, 49.99459367, 59.00971014, 24.03299408, 17.09453132, 37.44112252, 46.6352525, 60.42442286, 39.35194465, 46.57121135, 56.28622077, 59.20354176, 57.72511864, 41.97053375, 27.97077407, 29.70497125, 46.63976021, 40.24305901, 24.84335714, 36.08600444, 61.619572, 69.31377401, 86.91496878, 44.47955842, 44.1230351, 46.12514671, 43.97381958, 71.99269072, 47.01277643, 50.08167664, 27.01076954, 31.32586466, 40.96782215, 19.07024825, 53.00009679, 43.15397869, 42.49652848, 53.47325607, 43.45891027, 42.57719313, 39.40459925, 42.15077856, 52.23784844, 33.07947933, 45.02462309, 59.187763, 51.9198527, 48.3179841, 76.10501177, 34.95091433, 40.75545034, 31.27034043, 39.83209227, 47.87278051, 46.25057806, 62.84591205, 41.24656655, 68.14749236, 53.11576938, 39.20515676, 61.96116013, 35.64665684, 72.52689101, 54.64239536, 34.14169048, 34.32282338, 49.60786171, 50.32976034, 43.83560386, 57.49367366, 81.65759842, 61.59398941, 37.77960776, 30.74484476, 34.72859511, 32.46631033, 37.41725027, 34.04569722, 54.11932007, 34.62264522, 28.36753913, 30.95379445, 84.06354755, 29.32445434, 56.7720931, 33.23951864, 48.61860157, 39.3563214, 32.44713462, 61.25078174, 32.49661836, 40.38508488, 26.73565294, 58.16191656, 61.12461262, 23.701462, 22.14004554, 57.80213129, 57.15936762, 31.51238062, 44.60223083, 30.60135802, 46.96637333, 42.79517081, 56.85541543, 48.79421654, 29.72862307, 41.61735121, 43.37983393, 41.16802781, 61.69637392, 37.29991153, 39.0936012, 57.39158494, 57.55033901, 50.72878897, 34.82491685, 42.66486539, 34.54565803, 55.04161695, 44.56687339, 53.46745359, 57.22210412, 34.8578696, 28.81098073, 51.4033337, 51.9568532, 60.98717632, 62.98817996, 44.1335128, 33.38418814, 59.71059054, 45.82016411, 29.47178401, 30.64995791, 28.52106318, 53.98066153, 64.22209517, 58.29438562, 39.18280924, 38.1302144, 41.90062316, 28.68650929, 69.42769639, 33.79539164, 26.08549507, 55.29167497, 97.25975259, 63.07957724, 56.59002373, 51.40088678, 71.33491023, 46.24955174, 33.90101761, 38.0669817, 52.50993176, 51.84637529, 39.93642798, 61.9268346, 30.25561485, 49.57396856, 44.70170977, 57.00286149, 40.39009586, 63.23642634, 59.23643766, 55.80521902, 68.58421775, 24.04456631, 51.64338572, 61.14103174, 59.29371792, 46.51493959, 43.48297587, 39.99164284, 44.62589755, 58.89385062, 60.96824416, 54.02310453, 43.54420281, 44.24628098, 47.0991445, 58.9015349, 60.54157696, 34.86277089, 33.79969585, 34.57183642, 47.21383117, 55.3529805, 36.49813553, 44.94388291, 29.43134497, 43.41469037, 43.033338, 63.37329389, 38.22029171, 43.2894392, 23.42769168, 55.18117532, 19.39227876, 28.29656641, 28.56075122, 39.57260362, 65.48606054, 31.05339648, 24.87488959, 61.6027878, 59.56983406, 37.53918879, 28.67095839, 36.51499868, 44.43350204, 53.35842664, 48.30182354, 31.03494822, 45.68689659, 46.11113306, 53.89204524, 29.75548276, 35.60906482, 53.35195594, 56.28657675, 44.77245145, 60.20671942, 41.62253735, 40.34528594, 38.48551456, 27.39317425, 51.05414332, 38.41986986, 75.05074423, 34.16773046, 52.18497954, 49.63059496, 28.7365636, 10.59466471, 38.1033901, 52.20531405, 47.031987, 47.45955635, 44.64312012, 50.32229588, 62.40798968, 37.7455721, 31.97746406, 51.17250147, 45.91231295, 66.58450378, 32.68956686, 34.35845347, 70.34703042, 41.47493453, 53.67684859, 35.66735299, 19.76630329, 35.69026569, 76.57475236, 62.11269107, 37.06632602, 57.91686258, 33.95869501, 55.18034702, 66.09725866, 46.80608564, 46.75623531, 55.49605214, 45.7813294, 22.37612777, 62.40414132, 50.51745906, 46.86535062, 54.4172637, 35.44713601, 45.40918234, 43.83215257, 57.14754799, 24.20941074, 44.8145542, 50.79673435, 42.14561269, 32.73720673, 28.51047028, 32.14753623, 28.43006627, 39.50188334, 58.51806717, 37.96898151, 73.14656287, 48.23605238, 75.31273481, 29.57608972, 43.62952257, 30.47534709, 43.24927262, 43.61475563, 53.48883918, 53.85263136, 41.91477406, 56.16405384, 46.21202327, 55.52602904, 49.88481191, 46.31478116, 72.29722834, 40.48187205, 35.31368051, 40.57713079, 34.15725967, 65.85738596, 32.16093944, 32.07117679, 46.44579516, 53.3243447, 69.35531671, 21.70205174, 44.30678622, 40.13349937, 51.7431728, 43.03690121, 26.53566586, 18.74773427, 25.97768442, 66.68668827, 42.97352559, 31.61567696, 61.57362103, 55.07104736, 25.05950764, 53.04884067, 30.47176616, 43.33249885, 44.48360752, 40.59006165, 44.29759954, 69.71063388, 47.70186943, 51.12166943, 40.15048072, 44.96459746, 56.31842906, 57.79593771, 49.19795057, 33.58506451, 42.67650993, 47.96512915, 57.98722437, 42.08107371, 66.85903821, 45.30286487, 38.39187118, 48.02442004, 35.97047743, 56.71378254, 40.51082047, 43.78022461, 60.33208664, 35.78159098, 40.98937317, 36.20547787, 45.2382906, 47.81497885, 20.44519563, 16.68817267, 38.31035896, 38.60590267, 70.75756511, 31.73001452, 45.85476281, 47.11473565, 31.40248172, 42.94971714, 39.34376633, 21.09018956, 31.45915941, 53.82696054, 73.59824534, 31.5694168, 39.02189966, 46.91790827, 60.66603832, 59.81148782, 20.46813743, 54.95108785, 66.71844123, 49.48461319, 25.10459028, 60.26169536, 21.90344297, 63.56310687, 38.70295559, 58.19794152, 25.68981924, 61.4804908, 41.97067608, 22.77156359, 48.51789441, 50.31845297, 42.36456456, 43.35814281, 41.32891651, 35.17106573, 48.45296117, 30.55292595, 55.26758567, 71.25929921, 34.62580089, 43.89804598, 46.06384675, 30.74209253, 47.99143497, 34.02715801, 37.95367551, 45.14366438, 40.73655716, 45.32116105, 48.17651965, 63.54774876, 16.32237452, 54.22730144, 46.02331286, 45.44633826, 53.56976595, 53.96781286, 19.79116777, 42.05820938, 45.48852278, 37.34932167, 45.134461, 49.60637239, 29.99017683, 35.2785614, 71.54855053, 61.55744768, 55.7627296, 37.72455372, 62.51288842, 48.17063649, 65.26648616, 48.4831201, 33.49833137, 32.10986243, 15.42586026, 41.95660905, 30.07072484, 42.33604863, 53.20660203, 48.27036556, 32.92677161, 33.59521848, 44.04333058, 59.30038922, 48.84064622, 63.31815488, 36.01169023, 44.42967033, 23.14247159, 53.6314237, 42.43225997, 28.18151375, 44.0733306, 55.93530003, 30.86515779, 34.10702034, 59.38495522, 57.79906004, 64.86160093, 56.70670687, 43.24880707, 40.00049219, 44.08430336, 17.50391283, 72.81320114, 41.55481964, 63.461066, 50.81938548, 58.7427594, 35.27822458, 33.5188344, 46.13196979, 56.94022883, 66.96258461, 39.19601268, 21.95750575, 51.67252792, 46.51047909, 30.42289547, 46.47496475, 41.6440483, 42.36900563, 68.29398345, 30.14059255, 38.90124252, 40.87014585, 51.33635945, 51.72908337, 50.8177621, 31.65411733, 56.75197699, 47.76885318, 34.18305356, 52.52137441, 48.39806899, 18.34609209, 32.5461584, 60.15104883, 36.29250847, 39.02418361, 34.68801402, 48.02453889, 31.36738248, 42.44522981, 71.79176852, 34.25588794, 38.46866138, 45.01393624, 63.38509325, 32.44823195, 64.59346474, 53.80793998, 41.2889141, 28.86534461, 34.85039051, 37.04622686, 31.83207726, 36.65410743, 27.66293315, 23.11203257, 41.61059067, 19.97321534, 59.879676, 39.84187157, 47.324581, 38.24903991, 41.0234849, 62.30809429, 48.47191326, 23.26696808, 29.91547934, 78.39181209, 41.86240014, 33.53717515, 39.63756903, 74.86377649, 56.30173648, 40.29403413, 59.12602764, 47.23561802, 51.32370456, 45.44426051, 55.54666292, 58.85362888, 38.30516953, 46.11300177, 37.96931091, 41.01315149, 63.09345867, 26.74145771, 31.37447907, 39.26896396, 65.35880308, 60.0670218, 45.48057201, 29.76683425, 51.39638136, 46.12180705, 60.72093818, 45.01613513, 37.04611291, 31.32979098, 57.82548455, 29.89919764, 38.77980495, 55.71511912, 66.9872235, 48.74616069, 32.87503301, 56.10335632, 28.72445387, 41.00675821, 55.22238115, 38.56391412, 21.82487917, 51.87394855, 41.62740713, 72.32943223, 49.85456187, 41.76869194, 55.686196, 46.18471338, 52.57455653, 23.03383172, 51.460223, 45.88045256, 47.91709836, 53.09464847, 65.17159616, 48.0076358, 42.50038253, 50.57143193, 22.05776575, 25.5770314, 57.41889173, 37.07408252, 69.83286794, 53.31690771, 36.14562381, 35.3626014, 70.74448842, 30.01870438, 41.95755074, 64.41141845, 48.12704663, 29.33183678, 47.45391445, 35.76760392, 17.57864013, 42.66918162, 27.84884911, 37.83419437, 56.38203205, 32.93395446, 19.45549279, 48.49557175, 63.74692618, 48.36501421, 38.45370018, 63.77499738, 43.40984685, 61.28735474, 47.00513455, 31.82012086, 40.85624032, 32.79590137, 43.79441893, 47.93350586, 26.44410209, 22.71480768, 41.74097624, 29.7828174, 35.24077319, 37.1436077, 63.62150539, 35.27952907, 30.9258966, 35.22384343, 45.0069715, 47.38652625, 60.86474384, 53.19528479, 37.61239521, 64.78497877, 39.50008676, 43.11733875, 34.67761458, 55.21401193, 57.22836509, 30.10411603, 30.03903287, 53.62027996, 40.63516283, 50.229386, 39.59707517, 55.53993024, 62.31160356, 48.65142538, 59.51279601, 51.46268896, 36.70086545, 45.73324953, 39.82026282, 51.51657943, 39.9507342, 26.65847555, 18.11032673, 41.57393548, 37.24804734, 59.78878572, 42.18870686, 57.73556775, 29.83442692, 24.27687775, 44.54663257, 48.40426261, 34.13830576, 64.47843419, 53.82888778, 45.77073351, 41.95910655, 56.25654343, 42.44938602, 18.92651056, 62.89841562, 42.28210051, 60.01632343, 56.38799965, 53.56842386, 71.059581, 59.21196097, 72.29678294, 40.0820475, 74.53163756, 46.35508897, 48.65592196, 36.69711286, 54.84914739, 57.62299813, 63.0750109, 25.53592874, 19.43203054, 63.18532427, 54.79806194, 28.75123602, 47.68037559, 36.06887062, 48.53619627, 42.05208952, 14.47366507, 26.25183654, 57.37741978, 24.92962789, 47.85306044, 35.55674275, 43.62606531, 51.98445971, 57.10441923, 45.20539557, 43.22417529, 48.20941756, 37.12416781, 39.54238987, 45.31000358, 24.59001204, 32.61256929, 31.61553515, 55.76617515, 57.82479513, 34.12465645, 52.1634834, 50.140277, 34.5334757, 70.76112738, 47.22161503, 35.44101995, 54.50312705, 47.74706989, 21.04494842, 42.42698916, 57.8551517, 49.67127478, 67.6702045, 30.64335682, 31.87819093, 45.79096976, 42.72129981, 56.22043416, 22.12571532, 31.93377902, 31.9561172, 60.28281847, 37.49005649, 30.63141229, 22.82707918, 29.55804713, 55.79929136, 39.64043613, 31.79538118, 61.92391469, 19.30462724, 37.00041938, 61.26446455, 47.10048686, 34.70929308, 33.34157984, 49.28331646, 39.9565451, 48.80158593, 29.25279435, 49.96980394, 68.7766356, 49.61949286, 18.80600378, 52.93721773, 24.29791779, 67.69568275, 54.22725318, 35.67531845, 58.05037476, 70.54029077, 55.59508174, 42.07974012, 61.62117032, 44.47174079, 40.13197612, 61.19863058, 35.16748823, 54.79320966, 46.40640448, 41.99222891, 53.33216862, 19.04146695, 29.60278169, 38.43089591, 61.22497978, 32.04678119, 30.77915985, 38.02625789, 74.25140223, 30.44626923, 42.69951906, 28.99988779, 49.76041564, 30.86941271, 58.65788956, 62.64967161, 23.5689175, 42.21941421, 54.88455829, 38.10115824, 24.12341961, 32.84464782, 81.72102673, 42.42771851, 37.75191241, 32.05927543, 43.55812503, 64.79161154, 61.05179286, 53.24693267, 36.29056269, 61.49030629, 53.68500702, 65.93501988, 50.7243041, 51.72139759, 64.80610623, 58.2860023, 33.16444766, 42.7872046, 55.14190562, 39.14341079, 36.05577261, 30.03351742, 24.16526837, 47.94163599, 52.55045103, 56.60625705, 61.6878126, 23.13212844, 50.50369148, 47.79873905, 47.01238239, 35.9159739, 53.18067189, 48.42928497, 67.48879213, 37.37609292, 19.7749038, 47.87115046, 48.90378974)
p.values <- c(9.92E-11, 8.72E-17, 6.90E-11, 9.71E-13, 3.86E-10, 6.58E-19, 7.68E-08, 3.30E-09, 1.98E-20, 4.47E-16, 7.01E-08, 9.48E-12, 9.14E-12, 1.01E-14, 1.08E-11, 1.04E-18, 4.17E-12, 0.000331062, 4.97E-11, 8.14E-09, 2.90E-13, 4.53E-14, 4.27E-12, 1.14E-11, 2.46E-12, 5.02E-08, 2.99E-16, 3.31E-16, 7.74E-10, 1.39E-12, 2.58E-08, 1.86E-07, 9.29E-10, 3.75E-16, 3.64E-12, 3.94E-11, 1.08E-06, 6.97E-11, 7.38E-15, 1.02E-11, 2.07E-07, 1.38E-08, 3.84E-12, 4.86E-10, 1.81E-16, 1.20E-13, 1.35E-09, 1.34E-06, 6.06E-14, 6.68E-10, 2.21E-14, 1.97E-09, 1.26E-10, 2.44E-12, 1.00E-15, 9.74E-07, 1.52E-13, 1.07E-20, 3.39E-07, 1.21E-12, 5.26E-10, 3.34E-12, 2.35E-06, 1.68E-14, 2.74E-05, 7.79E-09, 1.83E-16, 5.84E-15, 1.07E-09, 1.75E-09, 2.53E-13, 5.74E-17, 1.27E-10, 4.17E-09, 7.26E-14, 3.16E-08, 1.52E-08, 7.35E-10, 2.91E-11, 2.08E-10, 3.25E-11, 1.60E-10, 2.36E-15, 9.47E-13, 6.65E-12, 3.35E-07, 1.44E-09, 5.53E-15, 1.41E-12, 2.04E-09, 9.65E-11, 2.99E-09, 4.49E-10, 4.34E-16, 2.86E-07, 1.54E-12, 5.56E-11, 3.49E-09, 3.42E-16, 1.98E-16, 3.27E-12, 1.23E-10, 8.01E-12, 0.000114784, 9.07E-07, 2.97E-15, 3.37E-11, 2.96E-11, 1.39E-10, 3.75E-11, 2.02E-12, 5.21E-10, 5.91E-11, 1.69E-12, 1.45E-09, 2.74E-10, 1.34E-14, 4.75E-15, 4.16E-13, 6.56E-08, 9.28E-12, 3.97E-10, 4.82E-10, 1.67E-09, 1.87E-12, 7.39E-09, 3.77E-09, 5.58E-09, 9.42E-10, 3.00E-14, 5.08E-11, 6.10E-11, 2.21E-07, 3.34E-12, 1.22E-11, 3.33E-17, 1.02E-11, 7.69E-11, 1.35E-14, 8.15E-12, 4.82E-12, 4.41E-13, 1.54E-12, 1.57E-14, 9.47E-07, 3.56E-05, 9.42E-10, 8.55E-12, 7.65E-15, 3.54E-10, 8.83E-12, 6.27E-14, 1.42E-14, 3.01E-14, 9.27E-11, 1.23E-07, 5.03E-08, 8.53E-12, 2.24E-10, 6.22E-07, 1.89E-09, 4.17E-15, 8.40E-17, 1.13E-20, 2.57E-11, 3.08E-11, 1.11E-11, 3.33E-11, 2.16E-17, 7.05E-12, 1.47E-12, 2.02E-07, 2.18E-08, 1.55E-10, 1.26E-05, 3.34E-13, 5.06E-11, 7.08E-11, 2.62E-13, 4.33E-11, 6.79E-11, 3.44E-10, 8.45E-11, 4.92E-13, 8.85E-09, 1.95E-11, 1.43E-14, 5.78E-13, 3.62E-12, 2.69E-18, 3.38E-09, 1.73E-10, 2.24E-08, 2.77E-10, 4.55E-12, 1.04E-11, 2.24E-15, 1.34E-10, 1.52E-16, 3.14E-13, 3.82E-10, 3.50E-15, 2.37E-09, 1.65E-17, 1.45E-13, 5.12E-09, 4.67E-09, 1.88E-12, 1.30E-12, 3.57E-11, 3.39E-14, 1.62E-19, 4.22E-15, 7.92E-10, 2.94E-08, 3.79E-09, 1.21E-08, 9.54E-10, 5.38E-09, 1.89E-13, 4.00E-09, 1.00E-07, 2.64E-08, 4.79E-20, 6.12E-08, 4.89E-14, 8.15E-09, 3.11E-12, 3.53E-10, 1.22E-08, 5.02E-15, 1.19E-08, 2.09E-10, 2.33E-07, 2.41E-14, 5.36E-15, 1.12E-06, 2.53E-06, 2.90E-14, 4.02E-14, 1.98E-08, 2.41E-11, 3.17E-08, 7.22E-12, 6.08E-11, 4.69E-14, 2.84E-12, 4.97E-08, 1.11E-10, 4.51E-11, 1.40E-10, 4.01E-15, 1.01E-09, 4.04E-10, 3.57E-14, 3.29E-14, 1.06E-12, 3.61E-09, 6.50E-11, 4.16E-09, 1.18E-13, 2.46E-11, 2.63E-13, 3.89E-14, 3.55E-09, 7.98E-08, 7.52E-13, 5.67E-13, 5.74E-15, 2.08E-15, 3.07E-11, 7.56E-09, 1.10E-14, 1.30E-11, 5.67E-08, 3.09E-08, 9.27E-08, 2.02E-13, 1.11E-15, 2.26E-14, 3.86E-10, 6.62E-10, 9.60E-11, 8.51E-08, 7.93E-17, 6.12E-09, 3.27E-07, 1.04E-13, 6.08E-23, 1.99E-15, 5.37E-14, 7.53E-13, 3.01E-17, 1.04E-11, 5.80E-09, 6.84E-10, 4.28E-13, 6.00E-13, 2.62E-10, 3.56E-15, 3.79E-08, 1.91E-12, 2.29E-11, 4.35E-14, 2.08E-10, 1.83E-15, 1.40E-14, 8.00E-14, 1.22E-16, 9.41E-07, 6.66E-13, 5.31E-15, 1.36E-14, 9.09E-12, 4.28E-11, 2.55E-10, 2.39E-11, 1.66E-14, 5.80E-15, 1.98E-13, 4.14E-11, 2.90E-11, 6.75E-12, 1.66E-14, 7.20E-15, 3.54E-09, 6.11E-09, 4.11E-09, 6.36E-12, 1.01E-13, 1.53E-09, 2.03E-11, 5.79E-08, 4.43E-11, 5.38E-11, 1.71E-15, 6.32E-10, 4.72E-11, 1.30E-06, 1.10E-13, 1.06E-05, 1.04E-07, 9.08E-08, 3.16E-10, 5.85E-16, 2.51E-08, 6.12E-07, 4.20E-15, 1.18E-14, 8.96E-10, 8.58E-08, 1.51E-09, 2.63E-11, 2.78E-13, 3.65E-12, 2.53E-08, 1.39E-11, 1.12E-11, 2.12E-13, 4.90E-08, 2.41E-09, 2.79E-13, 6.26E-14, 2.21E-11, 8.54E-15, 1.11E-10, 2.13E-10, 5.52E-10, 1.66E-07, 8.99E-13, 5.70E-10, 4.59E-18, 5.06E-09, 5.05E-13, 1.86E-12, 8.29E-08, 0.001134145, 6.71E-10, 5.00E-13, 6.98E-12, 5.62E-12, 2.36E-11, 1.30E-12, 2.79E-15, 8.06E-10, 1.56E-08, 8.46E-13, 1.24E-11, 3.35E-16, 1.08E-08, 4.58E-09, 4.97E-17, 1.19E-10, 2.36E-13, 2.34E-09, 8.75E-06, 2.31E-09, 2.12E-18, 3.24E-15, 1.14E-09, 2.73E-14, 5.63E-09, 1.10E-13, 4.29E-16, 7.84E-12, 8.04E-12, 9.36E-14, 1.32E-11, 2.24E-06, 2.80E-15, 1.18E-12, 7.60E-12, 1.62E-13, 2.62E-09, 1.60E-11, 3.58E-11, 4.04E-14, 8.64E-07, 2.17E-11, 1.02E-12, 8.47E-11, 1.05E-08, 9.32E-08, 1.43E-08, 9.71E-08, 3.28E-10, 2.01E-14, 7.19E-10, 1.20E-17, 3.78E-12, 4.02E-18, 5.38E-08, 3.97E-11, 3.38E-08, 4.82E-11, 4.00E-11, 2.60E-13, 2.16E-13, 9.53E-11, 6.67E-14, 1.06E-11, 9.22E-14, 1.63E-12, 1.01E-11, 1.85E-17, 1.98E-10, 2.81E-09, 1.89E-10, 5.08E-09, 4.85E-16, 1.42E-08, 1.49E-08, 9.42E-12, 2.83E-13, 8.22E-17, 3.18E-06, 2.81E-11, 2.37E-10, 6.33E-13, 5.37E-11, 2.59E-07, 1.49E-05, 3.45E-07, 3.18E-16, 5.55E-11, 1.88E-08, 4.26E-15, 1.16E-13, 5.56E-07, 3.25E-13, 3.39E-08, 4.62E-11, 2.56E-11, 1.88E-10, 2.82E-11, 6.87E-17, 4.96E-12, 8.68E-13, 2.35E-10, 2.01E-11, 6.16E-14, 2.91E-14, 2.31E-12, 6.82E-09, 6.46E-11, 4.34E-12, 2.64E-14, 8.76E-11, 2.92E-16, 1.69E-11, 5.79E-10, 4.21E-12, 2.00E-09, 5.04E-14, 1.96E-10, 3.67E-11, 8.01E-15, 2.21E-09, 1.53E-10, 1.78E-09, 1.74E-11, 4.68E-12, 6.14E-06, 4.41E-05, 6.03E-10, 5.19E-10, 4.04E-17, 1.77E-08, 1.27E-11, 6.70E-12, 2.10E-08, 5.62E-11, 3.55E-10, 4.38E-06, 2.04E-08, 2.19E-13, 9.57E-18, 1.92E-08, 4.19E-10, 7.40E-12, 6.76E-15, 1.04E-14, 6.06E-06, 1.24E-13, 3.13E-16, 2.00E-12, 5.43E-07, 8.30E-15, 2.87E-06, 1.55E-15, 4.93E-10, 2.37E-14, 4.01E-07, 4.47E-15, 9.27E-11, 1.82E-06, 3.27E-12, 1.31E-12, 7.58E-11, 4.56E-11, 1.29E-10, 3.02E-09, 3.38E-12, 3.25E-08, 1.05E-13, 3.13E-17, 4.00E-09, 3.46E-11, 1.14E-11, 2.95E-08, 4.28E-12, 5.43E-09, 7.24E-10, 1.83E-11, 1.74E-10, 1.67E-11, 3.90E-12, 1.57E-15, 5.34E-05, 1.79E-13, 1.17E-11, 1.57E-11, 2.50E-13, 2.04E-13, 8.64E-06, 8.86E-11, 1.54E-11, 9.88E-10, 1.84E-11, 1.88E-12, 4.34E-08, 2.86E-09, 2.71E-17, 4.30E-15, 8.18E-14, 8.15E-10, 2.65E-15, 3.91E-12, 6.54E-16, 3.33E-12, 7.13E-09, 1.46E-08, 8.58E-05, 9.33E-11, 4.17E-08, 7.69E-11, 3.00E-13, 3.71E-12, 9.57E-09, 6.79E-09, 3.21E-11, 1.35E-14, 2.78E-12, 1.76E-15, 1.96E-09, 2.64E-11, 1.50E-06, 2.42E-13, 7.32E-11, 1.10E-07, 3.16E-11, 7.49E-14, 2.77E-08, 5.22E-09, 1.30E-14, 2.90E-14, 8.03E-16, 5.06E-14, 4.82E-11, 2.54E-10, 3.15E-11, 2.87E-05, 1.43E-17, 1.15E-10, 1.64E-15, 1.01E-12, 1.80E-14, 2.86E-09, 7.06E-09, 1.11E-11, 4.49E-14, 2.77E-16, 3.83E-10, 2.79E-06, 6.56E-13, 9.11E-12, 3.47E-08, 9.28E-12, 1.09E-10, 7.56E-11, 1.41E-16, 4.02E-08, 4.46E-10, 1.63E-10, 7.78E-13, 6.37E-13, 1.01E-12, 1.84E-08, 4.94E-14, 4.80E-12, 5.02E-09, 4.26E-13, 3.48E-12, 1.84E-05, 1.16E-08, 8.79E-15, 1.70E-09, 4.19E-10, 3.87E-09, 4.21E-12, 2.14E-08, 7.27E-11, 2.39E-17, 4.83E-09, 5.56E-10, 1.96E-11, 1.70E-15, 1.22E-08, 9.21E-16, 2.21E-13, 1.31E-10, 7.76E-08, 3.56E-09, 1.15E-09, 1.68E-08, 1.41E-09, 1.44E-07, 1.53E-06, 1.11E-10, 7.85E-06, 1.01E-14, 2.75E-10, 6.02E-12, 6.23E-10, 1.50E-10, 2.94E-15, 3.35E-12, 1.41E-06, 4.51E-08, 8.45E-19, 9.79E-11, 6.99E-09, 3.06E-10, 5.04E-18, 6.22E-14, 2.18E-10, 1.48E-14, 6.29E-12, 7.83E-13, 1.57E-11, 9.13E-14, 1.70E-14, 6.05E-10, 1.12E-11, 7.19E-10, 1.51E-10, 1.97E-15, 2.33E-07, 2.13E-08, 3.69E-10, 6.24E-16, 9.17E-15, 1.54E-11, 4.87E-08, 7.55E-13, 1.11E-11, 6.58E-15, 1.95E-11, 1.15E-09, 2.18E-08, 2.86E-14, 4.55E-08, 4.74E-10, 8.38E-14, 2.73E-16, 2.91E-12, 9.83E-09, 6.88E-14, 8.34E-08, 1.52E-10, 1.08E-13, 5.30E-10, 2.99E-06, 5.92E-13, 1.10E-10, 1.82E-17, 1.66E-12, 1.03E-10, 8.50E-14, 1.08E-11, 4.14E-13, 1.59E-06, 7.31E-13, 1.26E-11, 4.45E-12, 3.18E-13, 6.87E-16, 4.25E-12, 7.07E-11, 1.15E-12, 2.65E-06, 4.25E-07, 3.52E-14, 1.14E-09, 6.45E-17, 2.84E-13, 1.83E-09, 2.74E-09, 4.07E-17, 4.28E-08, 9.33E-11, 1.01E-15, 3.99E-12, 6.10E-08, 5.63E-12, 2.22E-09, 2.76E-05, 6.48E-11, 1.31E-07, 7.70E-10, 5.97E-14, 9.53E-09, 1.03E-05, 3.31E-12, 1.41E-15, 3.54E-12, 5.61E-10, 1.39E-15, 4.44E-11, 4.93E-15, 7.08E-12, 1.69E-08, 1.64E-10, 1.02E-08, 3.65E-11, 4.41E-12, 2.71E-07, 1.88E-06, 1.04E-10, 4.83E-08, 2.91E-09, 1.10E-09, 1.51E-15, 2.86E-09, 2.68E-08, 2.94E-09, 1.96E-11, 5.83E-12, 6.11E-15, 3.02E-13, 8.63E-10, 8.35E-16, 3.28E-10, 5.16E-11, 3.89E-09, 1.08E-13, 3.88E-14, 4.09E-08, 4.23E-08, 2.43E-13, 1.83E-10, 1.37E-12, 3.12E-10, 9.16E-14, 2.93E-15, 3.06E-12, 1.22E-14, 7.30E-13, 1.38E-09, 1.36E-11, 2.78E-10, 7.10E-13, 2.60E-10, 2.43E-07, 2.08E-05, 1.13E-10, 1.04E-09, 1.06E-14, 8.29E-11, 3.00E-14, 4.71E-08, 8.34E-07, 2.48E-11, 3.47E-12, 5.13E-09, 9.76E-16, 2.19E-13, 1.33E-11, 9.32E-11, 6.36E-14, 7.25E-11, 1.36E-05, 2.18E-15, 7.90E-11, 9.41E-15, 5.95E-14, 2.50E-13, 3.47E-17, 1.42E-14, 1.85E-17, 2.44E-10, 5.97E-18, 9.87E-12, 3.05E-12, 1.38E-09, 1.30E-13, 3.17E-14, 1.99E-15, 4.34E-07, 1.04E-05, 1.88E-15, 1.34E-13, 8.23E-08, 5.02E-12, 1.90E-09, 3.24E-12, 8.89E-11, 0.000142133, 3.00E-07, 3.60E-14, 5.95E-07, 4.59E-12, 2.48E-09, 3.98E-11, 5.59E-13, 4.13E-14, 1.77E-11, 4.88E-11, 3.83E-12, 1.11E-09, 3.21E-10, 1.68E-11, 7.09E-07, 1.12E-08, 1.88E-08, 8.16E-14, 2.87E-14, 5.17E-09, 5.11E-13, 1.43E-12, 4.19E-09, 4.03E-17, 6.34E-12, 2.63E-09, 1.55E-13, 4.85E-12, 4.49E-06, 7.34E-11, 2.82E-14, 1.82E-12, 1.93E-16, 3.10E-08, 1.64E-08, 1.32E-11, 6.31E-11, 6.48E-14, 2.55E-06, 1.60E-08, 1.58E-08, 8.22E-15, 9.19E-10, 3.12E-08, 1.77E-06, 5.43E-08, 8.03E-14, 3.05E-10, 1.71E-08, 3.57E-15, 1.11E-05, 1.18E-09, 4.99E-15, 6.74E-12, 3.83E-09, 7.73E-09, 2.22E-12, 2.60E-10, 2.83E-12, 6.35E-08, 1.56E-12, 1.10E-16, 1.87E-12, 1.45E-05, 3.44E-13, 8.25E-07, 1.91E-16, 1.79E-13, 2.33E-09, 2.55E-14, 4.51E-17, 8.90E-14, 8.76E-11, 4.16E-15, 2.58E-11, 2.37E-10, 5.16E-15, 3.03E-09, 1.34E-13, 9.61E-12, 9.16E-11, 2.82E-13, 1.28E-05, 5.30E-08, 5.67E-10, 5.09E-15, 1.51E-08, 2.89E-08, 6.98E-10, 6.88E-18, 3.43E-08, 6.38E-11, 7.24E-08, 1.74E-12, 2.76E-08, 1.88E-14, 2.47E-15, 1.21E-06, 8.16E-11, 1.28E-13, 6.72E-10, 9.04E-07, 9.98E-09, 1.57E-19, 7.33E-11, 8.03E-10, 1.50E-08, 4.12E-11, 8.33E-16, 5.56E-15, 2.94E-13, 1.70E-09, 4.45E-15, 2.35E-13, 4.66E-16, 1.06E-12, 6.40E-13, 8.26E-16, 2.27E-14, 8.47E-09, 6.10E-11, 1.12E-13, 3.94E-10, 1.92E-09, 4.25E-08, 8.84E-07, 4.39E-12, 4.19E-13, 5.32E-14, 4.02E-15, 1.51E-06, 1.19E-12, 4.72E-12, 7.05E-12, 2.06E-09, 3.04E-13, 3.42E-12, 2.12E-16, 9.74E-10, 8.71E-06, 4.55E-12, 2.69E-12)
While p-values range from 6.08038E-23 to 0.001134145, the bootstrapped p-value I get is 0.4995005 and I don't understand why. I am using the following function to find the bootstrapped p-value:
(1+sum(logit.boot$t[,2] > logit.boot$t0[2]))/(1+logit.boot$R)
where logit.boot$t[,2] takes on values from the p.values vector, logit.boot$t0[2] equals 2.664684e-11 and logit.boot$R = 1000.
EDIT
Here is the code I used for bootstrapping:
logit.bootstrap <- function(data, indices){
d <- data[indices, ]
Mf1 <- glm(Y ~ A + B + C, data = d, family = "binomial")
data.setM1 <- na.omit(d[, all.vars(formula(Mf1))])
M1.io <- glm(Y ~ A + B, data = data.setM1, family = "binomial")
my.test <- lrtest(Mf1, M1.io)
return(c(my.test$"Chisq"[2], my.test$"Pr(>Chisq)"[2]))
}
logit.boot <- boot(data=my.data, statistic=logit.bootstrap, R=1000) # 10'000 samples
In the result of the boot function, t0 should the p value on the original data, and t is some p values which are generated from random resampling/permutation on the original data.
And in your case, you shouldn't use
(1+sum(logit.boot$t[,2] > logit.boot$t0[2]))/(1+logit.boot$R)
to get information from your bootstrapped p values, you may use
quantile(logit.boot$t[,2], c(0.025,0.975))
or something like this to obtain a bootstrapped 95% confidence interval on your p value. This is not very meaningful, since the meaning of p value is already a probability (confidence level), why do you bother to obtain a confidence interval for p value? And the validness of the bootstrap method relies on the correctness of your parametric model. So if you want to use non-parametric approach toward this problem, I think you need to find some other approaches instead of this one.

Why colors did not appear in Key of heatmap.2()

I have a data that looks like this:
SC_LT34F_BM SC_LTSL_BM SC_STSL_BM SC_LTSL_FL SC_STSL_FL SC_MPP34F_BM SC_ST34F_BM SC_CMP_BM SC_MEP_BM SC_GMP_BM SC_CDP_BM SC_MDP_BM MLP_BM MLP_FL proB_CLP_BM proB_FrA_BM proB_FrBC_BM preB_FrC_BM preB_FrD_BM B_FrE_BM proB_CLP_FL proB_FrA_FL proB_FrBC_FL preB_FrD_FL B_FrE_FL B_T1_Sp B_T2_Sp B_T3_Sp B_Fo_Sp B_GC_Sp B_MZ_Sp B1a_Sp B_FrF_BM B_Fo_MLN B_Fo_LN B_Fo_PC B1b_PC B1a_PC DC_8-_Th DC_8+_Th DC_4+_Sp DC_8+_Sp DC_8-4-11b-_Sp DC_8-4-11b+_Sp DC_pDC_8-_Sp DC_pDC_8+_Sp DC_4+_SLN DC_8+_SLN DC_8-4-11b-_SLN DC_8-4-11b+_SLN DC_pDC_8+_SLN DC_IIhilang-103-11blo_SLN DC_IIhilang-103-11b+_SLN DC_IIhilang+103+11blo_SLN DC_IIhilang+103-11b+_SLN DC_4+_MLN DC_8+_MLN DC_8-4-11b-_MLN DC_8-4-11b+_MLN DC_pDC_8+_MLN DC_LC_Sk DC_103-11b+_Lv DC_103+11b-_Lv DC_103+11b-_LuLN DC_103-11b+_LuLN DC_103-11b+24+_Lu DC_103+11b-_Lu DC_103-11b+_PolyIC_Lu DC_103+11b-_PolyIC_Lu DC_103-11b+F4/80lo_Kd DC_103+11b-_SI DC_103+11b+_SI DC_103+11b-_Salm3_SI DC_103+11b+_Salm3_SI MF_BM MF_RP_Sp MF_Lu MF_103-11b+24-_Lu MF_II+480lo_PC MF_103-11b+_SI MF_11cloSer_SI MF_103-11b+_Salm3_SI MF_11cloSer_Salm3_SI MF_II-480hi_PC MF_Microglia_CNS MF_Thio5_II+480int_PC MF_Thio5_II-480int_PC MF_Thio5_II-480hi_PC MF_Thio5_II+480lo_PC Mo_6C+II-_BM Mo_6C-II-_BM Mo_6C+II-_Bl Mo_6C+II+_Bl Mo_6C-II-_Bl Mo_6C-II+_Bl Mo_6C-IIint_Bl Mo_6C+II-_LN GN_BM GN_Bl GN_Arth_BM GN_Arth_SynF GN_UrAc_PC GN_Thio_PC NK_Sp NK_49CI-_Sp NK_49CI+_Sp NK_49H-_Sp NK_49H+_Sp NK_MCMV1_Sp NK_MCMV7_Sp NK_H+_MCMV1_Sp NK_H+_MCMV7_Sp NK_b2m-_Sp NK_DAP10-_Sp NK_DAP12-_Sp preT_ETP_Th preT_ETP-2A_Th preT_DN2_Th preT_DN2A_Th preT_DN2B_Th preT_DN2-3_Th preT_DN3A_Th preT_DN3B_Th preT_DN3-4_Th T_DN4_Th T_ISP_Th T_DP_Th T_DPbl_Th T_DPsm_Th T_DP69+_Th T_4+8int_Th T_4SP69+_Th T_4SP24int_Th T_4SP24-_Th T_4int8+_Th T_8SP69+_Th T_8SP24int_Th T_8SP24-_Th T_4Nve_Sp T_4Mem_Sp T_4Mem44h62l_Sp T_4Nve_LN T_4Mem_LN T_4Mem44h62l_LN T_4Nve_PP T_4Nve_MLN T_4_LN_BDC T_4_PLN_BDC T_4_Pa_BDC T_4FP3-_Sp T_4FP3+25+_Sp T_4FP3+25+_AA T_4FP3+25+_LN T_8Nve_Sp T_8Mem_Sp T_8Nve_LN T_8Mem_LN T_8Nve_PP T_8Nve_MLN T_8Nve_Sp_OT1 T_8Eff_Sp_OT1_d5_VSVOva T_8Eff_Sp_OT1_d6_VSVOva T_8Eff_Sp_OT1_d8_VSVOva T_8Eff_Sp_OT1_d15_VSVOva T_8Mem_Sp_OT1_d45_VSVOva T_8Mem_Sp_OT1_d106_VSVOva T_8Eff_Sp_OT1_12hr_LisOva T_8Eff_Sp_OT1_24hr_LisOva T_8Eff_Sp_OT1_48hr_LisOva T_8Eff_Sp_OT1_d6_LisOva T_8Eff_Sp_OT1_d8_LisOva T_8Eff_Sp_OT1_d10_LisOva T_8Eff_Sp_OT1_d15_LisOva T_8Mem_Sp_OT1_d45_LisOva T_8Mem_Sp_OT1_d100_LisOva NKT_44-NK1_1-_Th NKT_44+NK1_1-_Th NKT_44+NK1_1+_Th NKT_4+_Sp NKT_4-_Sp NKT_4+_Lv NKT_4-_Lv Tgd_Th Tgd_vg1+vd6-24ahi_Th Tgd_vg1+vd6+24ahi_Th Tgd_vg2+24ahi_Th Tgd_vg2+24ahi_e17_Th Tgd_vg3+24ahi_e17_Th Tgd_vg5+24ahi_Th Tgd_vg1+vd6-24alo_Th Tgd_vg1+vd6+24alo_Th Tgd_vg2+24alo_Th Tgd_vg3+24alo_e17_Th Tgd_Sp Tgd_vg2-_Sp Tgd_vg2-_act_Sp Tgd_vg2+_Sp Tgd_vg2+_act_Sp Tgd_vg2-_Sp_TCRbko Tgd_vg2+_Sp_TCRbko Tgd_vg5-_IEL Tgd_vg5+_IEL Tgd_vg5-_act_IEL Tgd_vg5+_act_IEL Ep_MEChi_Th Fi_MTS15+_Th Fi_Sk FRC_MLN FRC_SLN LEC_MLN LEC_SLN BEC_MLN BEC_SLN St_31-38-44-_SLN
1415806_at Plat 27.9185 36.5107 33.0332 30.6177 29.9747 28.8708 30.3841 37.5277 30.5361 32.6895 29.4836 27.9885 29.4244 26.5173 35.0402 31.544 30.9292 29.8665 35.6304 33.0442 26.7101 28.2309 30.9805 28.6152 31.8907 32.0462 34.8866 33.0858 35.7239 35.2472 34.3717 29.8923 39.6809 41.3769 42.2323 39.081 33.5901 35.0953 30.3213 27.7287 34.1493 37.4285 32.0074 39.7632 33.5368 30.3562 45.2669 40.6258 195.136 103.185 39.0732 80.0762 153.337 365.59 78.3391 39.9067 44.3187 56.1457 33.6093 41.5659 366.436 40.771 32.906 150.567 55.6916 105.192 44.2745 185.212 76.1094 28.6436 36.086 68.2284 39.585 119.956 26.9137 38.7293 33.0461 60.3476 28.3998 34.0431 32.9896 65.296 59.0182 28.654 40.783 33.7108 29.0525 29.3948 31.408 31.5986 35.9317 31.184 29.0688 34.2658 33.5081 32.2015 35.6911 41.8463 44.3161 38.3131 51.4425 51.4854 42.5922 40.787 39.072 34.6637 33.343 33.0619 36.7676 37.9347 31.0312 35.6631 35.7623 37.7508 33.1229 33.6179 41.1347 32.8821 35.5274 34.5783 29.3629 37.1282 32.6213 29.7352 31.6801 30.03 37.6091 37.3695 35.7894 39.4483 42.3723 41.7823 31.979 33.1111 34.9302 36.7907 34.9848 32.0475 41.4716 37.722 35.7637 43.4169 40.778 34.4366 47.119 41.7399 46.3535 30.093 31.4636 41.9103 46.1681 37.7144 34.474 42.1673 47.1553 37.3054 49.77 40.0073 33.6125 34.3092 38.0424 42.9508 39.9314 55.4645 36.0474 50.1869 38.7767 32.3656 31.0418 27.0207 30.6182 33.8824 42.901 32.0133 39.7088 37.3634 33.07 33.4334 43.9524 35.59 37.7714 42.626 33.3944 33.1647 31.626 39.8802 28.3281 40.7664 34.782 34.9716 31.0598 43.7914 32.7444 35.9125 38.8265 38.2612 32.2323 40.2928 36.7945 34.991 37.4216 40.4704 39.3888 30.0384 105.793 2526.44 640.249 242.364 131.67 1064.84 1056.81 208.29 157.891 271.912
1415899_at Junb 104.359 116.588 117.664 113.224 66.2672 86.464 81.6396 76.6304 100.614 116.538 118.284 129.816 101.239 89.2805 99.7887 125.883 112.003 99.5811 118.3 178.751 87.5629 70.5608 120.18 101.577 137.816 123.722 125.728 168.945 138.178 153.402 104.895 175.298 137.421 113.447 117.66 129.752 143.541 146.186 428.249 412.473 385.435 339.74 473.701 507.498 220.07 194.76 667.376 488.267 354.873 635.98 193.976 507.981 667.498 442.459 449.715 639.196 574.944 542.865 687.359 150.271 889.725 1169.58 459.569 374.314 461.532 1206.02 675.481 1130.99 849.501 280.516 979.627 1324.66 671.702 1053.9 152.166 350.176 337.302 826.052 513.71 1469.49 1517.93 1238.98 1257.99 330.983 1478.1 238.873 212.152 208.743 405.299 236.767 278.17 341.064 345.308 281.135 393.439 302.634 682.04 325.536 960.248 321.11 1291.57 883.89 885.596 219.172 175.986 216.132 278.688 295.721 275.892 215.793 299.334 331.465 185.401 220.586 204.986 456.516 378.278 226.349 454.313 425.804 232.92 146.899 110.746 112.351 125.992 103.248 150.85 94.4725 135.077 229.705 165.416 223.929 232.708 195.205 142.457 182.395 144.899 202.909 193.86 205.682 570.849 231.047 194.275 441.833 382.466 210.373 192.348 221.835 248.175 209.08 276.048 1647.57 249.185 263.404 191.867 211.169 157.855 283.887 155.999 156.376 168.494 222.407 175.15 175.776 180.29 216.886 284.49 206.288 178.744 188.286 163.138 180.242 205.278 286.698 151.971 255.359 293.267 662.865 772.192 520.293 706.199 559.661 146.378 177.677 180.272 144.715 107.154 135.916 149.646 251.437 214.44 328.079 189.697 166.164 252.097 254.642 277.984 260.566 294.951 244.528 709.615 765.502 148.709 310.161 404.302 1408.72 1158.08 1199.58 1694.65 812.419 1004.32 950.417 1083.41 1061.59
..(more)...
With the following code:
library(gplots);
library(RColorBrewer);
dat <- read.table("http://pastebin.com/raw.php?i=wM7WxEvY",sep="\t",na.strings="NA",header=TRUE)
dat <- dat[complete.cases(dat),]
dat.log <- log2(dat);
# Clustering and distance function
hclustfunc <- function(x) hclust(x, method="ward")
distfunc <- function(x) dist(x,method="maximum")
nofval <- length(unique(as.vector(as.matrix(dat.log))));
hmcols <- rev(redblue(nofval));
pdf(file="temp.pdf",width=50,height=40);
heatmap.2(as.matrix(dat.log),Colv=FALSE,lhei = c(0.25,4),density.info="none",scale="none",margin=c(10,10),col=hmcols,symkey=F,trace="none",dendrogram="row",keysize=0.3,hclust=hclustfunc,distfun=distfunc);
dev.off();
It produces this image:
Note that at the top left the colors of KEY did not appear at all.
What's the problem with my code above?
How can I correct it?
The colours are being parsed at very high resolution. You have assigned a colour gradient to every value in your matrix, total of 17410. Try decreasing the colour gradient to 128 or 256: col=bluered(256).
Alternatively, increase the key size keysize=1 to display the higher colour gradient.

Resources