How to get a probability density function from vector? - r
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
Related
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.
2D (kde2d) contour plots with conditions
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?
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.
How to fit a loess curve over this decomposed time series data in R?
We have time series data with some seasonality from the past 4 years. We want to predict the general rise in trend next year. For this, we decomposed the time series and observed the trend line: However, this trend line is placed in the middle of the values rather than the values themselves. We are not satisfied with simply extrapolating this trend line since it falls very short of expected traffic. Since we are interested in only the general rise in trend and not the seasonality, we remove the seasonality from the components: mydata <- read.csv("values.csv") mydataseries <- ts(mydata, start=c(2012,1,1),frequency = 365.25 mydataseriescomponents <- decompose(mydataseries) mydataseriesminusseasons <- mydataseries - mydataseriescomponents$seasonal We are now trying to fit a loess() curve in R around this time series data minus the seasonal component, that is mydataseriesminusseasons: 855154881.9 1027395443 1132284155 944870172.3 898459083.9 845115286.7 204393180.2 -75788428.32 -184120868.7 -164634776 -190543808.7 -43973009.39 -452418843.2 -1065106918 -1194545584 -1250333168 -379435027.4 -151057609.1 134304962.6 37020062.65 -307740042.8 -309480234.5 -388529539.7 -379333445.3 -193124460 -663765015.3 -100597898.3 -327949890.1 -429500583.5 -1321506072 -1444202356 -369913100.7 -715237274.1 -83507361.25 -328296509.9 -409957935.1 -1351211680 -533631519.6 -882845870.8 -711202595.9 -147504975.3 -361087020.5 -392960561 -456709751.2 -1065209981 -2062128692 -1112973164 -914751976.5 -1377070656 -1903432323 -2110392180 -1984477186 -1434481986 -988902503.8 -944477878.3 -1388889111 -1559730054 -1668752977 -1590459585 -1528272998 -850923022 -542720361.8 -791860111.9 -1057854181 -852120155.6 -810625768.1 -56185632.59 576968488.7 691371629.9 160486150.2 -308533580.1 -261619133.2 -404620378.3 740114544.5 1006206606 622867052.1 -71219884.82 -39173777.42 -533631907.8 -709943766.3 -565909169.9 -968499911.2 -1056539190 -1266350530 -1445031918 -1579156208 -1550356091 -1316401212 -899907725.4 -681646243 -996858524.4 -1261573594 -1620842348 -1529532466 -1107218074 287538766 303061371.4 -382291371.7 -639757694.3 -737369705.5 -732118809.2 -393825621.1 -810602326.3 -1044759123 -1410535140 -1636325717 -1646415420 -1514426422 -1241825553 31448256.14 64762654.11 -513468522.6 -676115681.9 -191498426 -86743267.18 80585792.24 538395944.8 262807408.8 -156283609.7 -72157485.31 -56386961.34 -14257457.85 233362524.8 495465812.9 354441383.3 74975465.29 28985451.46 187381822.2 517857439.4 940857149.4 1397097814 1965769992 1735207534 1568036010 1496104390 1647402384 928936108 1372629124 1417356139 1168474219 1080545493 996524274.5 988026158.1 1060004940 1315522041 1444552768 1438503151 1174067300 1063743311 1086528293 1310565938 1542624917 1504331433 1280216655 1726223821 1670308928 1120574360 1084897870 1285908119 1232985139 1101293494 1081075441 881717495.1 975005126.7 1058436909 1290433280 1288259727 1038856967 1006240656 891910425.2 920601850.4 981585788.8 1536507833 1546018200 1149902811 1230460988 1191817042 1161287112 1273239958 1590385882 1538451838 1242359113 913747727.7 888013837.2 934884821.1 1198395868 1277044767 1235456131 963043028 925500611.4 921906159.7 957528730.9 934517634.5 1183155135 1155142736 893512199.3 829955361 839182104.7 904102148.6 972879836.6 1227504663 1192420215 904137203.4 944756516 1375037708 1328414157 1779424344 1921248556 1899629843 1773839270 1565431502 1592386775 1825650269 1404794363 1393784791 1416771770 1288386476 1289239680 815093905.4 681990799.1 783953618.4 1103067833 1182429773 933897907.8 874114515.6 787403408.5 860338795 1052657878 1297180989 1245476158 1014316130 1004606484 735958898.4 575505161.4 588750452.3 803692654.7 833093724.3 531996754.3 199110366.8 -18901281.1 -6413198.146 -33290860.64 252073940.6 203247618.9 -164091120.7 -501720846.4 -865543851.3 -856086326 -612355346.3 400846624.1 511862726 288735892.8 -127533264.3 -940372573.2 -155917893.1 -699989731.6 -320401187.5 -277824927.9 -705440125.7 -1042182377 -1206106831 -1339738778 -165282703.3 222304361.4 136773204.1 -224139914.3 -271723348.1 -288223577.8 -285482682.4 -1057479814 -1059799528 -960773269.6 -1378106942 -1682462197 -1880270405 -1877392694 -1621410466 -1218560480 387109224.3 85424610.03 -558048286.6 -432347510.8 -107370046 224698124.4 732906395.5 -523071744.4 -1239504492 -1798916179 -2065361083 -1987860160 -1725292219 -1109123667 -971275176.7 -1420498329 -1889158526 -1136864728 -1002777887 647298007.9 1277421457 248465769.8 -377527211.2 -724681515.2 -967478152.4 -947666627.1 -734506065.3 -408053802.2 -241421840.8 -363715586.3 -829237162.5 -929529173.2 -260432788.4 -67756618.13 242997207.2 567370574.9 128921994 -159670249.1 -226982681.8 -240623081 -26502753.8 311495394.1 477285225.3 198408156.8 -195753985.4 -271887709.5 -196538766.7 -72464893.44 180860168.9 360960891.9 147945699.2 -29352193.17 325127464.9 960490365.6 1453481987 1424677454 1207446280 537281902.1 -167977127.5 -505612366.5 -1460096451 -1554214240 -1472813276 -1158137635 -1079634747 -1400116741 -1623247577 -1720625509 -1291068926 -541823228.2 423680238 828606261.2 651175802 588260033.4 511022741 644493024.6 696908085.1 949150687.9 1037411745 754948966.3 790033725.6 1053226989 1170333305 1056602964 1081413405 1135864583 971795777.8 855154881.9 1027395443 1132284155 944870172.3 896319497.9 845115286.7 204393180.2 -75788428.32 -184120868.7 -164634776 -190543808.7 -43973009.39 -452418843.2 -1065106918 -1194545584 -1250333168 -379435027.4 -151057609.1 139705076.6 37020062.65 -307740042.8 -309480234.5 -388529539.7 -379333445.3 -193124460 1308430606 -100597898.3 -327949890.1 -429500583.5 -1321506072 -1444202356 -369913100.7 1419976593 180125360.7 -328296509.9 -409957935.1 -1351211680 -533631519.6 1246061777 1639641696 272442819.7 -361087020.5 -392960561 -456709751.2 1014735303 478499133.8 -748455756.5 -914751976.5 -1377070656 -1903432323 -2110392180 -1984477186 -1434481986 -988902503.8 -944477878.3 -1388889111 -1559730054 -1668752977 -1590459585 -1528272998 -850923022 -542720361.8 -791860111.9 -1057854181 -852120155.6 -810625768.1 -56185632.59 576968488.7 681069818.9 160486150.2 -308533580.1 -261619133.2 -404620378.3 740114544.5 1006206606 622867052.1 -71219884.82 -39173777.42 -533631907.8 -709943766.3 -565909169.9 1641890896 1588111061 880069519.6 1090752417 1278890698 1335767912 1519822543 1812984581 1334545973 426228457.6 456951496.9 1228693380 1312355639 1637418032 691968559 303061371.4 -382291371.7 -639757694.3 -737369705.5 -732118809.2 -408383535.1 1630144553 1548715666 747397223.2 884268460.1 1205537489 1226277745 1637844137 477586396.1 64762654.11 -513468522.6 -676115681.9 -191498426 -86743267.18 80585792.24 538395944.8 262807408.8 -156283609.7 -72157485.31 -56386961.34 -14257457.85 233362524.8 495465812.9 354441383.3 74975465.29 28985451.46 187381822.2 517857439.4 940857149.4 1397097814 1479492584 1206235886 1230335054 1209244303 1772074811 1693077942 1461745247 1417356139 1168474219 1080545493 996524274.5 988026158.1 1059643199 1314652245 1440434637 1438503151 1174067300 1063743311 1086528293 1310565938 1542624917 1504331433 1280216655 1726223821 1670308928 1863627651 1882123871 2055914335 1992301669 1579375771 1533925079 1762629244 1838997943 1897919645 2107505072 1997289608 1464337865 1415561153 1676756233 1700040307 1783398157 1624554189 1546018200 1149902811 1230460988 1191817042 1161373475 1273239958 1590385882 1538451838 1242359113 913747727.7 888013837.2 934884821.1 1198395868 1277044767 1235456131 963043028 925500611.4 921906159.7 957528730.9 934517634.5 1183155135 1151401692 893512199.3 829955361 839182104.7 904102148.6 972879836.6 1227504663 1192420215 904137203.4 944756516 1375037708 1328414157 1193178073 1253502729 1251928059 1185271006 1244858293 1231640212 1171269572 1343448619 1393784791 1416771770 1288386476 1289239680 815093905.4 681990799.1 783953618.4 1103067833 1182429773 933897907.8 874114515.6 787403408.5 860338795 1052657878 1297180989 1245476158 1014316130 1004606484 735958898.4 575505161.4 588750452.3 803692654.7 833093724.3 531996754.3 199110366.8 -18901281.1 -6413198.146 -33290860.64 252073940.6 203247618.9 -164091120.7 -501720846.4 -865543851.3 -856086326 -612355346.3 400846624.1 511862726 288735892.8 -127533264.3 -940372573.2 -155917893.1 -699989731.6 -320401187.5 -277824927.9 -705440125.7 -1042182377 -1206106831 -1339738778 -165282703.3 222304361.4 136773204.1 -224139914.3 -271723348.1 -288223577.8 -285482682.4 410687500.7 1631841798 1553281634 713309450.5 649367763.9 960215164.3 1049107976 1148989485 1678375251 1164709303 183895982 465208739.4 766073381.2 586658157 853178118.4 1317822533 1674419406 693138111.6 610057420.2 928861116.6 1021382975 1317392280 1950890283 1753467250 679132043.8 530667904.1 1923321662 2445945599 2224779498 2205640478 2617939193 1771677175 1773936492 2444894838 2401384689 2491268212 2581667225 2449579792 1593738389 1956098689 2378730864 235226517.6 -67756618.13 242997207.2 567370574.9 128921994 -159670249.1 -226982681.8 -240623081 -26502753.8 311495394.1 477285225.3 198408156.8 -195753985.4 -271887709.5 -196538766.7 -72464893.44 180860168.9 360960891.9 147945699.2 -29352193.17 325127464.9 960490365.6 1453481987 1424677454 1207446280 537281902.1 -167977127.5 -505612366.5 1404374892 1613823539 1849271413 1936762445 1513383047 1256267888 1553901607 1655449233 1979063830 2224098910 2147758870 1612601292 1277373178 1489383946 1406268621 1510782787 1555473157 1721503681 1473734831 1214127421 1427159815 1454163770 1559572239 1693448937 1686056516 1534649610 1402815411 1597472633 1479661974 1572474919 1758527502 1912156129 2007806540 2577055685 3079863351 3189154952 3084552356 3020184398 3019956688 2361199448 1906290720 1878596097 1894542086 54727454.63 -151057609.1 134304962.6 37020062.65 -307740042.8 -309480234.5 -388529539.7 -379333445.3 -193124460 -663765015.3 -100597898.3 -327949890.1 -429500583.5 1538626202 1943756793 142960155.3 -715237274.1 -83507361.25 -328296509.9 -409957935.1 1469349471 -6715352.565 -882845870.8 -711202595.9 -147504975.3 -361087020.5 -392960561 -456709751.2 -1065125015 1006714631 2153142496 1804378762 1673270778 2693842453 3029003743 3091803034 2506604564 2457560591 2027821010 1756470132 2064844611 2119623546 2162263280 2002164168 1694641809 616667238.2 178971439.1 187991217 342780020.4 452558045.9 1221341191 1928282804 1898438088 2350801273 3271266186 3102579205 3404316683 1296736764 1006206606 622867052.1 -71219884.82 -39173777.42 777976197.2 831608580.7 1173972977 574093131.8 145884449.2 125630390.6 140647407.2 -1948845.745 -20569346.72 170376510.8 416953573.6 394780276 210086267.6 240846310.9 -4692367.437 13267344.2 462459409.2 1638331860 1368251762 844946221.3 908678722.7 858991700.5 821130809.8 1087001122 501346560.7 49030467.37 -115293555.8 -42916860.95 -94506694.82 65744337.46 214422930.7 1246493179 948746467.1 450984956.4 906168925.1 55072855.99 -86742286.18 80586773.24 538396925.8 262808389.8 -156282628.7 -72156504.31 -56385980.34 -14256476.85 233363505.8 495466793.9 354442365.3 74976446.29 28986433.46 187382803.2 517858420.4 940858130.4 1397098796 1479493565 1206236868 1230336035 1209245284 1021481495 1358007248 1908140672 1690817796 1450430426 1573572004 1548289864 1518408336 1551340078 1800682764 1691240562 1675755235 1422581675 1551622923 1630779709 1361558060 1542625898 1504332415 1280217636 1726224802 1670309909 1120575341 1084898851 1285909100 1226741796 1101294475 1081076422 881718476.1 975006107.7 1058437890 1290434261 1288260708 1038857948 1006241637 891911406.2 920602831.4 981586769.8 1536508814 1546019181 1149903793 1230461969 1191818023 1161288092 1273240939 1590386863 1538452819 1242360094 913748708.7 888014818.2 934885802.1 1198396849 1277045748 1235457112 963044009 925501591.4 921907140.7 957529712.9 934518615.5 1183156116 1151402673 893513180.3 829956342 839183085.7 904103129.6 972880817.6 1227505644 1192421196 904138184.4 944757497 1375038689 1328415139 1193189782 1253504218 1251929547 1185272494 1244859781 1231641700 1171271060 1343450107 1393786279 1416773258 1288387964 1289241168 1276942382 1223342782 1265179173 1582950274 1549362846 1289741511 1522844687 1575762386 1623981295 1140018366 1297182477 1245477646 1014317618 1004607972 3339996446 2617836416 2598501271 2725463672 2379954942 2430902194 3387783330 4057325882 3941464221 4026010913 3593315188 3218647755 2899429341 3156298547 3453939489 3535652872 3957490786 2127115167 1652343230 1644069350 1408460965 3374914231 1354451507 3451778958 4125068975 3062203905 2860803149 3523217492 3446260128 4086491216 1353224655 1786887688 1329952369 1262946794 1434089723 1426765711 1394483892 3184736742 3585370070 2492338381 2870647454 3422458727 3496074936 3440427221 3488297885 3411694273 1862226333 2347786389 2984492965 2832984919 2706245540 2975365013 2750770215 2329108891 2668972592 3485974677 3498308730 3651172133 4020199587 3953317903 2733969884 2903235323 3953139670 4668898648 4652525612 4073702669 3715845753 3017343417 4181519935 4751974434 4619926728 4594101972 4732221475 4318140179 3780497707 4451918052 5012718317 4833179055 5653878208 5807608123 5396558840 4198373572 4884875793 5677377778 5912605893 5944449107 5747882280 5227572313 4478777171 4801671568 5862958412 6148995450 6002089979 5948770595 5519491673 4863435104 5079255850 5868770156 5542293262 4248733096 2766041977 2732273377 2763007960 3709017196 5826881003 5418281457 4464795375 4353979464 4041806357 3642750843 3991233296 4574288639 4505497973 4507525662 3759850718 2770466566 1884370202 2017997394 2536894291 2394368239 2561217637 2329522814 2238153751 1823017685 1985828850 2534460960 2292248472 2008277139 1792241233 1777656572 1763197595 1863541282 2165268053 2093475484 2045555081 1853852293 1858329332 1755509088 1713779365 1790957115 1574452597 1579659809 1670558649 1766876466 1623856630 2694719637 3768836252 3933201414 3980190714 4955559887 4938681336 4365493305 4568797166 5264823884 5274383182 5433866314 5417386015 5045165577 4013353224 4858457348 5313474135 5517720717 4442688396 4160415512 4888461743 3958104821 4567324340 5323056776 5488909281 4557331369 5223549360 4326783309 3764876526 4571173289 5423886480 5493146693 5626783987 4769215133 3238864341 3322242772 3840761593 4440231932 3952228746 3826102990 3642814617 3683433336 3290239564 3679644227 4401886050 4271007289 4331924299 4217934600 4322830334 3958867188 4735975510 5434096780 5704487461 5359613448 5223744170 3712806728 2381705672 2316848053 2396344551 1960261326 2098710139 1955760687 2933140424 2967171559 3746036475 5150516737 5103739176 4799974487 4940976107 4470787625 2874748403 3370617116 4116000776 3907376783 3879136871 3858305272 3498190930 2968939532 3482738547 4592541370 4548237451 4039300654 3954893868 3196099484 2977703338 3645589701 4866174649 5072864386 5232041565 5275606802 4693688082 3245094491 3790221336 4772983985 4581973930 4331144672 4167962637 3622317542 3760217425 4483667233 5577532419 5303025177 5677698961 5720893489 5385575901 4466914817 5021515141 5865735715 5703914224 5678717816 5600943246 5110447244 4590128626 4877035122 5442054864 5540200590 5229513831 4574668437 3734155348 2825747731 2665659550 3218611753 3177069031 3225833078 2857378098 2605242926 2290489544 2556941031 3052363819 3023655743 3139325913 3183875762 3084641745 2584707861 2573111682 2596449197 3119292036 3103807890 3003440326 3050225234 2639037382 2719271674 3174072606 2288642761 2407051251 2769659370 2792708736 2422258872 2550055714 3094896689 3167462954 3145311598 2982505987 2846929030 2410677820 2528516371 3317404595 3405548963 3264859256 3217887704 3076794348 2682319143 2752574869 3546644862 3387139453 3465822066 3527697761 3304648740 2671176465 2775904656 3369489444 3186975051 3265608930 3125970955 2336383605 2101672532 2227649209 3046717349 3161392531 3174174168 3069526988 3140929673 2396972936 2491933483 3274873818 3471396399 3449881421 3260944652 3059846681 2300326480 2410144424 3280639160 3165080129 1880734112 2026731745 1851573264 1593311358 1623039610 1888090770 1983714225 1990135314 1884610261 1966858510 1881518298 1817889199 2209334095 2213195958 3180360773 3506589476 3266458246 2314386847 2203488644 2979775043 2887785856 3029641480 2854946175 2971200632 2338656676 2508827357 3221768984 3271647981 1494100499 2557318665 2566743784 2024262236 2326858931 2898711691 2629767554 2418419575 2529673112 2517326919 2394071701 2882872031 3958018274 4398615549 4850186215 4769908627 3875047506 3686152334 3944845885 4407300286 5483421647 5150638137 5610203814 4608824221 3183456836 4173041229 5250468129 5281994707 5707036828 5352424541 5755606494 4561838923 5206514812 6017273753 5965257129 6031374315 6079040231 4379684817 2770833772 3855818791 4754914912 4592227424 4426284753 4410453960 4025381538 3174239722 3637497533 4441638488 4174099821 3906145103 3894032411 3032325960 2296152859 3634154800 5013642209 4862468183 4819578542 4516969809 3607317085 2438327317 3732908830 5107431888 4696140901 1856348267 1237864483 406427050.9 166776835.3 1498808575 1828048545 1624152578 1349901570 1420774156 998226407.7 1012022910 1532830520 1859891754 1422784584 1300680502 1969725485 1936125754 1730921235 2284540775 2480696530 2271292433 2177291835 2174315253 1943550394 1789789173 2208387982 2445973421 2180115879 2053590351 2057128187 1868753587 1794479025 2093710971 2310482091 1882157273 1506021669 1535469156 2038211764 2132884419 2539631965 2937476532 2237006540 1897259543 801631140.7 589473184.2 116334380.3 674275361.3 1282712559 1119202007 1004676722 781599593.7 1184057471 1405174402 2414122535 3215047803 3117104932 2843730513 2338714670 1830982498 1282357057 1398445510 1709185553 1343346425 1299455992 1382754660 1451688601 1355952002 1395566041 1646971917 1518132724 1378268909 1383505613 1477733701 1396182586 1340692285 1513095775 952400088.2 654084246.7 626929432.3 700786606 523798987.3 1212948425 1567710490 1072360130 1057312922 876650104.6 1532682661 1439342205 1801524855 2099113224 1992935512 2063753470 1849349346 1589462235 1341435771 1147947080 2071354378 2006092710 2105408195 1234206054 656144711.4 1208902786 1232216105 2213555415 2017146411 1991371378 994748835.5 1523018258 551904050.2 4489317425 7011882149 7509029269 7405531928 6627086822 5118361296 2929515389 4386298474 6193577031 6201888044 5600929516 5249637157 4071570693 3812427933 4814958529 6581889904 6706593436 6538328968 5770674289 5146640592 3869631764 5168489883 7218970135 7319257013 6818980598 6581026441 4463128268 2549197744 2751600290 3586655201 3073231312 2610229695 2664878334 2445857027 3333286739 5342397336 8218514365 7400486992 7351969323 6170498161 6166815740 4938259613 5123232548 6952344511 7484834076 7975757356 6042108897 3954139391 2561409558 3636287452 6659637045 6610145475 6303751643 5790815423 5286756045 532871596.2 2403662106 2933984545 2177296758 1954486433 1713519574 1459802901 4020142932 5383799348 6858179971 7112822894 6327294007 5759923625 5042533123 3796835736 5750880779 7453820307 7335397513 6962686301 7790660114 6724956363 5003169135 6701050938 7992041249 7756326177 7913301179 7741411043 6785177818 6284270117 6963921883 7785974652 7574222100 7588499293 5788919572 4105788142 2859825648 2924210471 4069907537 3895077405 3979654780 2075329893 1979403277 1632081713 1877890303 2412917344 3763581680 3726439732 3673898152 3345262416 2191053212 2548906553 3841133834 3846853011 3492242728 3479185981 3290714847 2514060721 2645599322 2791855040 3791586130 However, we are not familiar with the form of the loess() function and it seems to expect a formula which we do not know. We tried the following: y <- c(mydata) x <- 1:1614 lo <- loess(y~x) We get the error: Error in model.frame.default(formula = y ~ x) : invalid type (list) for variable 'y' How do we fit a loess curve around the values to get the general trend line? Also, after removing the seasonal component we have some negative values for some reason. Would this affect the loess() curve?