Error in inherits(f, "fitdist") : object 'fitw' not found - r

I am using R for modelling distributions with package fitdistrplus, I got a problem that
Error in inherits(f, "fitdist") : object 'fitw' not found.
Attached is the code I am using for modelling. does anyone know what is wrong with my code?
library(fitdistrplus)
timegaplist = c(133408000, 150828000, 175692000, 96000, 143000, 169000, 207000,
220000, 304000, 333000, 371000, 549000, 605000, 643000, 848000,
874000, 907000, 935000, 1054000, 1068000, 1481000, 2082000, 2440000,
2658000, 2836000, 3580000, 4138000, 4478000, 4536000, 4886000,
6238000, 6532000, 6609000, 6676000, 6886000, 7742000, 7931000,
8607000, 9186000, 9433000, 9575000, 9979000, 11139000, 13012000,
13099000, 13220000, 13660000, 13849000, 15585000, 16787000, 17591000,
18889000, 19169000, 19529000, 20863000, 22924000, 23463000, 24438000,
25203000, 25364000, 25557000, 27173000, 27436000, 28769000, 30435000,
31880000, 32342000, 33237000, 33497000, 34657000, 35227000, 35660000,
36641000, 37488000, 38384000, 38930000, 38950000, 39652000, 41143000,
44787000, 44979000, 45088000, 47357000, 52694000, 56774000, 59568000,
70066000, 73901000, 76181000, 78820000, 1875073000, 197330000,
197981000, 205765000, 216749000)
fitW = fitdist(timegaplist, "weibull",lower = c(0, 0))
gofw=gofstat(fitw)
wc=c(gofw$ks,gofw$kstest,gofw$aic,gofw$bic)
names(wc)=c("weibull.KS","weibull.KSTest","weibull.AIc","weibull.BIc")

Related

How to solve Warning in log(z) : NaNs produced in R?

I try to run K-S test simulation with different data and with GEV distribution but I get 50 warnings of Warning in log(z): NaNs produced
This is my data t1 = 2.1466558 2.9447386 2.1410642 1.8847492 2.0233282 2.1907725 3.1755095 2.1142972 2.1889601 2.8422979 1.8555857 1.0429501 2.1383811 3.9976282 14.0612719 6.0016379 4.0426939 3.9845386 5.1821300 3.8703266 2.9009807 3.8450287 6.1019829 4.1811626 8.0737452 2.8416879 3.1656657 2.1342049 1.9984793 2.8037649 6.9629563 2.8223349 10.9695854 1.8985456 0.9444765 6.0065642 2.0394709 9.1677515 5.0589429 4.1036932 4.9599679 3.0425898 1.9477278 3.0447457 8.1563085 4.9423730 3.1336760 1.8389239 3.1262185 1.1628846 3.8445247 2.1454052 1.9209593 0.9197765 2.8171347 8.0249643 13.1267940 6.8506226 2.0811591 2.8517716 2.8864796 1.8227987 8.1442224 2.8798242 5.1112049 2.8529055 6.8265215 1.0436781 3.8380311 2.9659720 3.0153516 2.8497134 24.0545609 3.1952943 3.9564030 7.1348925 3.0067497 2.8581224 13.0294469 1.8576194 2.8081190 6.0940443 1.9729950 4.1334539 9.9874363 2.0489537 1.9479052 2.8050009 3.1097060 8.9115900 23.8376271 3.9219177 2.9991323 3.8501608 4.1910852 4.9508869 11.9260378 5.1473547 6.1864583 2.8165587 3.8589393 5.1742220 2.8812650 4.1469513 2.9816058 6.9291070 4.0086371 2.8950365 3.1368533 2.9716707 4.0936148 4.0987735 8.8792285 2.9914305 15.9832293 11.1705646 4.1691180 2.0268396 9.1313510 2.8457873 5.8162405 5.1019303 2.9493099 3.1892744 6.1027555 5.9852653 6.0070368 5.0606722 3.8827039 2.8579010 3.1809342 2.8639117 4.0446142 8.1086074 6.9708477 3.9406243 3.9113551 2.8471808 3.9408469 1.8318536 4.8696027 6.1638158 10.0075047 4.0620721 2.1995222 2.9713600 0.9827086 11.8048057 3.1639570 4.1820899 2.8913417 5.1807095 1.8735194 3.8650210 2.9308563 6.9203276 7.0470336 2.1721080 1.9304191 2.9782089 4.9717892 1.8260324 4.0094237 6.0354774 4.1934337 3.8605304 6.9868062 9.0001938 19.9510362 10.0213967 1.9980948 1.9564188 10.0595901 5.9441410 5.9212171 1.9805753 2.8141160 9.8859371 2.1912938 5.0260191 7.0394183 3.1071499 4.8651357 4.8464983 3.1653826 4.0813080 0.9293124 2.0533324 3.1302422 5.0649879 1.9045972 3.0304574 6.1638933 1.8765108 2.1042605 5.0677281 7.9328270 5.0485400 11.8101217 2.8496955 3.9641349 2.0423748 3.9535697 10.1833001 1.9963743 3.9404075 1.0794579 5.1952880 2.1310139 3.1615550 4.1934939 2.1528778 1.8080386 7.8411243 9.8299614 6.0534968 4.0174467 2.0321006 6.8884815 3.1990381 3.9448174 4.1087308 2.8989261 3.1667614 3.0734750 4.9591400 4.0537864 5.1886589 2.0860818 3.9166460 3.8028030 2.8333645 2.0257119 3.9347423 2.1057551 2.9608942 5.8546608 3.1449161 1.8630542 5.0733393 1.8331204 3.1629142 4.0929211 6.9565034 3.8253997 2.8041233 5.1246350 3.8994802 2.0389505 5.0663955 3.8854816 1.8575128 1.9655496 3.0056002 4.9812668 4.8201262
I fit the GEV to the data:
fit5 = fevd(t1, type="GEV") using the function fevd in extRemes package. I wanna do K-S test simulation but get 50 warnings at this part:
stats <- replicate(n.sims, {
r <- rgevd(n = length(t1),location=fit5$results$par["location"],
shape= fit5$results$par["shape"],
scale = fit5$results$par["scale"])
estfit.gev <- fevd(r, type = "GEV") # added to account for the estimated parameters
as.numeric(ks.test(r, "pgevd",location=estfit.gev$results$par["location"],
shape= estfit.gev$results$par["shape"],
scale = estfit.gev$results$par["scale"])$statistic)
how do I solve this Warning in log(z): NaNs produced? I tried to use absolute r value but I still get the same warnings

Numerical integration in R : bad integrand behaviour error

This is my matrix
func=structure(c(-14.7690673280818, -14.5543581356252, -12.1406211639974,
-10.7200919648493, -9.55507848352318, -9.20790894914246, -8.74647670464071,
-8.26548763467919, -7.3962484443768, -6.94590909664862, -6.63903257406218,
-6.40598087538929, -6.09621085755895, -5.88245015332806, -5.69615454359131,
-5.4543516801245, -5.24485270997044, -5.05729667581875, -4.7660441793448,
-4.39683466679171, -4.30668996362841, -4.0828498417172, -3.95528199743041,
-3.81741171570944, -3.66175435590196, -3.56271256245504, -3.49609868983868,
-3.37586125647396, -3.0034966287813, -2.90517151506904, -2.72993249556762,
-2.66092057836039, -2.4408738658527, -2.36547969703899, -2.09546783234301,
-1.95526398213212, -1.88470374007828, -1.72750243012653, -1.60575660667247,
-1.43542615745848, -1.29362975715702, -1.18449733575892, -0.98947894198681,
-0.853386354928181, -0.63296867063245, -0.527486151545778, -0.361277864998242,
-0.257665212366851, -0.109270291541468, 0, 0.109270291541468,
0.257665212366851, 0.361277864998242, 0.527486151545778, 0.63296867063245,
0.853386354928181, 0.98947894198681, 1.18449733575892, 1.29362975715702,
1.43542615745848, 1.60575660667247, 1.72750243012653, 1.88470374007828,
1.95526398213212, 2.09546783234301, 2.36547969703899, 2.4408738658527,
2.66092057836039, 2.72993249556762, 2.90517151506904, 3.0034966287813,
3.37586125647396, 3.49609868983868, 3.56271256245504, 3.66175435590196,
3.81741171570944, 3.95528199743041, 4.0828498417172, 4.30668996362841,
4.39683466679171, 4.7660441793448, 5.05729667581875, 5.24485270997044,
5.4543516801245, 5.69615454359131, 5.88245015332806, 6.09621085755895,
6.40598087538929, 6.63903257406218, 6.94590909664862, 7.3962484443768,
8.26548763467919, 8.74647670464071, 9.20790894914246, 9.55507848352318,
10.7200919648493, 12.1406211639974, 14.5543581356252, 14.7690673280818,
-13.7079821475458, -13.4498703618915, -11.67838231268, -10.4589486406842,
-8.9432388382521, -8.58312548137122, -8.14102991846389, -7.71079209128989,
-6.95240042017031, -6.66414427349685, -6.40033205538623, -6.13816822549321,
-5.77208382991545, -5.49527630669887, -5.33154964830415, -5.12782641892739,
-4.93206161073643, -4.72556232300793, -4.52080276980657, -4.1694078333758,
-4.03956026669583, -3.90869860153294, -3.79104380757601, -3.69124767313376,
-3.47159857371935, -3.3643163654408, -3.29467696235366, -3.16605701449292,
-2.84435464789616, -2.71650210221017, -2.59690597248341, -2.52388797476942,
-2.34094207608544, -2.20427426100811, -1.83879580218285, -1.72737794398069,
-1.6454056454373, -1.5042411957216, -1.38609220687676, -1.2432788707001,
-1.1225617148797, -1.01318771357089, -0.90038209504245, -0.773284479514442,
-0.640368323748707, -0.555178375238413, -0.377358821158776, -0.230347860323025,
-0.110436162251717, 0, 0.110436162251717, 0.230347860323025,
0.377358821158776, 0.555178375238413, 0.640368323748707, 0.773284479514442,
0.90038209504245, 1.01318771357089, 1.1225617148797, 1.2432788707001,
1.38609220687676, 1.5042411957216, 1.6454056454373, 1.72737794398069,
1.83879580218285, 2.20427426100811, 2.34094207608544, 2.52388797476942,
2.59690597248341, 2.71650210221017, 2.84435464789616, 3.16605701449292,
3.29467696235366, 3.3643163654408, 3.47159857371935, 3.69124767313376,
3.79104380757601, 3.90869860153294, 4.03956026669583, 4.1694078333758,
4.52080276980657, 4.72556232300793, 4.93206161073643, 5.12782641892739,
5.33154964830415, 5.49527630669887, 5.77208382991545, 6.13816822549321,
6.40033205538623, 6.66414427349685, 6.95240042017031, 7.71079209128989,
8.14102991846389, 8.58312548137122, 8.9432388382521, 10.4589486406842,
11.67838231268, 13.4498703618915, 13.7079821475458, -14.358609077878,
-14.1271105147046, -11.9618138886078, -10.6190742201334, -9.31840132054895,
-8.96622474353695, -8.51227248333579, -8.05091545299969, -7.22455526958365,
-6.83691436333096, -6.54669635165921, -6.30238324376159, -5.97082920578328,
-5.73268017960003, -5.55511488901834, -5.32804232266972, -5.12385612117062,
-4.92897229198519, -4.67117775232928, -4.30885942992513, -4.20335651783943,
-4.0154831357938, -3.89174994433905, -3.76860783727992, -3.58819663306074,
-3.48596721027473, -3.41818297549918, -3.29470294456033, -2.94193593581688,
-2.83218876260999, -2.67847401240583, -2.60791242809822, -2.40221737689215,
-2.3031208003073, -1.99617971268181, -1.86711111167336, -1.79213635811389,
-1.64113856670334, -1.52078410227216, -1.36109806339877, -1.22745572081485,
-1.11822984936273, -0.955013720375685, -0.822400646878094, -0.635831069171161,
-0.538198299721656, -0.367498441110635, -0.24709807532094, -0.109721283846771,
0, 0.109721283846771, 0.24709807532094, 0.367498441110635, 0.538198299721656,
0.635831069171161, 0.822400646878094, 0.955013720375685, 1.11822984936273,
1.22745572081485, 1.36109806339877, 1.52078410227216, 1.64113856670334,
1.79213635811389, 1.86711111167336, 1.99617971268181, 2.3031208003073,
2.40221737689215, 2.60791242809822, 2.67847401240583, 2.83218876260999,
2.94193593581688, 3.29470294456033, 3.41818297549918, 3.48596721027473,
3.58819663306074, 3.76860783727992, 3.89174994433905, 4.0154831357938,
4.20335651783943, 4.30885942992513, 4.67117775232928, 4.92897229198519,
5.12385612117062, 5.32804232266972, 5.55511488901834, 5.73268017960003,
5.97082920578328, 6.30238324376159, 6.54669635165921, 6.83691436333096,
7.22455526958365, 8.05091545299969, 8.51227248333579, 8.96622474353695,
9.31840132054895, 10.6190742201334, 11.9618138886078, 14.1271105147046,
14.358609077878, -14.5672256639001, -14.3442603466748, -12.0526932005212,
-10.6704167793823, -9.43869316924387, -9.08906143604798, -8.63130745231583,
-8.15997238138419, -7.31181881941087, -6.89231124997616, -6.59362650222709,
-6.3550370379524, -6.03455479085867, -5.80880119944129, -5.62679869904323,
-5.39223941682433, -5.1853529853784, -4.99419352909143, -4.7193938866676,
-4.35357309705323, -4.255876038818, -4.04972245780601, -3.92404029302206,
-3.79341254883719, -3.62558255722496, -3.52497325621722, -3.4577838613747,
-3.33595188997765, -2.97322433504632, -2.86928245642403, -2.70462793445213,
-2.63485397290467, -2.42186464857093, -2.33481488889686, -2.04664318502277,
-1.91191506158551, -1.8391839961936, -1.68503324864501, -1.56397162198931,
-1.39887553095015, -1.26108886508264, -1.15191048988921, -0.972530768371285,
-0.838149222100249, -0.634376246882453, -0.532753819606308, -0.364336815412981,
-0.252468853112474, -0.109492065710681, 0, 0.109492065710681,
0.252468853112474, 0.364336815412981, 0.532753819606308, 0.634376246882453,
0.838149222100249, 0.972530768371285, 1.15191048988921, 1.26108886508264,
1.39887553095015, 1.56397162198931, 1.68503324864501, 1.8391839961936,
1.91191506158551, 2.04664318502277, 2.33481488889686, 2.42186464857093,
2.63485397290467, 2.70462793445213, 2.86928245642403, 2.97322433504632,
3.33595188997765, 3.4577838613747, 3.52497325621722, 3.62558255722496,
3.79341254883719, 3.92404029302206, 4.04972245780601, 4.255876038818,
4.35357309705323, 4.7193938866676, 4.99419352909143, 5.1853529853784,
5.39223941682433, 5.62679869904323, 5.80880119944129, 6.03455479085867,
6.3550370379524, 6.59362650222709, 6.89231124997616, 7.31181881941087,
8.15997238138419, 8.63130745231583, 9.08906143604798, 9.43869316924387,
10.6704167793823, 12.0526932005212, 14.3442603466748, 14.5672256639001,
-13.6245844768687, -13.3630613956461, -11.6420519179073, -10.4384236674326,
-8.89515033208928, -8.53401963497411, -8.0934438691888, -7.66719491633901,
-6.91751548158816, -6.64199852086489, -6.38157100998465, -6.11711906602055,
-5.74660855271358, -5.46484576488352, -5.30289294897202, -5.10216264876024,
-4.90747729878566, -4.69948913603343, -4.50152763272595, -4.15153286112639,
-4.01856478499323, -3.89501090892983, -3.77813524686729, -3.68133161034538,
-3.45665297878437, -3.34872310204811, -3.27884590260074, -3.14956711773407,
-2.83184663180451, -2.70167333082681, -2.5864505421683, -2.51311768021067,
-2.33308777876224, -2.19160406439047, -1.81862225736669, -1.70946687980764,
-1.6265976326061, -1.48669362532537, -1.36882733539455, -1.22817675030816,
-1.10911635110033, -0.999723362435733, -0.89337938721453, -0.766988745723311,
-0.640949911207503, -0.557354889428034, -0.37862272938278, -0.228200809764493,
-0.110527795707098, 0, 0.110527795707098, 0.228200809764493,
0.37862272938278, 0.557354889428034, 0.640949911207503, 0.766988745723311,
0.89337938721453, 0.999723362435733, 1.10911635110033, 1.22817675030816,
1.36882733539455, 1.48669362532537, 1.6265976326061, 1.70946687980764,
1.81862225736669, 2.19160406439047, 2.33308777876224, 2.51311768021067,
2.5864505421683, 2.70167333082681, 2.83184663180451, 3.14956711773407,
3.27884590260074, 3.34872310204811, 3.45665297878437, 3.68133161034538,
3.77813524686729, 3.89501090892983, 4.01856478499323, 4.15153286112639,
4.50152763272595, 4.69948913603343, 4.90747729878566, 5.10216264876024,
5.30289294897202, 5.46484576488352, 5.74660855271358, 6.11711906602055,
6.38157100998465, 6.64199852086489, 6.91751548158816, 7.66719491633901,
8.0934438691888, 8.53401963497411, 8.89515033208928, 10.4384236674326,
11.6420519179073, 13.3630613956461, 13.6245844768687, -13.7513240158161,
-13.4949850845108, -11.6972632618919, -10.4696154936035, -8.96823049188587,
-8.60864584793023, -8.16576044465774, -7.73344959477095, -6.97053016408726,
-6.67565344738059, -6.41008219291174, -6.14910749861269, -5.78532336166338,
-5.51109109533802, -5.34644256890291, -5.14116391069274, -4.94483810678764,
-4.73911258917317, -4.53082008138683, -4.17869747763421, -4.05047164341461,
-3.91581211159757, -3.79775240187192, -3.6964010627146, -3.47936581711638,
-3.37242020290272, -3.30290438286576, -3.17462683337767, -2.85085507867997,
-2.72420863226898, -2.60233967200701, -2.52948530961352, -2.34502396371101,
-2.21085897720345, -1.84928001732781, -1.73668634525457, -1.65518019199163,
-1.51336068884896, -1.39506478104353, -1.25112746056258, -1.1295492863675,
-1.02018515280999, -0.904021410598258, -0.776556379825624, -0.640066072057238,
-0.554047238235075, -0.376701966557133, -0.231463685042374, -0.110388540236378,
0, 0.110388540236378, 0.231463685042374, 0.376701966557133, 0.554047238235075,
0.640066072057238, 0.776556379825624, 0.904021410598258, 1.02018515280999,
1.1295492863675, 1.25112746056258, 1.39506478104353, 1.51336068884896,
1.65518019199163, 1.73668634525457, 1.84928001732781, 2.21085897720345,
2.34502396371101, 2.52948530961352, 2.60233967200701, 2.72420863226898,
2.85085507867997, 3.17462683337767, 3.30290438286576, 3.37242020290272,
3.47936581711638, 3.6964010627146, 3.79775240187192, 3.91581211159757,
4.05047164341461, 4.17869747763421, 4.53082008138683, 4.73911258917317,
4.94483810678764, 5.14116391069274, 5.34644256890291, 5.51109109533802,
5.78532336166338, 6.14910749861269, 6.41008219291174, 6.67565344738059,
6.97053016408726, 7.73344959477095, 8.16576044465774, 8.60864584793023,
8.96823049188587, 10.4696154936035, 11.6972632618919, 13.4949850845108,
13.7513240158161, -13.5038153563633, -13.2373523390222, -11.5894414578226,
-10.4087012189772, -8.82551281645418, -8.46290889731311, -8.02453396711809,
-7.60406134878737, -6.86699820314081, -6.6099290032563, -6.3544029256183,
-6.08663753750477, -5.70971751250438, -5.42077894932731, -5.26139485499848,
-5.06499864973269, -4.87187647554418, -4.66173225584577, -4.47361508632088,
-4.12564790942336, -3.98816098787005, -3.87518960476143, -3.75944221250401,
-3.66697204643782, -3.43501009186589, -3.32614231903036, -3.2559207639547,
-3.12568790968636, -2.81373363068119, -2.68019961742924, -2.57130991397796,
-2.49752109350884, -2.32171388099973, -2.17325620779303, -1.78940871644707,
-1.68352966297731, -1.59936153416788, -1.46128278798956, -1.34382587758861,
-1.20630719708568, -1.08964596607244, -0.980225481600834, -0.88323868593752,
-0.757871821632761, -0.641792114656659, -0.560506724513046, -0.380453009333927,
-0.225091641300559, -0.110660491161603, 0, 0.110660491161603,
0.225091641300559, 0.380453009333927, 0.560506724513046, 0.641792114656659,
0.757871821632761, 0.88323868593752, 0.980225481600834, 1.08964596607244,
1.20630719708568, 1.34382587758861, 1.46128278798956, 1.59936153416788,
1.68352966297731, 1.78940871644707, 2.17325620779303, 2.32171388099973,
2.49752109350884, 2.57130991397796, 2.68019961742924, 2.81373363068119,
3.12568790968636, 3.2559207639547, 3.32614231903036, 3.43501009186589,
3.66697204643782, 3.75944221250401, 3.87518960476143, 3.98816098787005,
4.12564790942336, 4.47361508632088, 4.66173225584577, 4.87187647554418,
5.06499864973269, 5.26139485499848, 5.42077894932731, 5.70971751250438,
6.08663753750477, 6.3544029256183, 6.6099290032563, 6.86699820314081,
7.60406134878737, 8.02453396711809, 8.46290889731311, 8.82551281645418,
10.4087012189772, 11.5894414578226, 13.2373523390222, 13.5038153563633,
-12.8877947524831, -12.5961340486959, -11.3210853809037, -10.2570925911286,
-8.47030492676585, -8.10018637873416, -7.67303749757961, -7.28202887686486,
-6.60931905266524, -6.44634841642492, -6.21582362929168, -5.93115698481963,
-5.5215432443443, -5.19600239869575, -5.04972087076752, -4.87543206990054,
-4.69028336184037, -4.46914150055587, -4.33123842894087, -3.99361363184664,
-3.833076928421, -3.77408485453713, -3.6640925546724, -3.59372660759739,
-3.32461379011727, -3.21096198541142, -3.13898393694403, -3.00388455382712,
-2.72134261347931, -2.57066623804085, -2.49408041291093, -2.41796583370138,
-2.26369776447253, -2.07966723692233, -1.64375650300888, -1.54786821816088,
-1.46043531083332, -1.33166687876378, -1.21629813646533, -1.09475471308712,
-0.990331188483095, -0.880770453063485, -0.831512873094893, -0.711368103958197,
-0.64608803628934, -0.576583643383317, -0.389788923647592, -0.219325408944189,
-0.101244293663156, 0, 0.101244293663156, 0.219325408944189,
0.389788923647592, 0.576583643383317, 0.64608803628934, 0.711368103958197,
0.831512873094893, 0.880770453063485, 0.990331188483095, 1.09475471308712,
1.21629813646533, 1.33166687876378, 1.46043531083332, 1.54786821816088,
1.64375650300888, 2.07966723692233, 2.26369776447253, 2.41796583370138,
2.49408041291093, 2.57066623804085, 2.72134261347931, 3.00388455382712,
3.13898393694403, 3.21096198541142, 3.32461379011727, 3.59372660759739,
3.6640925546724, 3.77408485453713, 3.833076928421, 3.99361363184664,
4.33123842894087, 4.46914150055587, 4.69028336184037, 4.87543206990054,
5.04972087076752, 5.19600239869575, 5.5215432443443, 5.93115698481963,
6.21582362929168, 6.44634841642492, 6.60931905266524, 7.28202887686486,
7.67303749757961, 8.10018637873416, 8.47030492676585, 10.2570925911286,
11.3210853809037, 12.5961340486959, 12.8877947524831, -12.6000848203634,
-12.2966556390103, -11.1957507602953, -10.1862843945321, -8.30440651819497,
-7.93147284818737, -7.50817793772083, -7.13162491301438, -6.48897104737938,
-6.36994876479492, -6.15110072929745, -5.85854042138457, -5.43365721329602,
-5.09102141962306, -4.95085939235108, -4.78689576531572, -4.60547103236952,
-4.37919276705198, -4.26474198682156, -3.93194755639431, -3.77843705689023,
-3.70907277842741, -3.61955988253518, -3.55951762156004, -3.27305364378077,
-3.15716747633446, -3.08436906473098, -2.94699678899349, -2.67819176248474,
-2.51950911610342, -2.45801068672049, -2.38080987129559, -2.23660157184075,
-2.03595688651075, -1.58836441712333, -1.47187389747016, -1.39555037998287,
-1.27113029247092, -1.15673682064109, -1.0426545765059, -0.943946623196274,
-0.835837575946843, -0.805837349555374, -0.689648730659341, -0.648094429117022,
-0.584092303333525, -0.394149224677363, -0.222824659020402, -0.0906541511144734,
0, 0.0906541511144734, 0.222824659020402, 0.394149224677363,
0.584092303333525, 0.648094429117022, 0.689648730659341, 0.805837349555374,
0.835837575946843, 0.943946623196274, 1.0426545765059, 1.15673682064109,
1.27113029247092, 1.39555037998287, 1.47187389747016, 1.58836441712333,
2.03595688651075, 2.23660157184075, 2.38080987129559, 2.45801068672049,
2.51950911610342, 2.67819176248474, 2.94699678899349, 3.08436906473098,
3.15716747633446, 3.27305364378077, 3.55951762156004, 3.61955988253518,
3.70907277842741, 3.77843705689023, 3.93194755639431, 4.26474198682156,
4.37919276705198, 4.60547103236952, 4.78689576531572, 4.95085939235108,
5.09102141962306, 5.43365721329602, 5.85854042138457, 6.15110072929745,
6.36994876479492, 6.48897104737938, 7.13162491301438, 7.50817793772083,
7.93147284818737, 8.30440651819497, 10.1862843945321, 11.1957507602953,
12.2966556390103, 12.6000848203634, -12.7233949898779, -12.425009683628,
-11.2494681735225, -10.2166322197219, -8.3755092456272, -8.00338523998922,
-7.57923229725886, -7.19608684570266, -6.5405512372713, -6.40269304276938,
-6.17884044516668, -5.8896632980985, -5.47132446137006, -5.13601542532135,
-4.9932306291456, -4.82484171541241, -4.64182091659811, -4.41774407285591,
-4.29324182862204, -3.95837714178017, -3.80090594237893, -3.73788575810611,
-3.6386462286676, -3.57417931862452, -3.29515190899568, -3.18022337150066,
-3.10777656095811, -2.97137842876953, -2.69668587115743, -2.54143464829308,
-2.47346988209172, -2.39673461879726, -2.24821478269518, -2.05469079214647,
-1.61210502089736, -1.50444445385474, -1.42335954097761, -1.29707578786137,
-1.18226432293022, -1.06498427720905, -0.963826675880699, -0.85422851115692,
-0.817708608597364, -0.698957479868998, -0.647234505242058, -0.580874151897233,
-0.392280434624987, -0.221324908501217, -0.0951930012794266,
0, 0.0951930012794266, 0.221324908501217, 0.392280434624987,
0.580874151897233, 0.647234505242058, 0.698957479868998, 0.817708608597364,
0.85422851115692, 0.963826675880699, 1.06498427720905, 1.18226432293022,
1.29707578786137, 1.42335954097761, 1.50444445385474, 1.61210502089736,
2.05469079214647, 2.24821478269518, 2.39673461879726, 2.47346988209172,
2.54143464829308, 2.69668587115743, 2.97137842876953, 3.10777656095811,
3.18022337150066, 3.29515190899568, 3.57417931862452, 3.6386462286676,
3.73788575810611, 3.80090594237893, 3.95837714178017, 4.29324182862204,
4.41774407285591, 4.64182091659811, 4.82484171541241, 4.9932306291456,
5.13601542532135, 5.47132446137006, 5.8896632980985, 6.17884044516668,
6.40269304276938, 6.5405512372713, 7.19608684570266, 7.57923229725886,
8.00338523998922, 8.3755092456272, 10.2166322197219, 11.2494681735225,
12.425009683628, 12.7233949898779, -12.9701665831908, -12.6818752140478,
-11.3569688906404, -10.2773650952434, -8.51780191626772, -8.14868819459235,
-7.72003821070641, -7.32508978114711, -6.64377488616525, -6.46822176338875,
-6.23435390289731, -5.95194722735932, -5.54670516078474, -5.22605862710606,
-5.07802507599128, -4.90078016073291, -4.71456527242172, -4.49489397213016,
-4.35027647059818, -4.01126873151645, -3.85381415345849, -3.78760418054142,
-3.67684233255883, -3.6035206970325, -3.33937554552141, -3.22636344257365,
-3.15462026543263, -3.02017161524238, -2.73369677368098, -2.58531260689116,
-2.50440723533775, -2.42860364735808, -2.27145544935968, -2.09218158273497,
-1.66032132882236, -1.56891953844307, -1.47901197414181, -1.34899860381407,
-1.23335063996306, -1.10967106859385, -1.00361116644947, -0.894069184830091,
-0.838429443534018, -0.717586396553344, -0.645513602695347, -0.574433901587114,
-0.388540562231589, -0.218323567844169, -0.104276269037671, 0,
0.104276269037671, 0.218323567844169, 0.388540562231589, 0.574433901587114,
0.645513602695347, 0.717586396553344, 0.838429443534018, 0.894069184830091,
1.00361116644947, 1.10967106859385, 1.23335063996306, 1.34899860381407,
1.47901197414181, 1.56891953844307, 1.66032132882236, 2.09218158273497,
2.27145544935968, 2.42860364735808, 2.50440723533775, 2.58531260689116,
2.73369677368098, 3.02017161524238, 3.15462026543263, 3.22636344257365,
3.33937554552141, 3.6035206970325, 3.67684233255883, 3.78760418054142,
3.85381415345849, 4.01126873151645, 4.35027647059818, 4.49489397213016,
4.71456527242172, 4.90078016073291, 5.07802507599128, 5.22605862710606,
5.54670516078474, 5.95194722735932, 6.23435390289731, 6.46822176338875,
6.64377488616525, 7.32508978114711, 7.72003821070641, 8.14868819459235,
8.51780191626772, 10.2773650952434, 11.3569688906404, 12.6818752140478,
12.9701665831908), .Dim = c(99L, 11L))
Each column is a function for me that I want to integrate, and put the values in my integr matrix:
integr=matrix(0,11)
for (t in 1:11){
integrating = approxfun(thau,func[,t],rule=2)
integr[t,1]=integrate(integrating, lower = 0.01, upper = 0.5,subdivisions = 1000)$value
}
I have this error message:
Error in integrate(integrating, lower = 0.01, upper = 0.5, subdivisions = 1000) :
extremely bad integrand behaviour
How do I get around this problem and continue to use the function integrate in R. Will I need to do some non-linear approach? If so, how can I do it?
Many thanks.
First, it is very interesting to see quite a few numerical integration question regarding quantile function in the last 10 days or so. For example:
Building a function by defining X and Y and then Integrating in R
Standard Normal Quantile Function Integration in R
Understanding and implementing numerical integration with a quantile function in R
Note how this question is similar to the first one. Although you did not mention what thau is, I believe it is thau <- seq(0.01, 0.99, 0.01). Let's have sketch your func matrix against thau:
matplot(thau, func, type = "l")
Also, let's verify that all columns of func are monotonically increasing:
all(diff(func) > 0)
# [1] TRUE
Basically, your question is using the answer I provided in the 1st linked question (the justification of rule = 2 is given in the 3rd linked question, though). But thanks to your question; I now realize there are some potential numerical flaw behind.
It is sophisticated for me to understand the mathematics behind Adaptive Quadrature in a limited time as I am not an expert in the field. But it is rather surprising to me that it would fail sometime on such a trivial task.
As I mentioned in the 2nd linked question, we can even use trapezoidal rule.
When I test integrate, it is the 1st column of func rather than the 5th as you reported that fails.
## get interpolation function for all columns in a list
flst <- lapply(1:ncol(func), function (i) approxfun(thau, func[,i], rule = 2))
## all OK excluding the 1st column
sapply(flst[-1], function (fun) integrate(fun, 0.01, 0.5)$value)
# [1] -2.010421 -2.088981 -2.114083 -2.000653 -2.015932 -1.986130 -1.912076
# [8] -1.877459 -1.892291 -1.921983
## the 1st one fails
integrate(flst[[1]], 0.01, 0.5)
# extremely bad integrand behaviour
As said earlier, I believe this failure artificial due to the problem's simple nature. In fact, let's consider
integrate(flst[[1]], 0.01 + .Machine$double.eps ^ 0.25, 0.5)
# -2.13653 with absolute error < 8.7e-05
integrate(flst[[1]], 0, 0.5)
# -2.286034 with absolute error < 0.00027
They all work.
As far as I can explore, the integrate function is using two Fortran subroutines:
dqags for definite integral, capable to deal with end-points singularity;
dqagi for indefinite integral.
R documentation for integrate does not explain much on the error handling of those routines, but the Fortran page does a little. Unfortunately, it is still not extremely clear what the "bad behaviour" is. But it is clear enough to see that regardless what error code is, those Fortran subroutines will always return integration result.
A look at the source code of integrate verifies this. Integration result is stored in variable wk, then a swtich statement is used to interpret the integer error code stored in wk$ierr:
res$message <- switch(wk$ierr + 1L, "OK", "maximum number of subdivisions reached",
"roundoff error was detected", "extremely bad integrand behaviour",
"roundoff error is detected in the extrapolation table",
"the integral is probably divergent", "the input is invalid")
if (wk$ierr == 6L || (wk$ierr > 0L && stop.on.error))
stop(res$message)
The if statement following this switch decides whether we want to ignore any error. Note there is an stop.on.error argument in integrate; if we set it FALSE instead of the default TRUE, integrate will always work. Therefore, let's do
z <- integrate(flst[[1]], 0.01, 0.5, stop.on.error = FALSE)
str(z)
# $ value : num -2.14
# $ abs.error : num 0.000446
# $ subdivisions: int 69
# $ message : chr "extremely bad integrand behaviour"
# $ call : language integrate(f = flst[[1]], lower = 0.01, upper = 0.5, stop.on.error = FALSE)
# - attr(*, "class")= chr "integrate"
z$value
# [1] -2.138348
This is all I can do at the moment. I believe there will be an opportunity for me to read around Adaptive Quadrature in the near future.

Error when using cluster package to compute euclidean distances

I have been working on a text mining project. I have performed some LDA topic modelling and now I have my topic probabilities. I would like to use the cluster package so that I can get the euclidean distances between documents so I can create a network graph, but I keep on getting an error. Any recommendation for good visualisation techniques would also be warmly welcomed :)
library(cluster)
FundDist <- as.matrix(daisy(EUTopicNetworks, metric = "euclidean", stand = TRUE))
Error in daisy(EUTopicNetworks, metric = "euclidean", stand = TRUE) : invalid type character for column numbers 1
In addition: Warning messages:
1: In data.matrix(x) : NAs introduced by coercion
2: In daisy(EUTopicNetworks, metric = "euclidean", stand = TRUE) :
with mixed variables, metric "gower" is used automatically
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
I have never uploaded reproducible data on this website using the dput() function before. So I hope I have done this correct. I have copied and pasted the output below. Thank you for taking the time to read my problem.
EUTopicNetworks <- structure(list(Filename = c("AT_Burenland_2007.txt", "AT21_Kaernten_07.txt",
"AT12_LowerAustria_07_13.txt", "AT_Nat_2007.txt", "AT34_Salzburg_07.txt",
"AT22_Steiermark_07.txt", "AT36_Tirol_07.txt", "UpperAustria2007.txt",
"AT13_Vienna_07.txt", "vorarlberg2007.txt", "AT_Austria_1.txt",
"AT11_Burgenland_1", "lowe austria 2014.txt", "AT13_Vienna2_14.txt",
"AT21_Kaernten_14.txt", "AT22_Steiermark_14.txt", "AT31_UpperAustria_14.txt",
"AT35_Salzburg_14.txt", "AT36_Tirol_14.txt", "AT37_Vorarlberg_14.txt",
"abbruzzo2007-2013.txt", "calabria2007-2013.txt", "campania2007-2013.txt",
"emiliaromagna2007-2013.txt", "sicily2007.txtt", "friuli2007-2013.txt",
"lazio2007-2013.txt", "liguria2007.txt", "lombardy2007-2013.txt",
"piemonte2007-2013.txt", "puglia2007-2013.txt", "sardinia2007-2013.txt",
"Bolzano_07.txt", "umbria 2007-2013.txt", "valledaosta 2007-2013.txt",
"tuscany2007.txt", "VENETO2007-2013.txt", "abruzzo2014-2020.txt",
"basilicata2014-2020.txt", "calabria2014-2020.txt", "campania2014-2020.txt",
"emiliaromagna2014-2020.txt", "sicily2014.txt", "friuli2014-2020.txt",
"lazio2014.txt", "liguria2014.txt", "lombardia2014-2020.txt",
"piemonte2014-2020.txt", "puglia_14.txt", "sardinia2014.txt",
"Bolzano_14.txt", "umbria2014.txt", "valledaosta 2014-2020.txt",
"tuscany2014.txt", "molise_14.txt", "molise_07.txt", "trento2007.txt",
"trento2014.txt", "ITALIANSTRATEGICPLAN2007-2013.txt", "italyinnovationstrategy2014-2020.txt",
"veneto2014-2020.txt", "aquitanie2014-2020.txt", "aquitanie2007.txt",
"auvergne2014-2020.txt", "auvergne_07.txt", "bretagne2014-2020.txt",
"bretagne_07.txt", "centre2014-2020.txt", "centre2007.txt", "champagne-ardenne 2007.txt",
"champagne-ardenne 2014.txt", "PICARDIE2007.txt", "picardie2014.txt",
"bassenormandie 2007.txt", "bassenormandie 2014.txt", "bourgogne2014.txt",
"bourgogne_07.txt", "midi-pyrenees2007.txt", "midipyrennes14.txt",
"franche-comte2014-2020.txt", "franche-comte_2007.txt", "hautenormandie2007.txt",
"hautenormandie2014-2020.txt", "limousine2014-2020.txt", "limousine2007.txt",
"loire2007.txt", "loire2014-2020.txt", "lorraine2014-2020.txt",
"lorraine2007.txt", "nordpasdecalais2007.txt", "nordpasdecalais2014-2020.txt",
"rhonealpes2014-2020.txt", "rhone-alpes2007.txt", "poitou-charenter2007.txt",
"poituou-charentes2014.txt", "corse2007.txt", "corsica.txt",
"bretagne_07.txt", "bretagne2014-2020.txt", "Baden-Wu_07.txt",
"Baden-wu14.txt", "bavaria2007.txt", "BAVARIA_14.txt", "BERLIN2014-2020.txt",
"Berlin_07.txt", "bradenburgh2014.txt", "Bradenburgh2007.txt",
"bremen2007.txt", "bremen2014.txt", "hamburg_07.txt", "HAMBURGO2014-2020.txt",
"Hessen_07.txt", "Hessian1.txt", "LowerSaxony2_07.txt", "LOWERSAXONY2014-2020.txt",
"Mecklenburg_07.txt", "MECKPOMM2014-2020.txt", "rheinland2014-2020.txt",
"RhinelanPlatz_07.txt", "saarland2014-2020.txt", "saarland_07.txt",
"sachsen-anhalt2014-2020.txt", "sachsen-anhelt2007.txt", "saxony_07.txt",
"saxony_14.txt", "Schleswig-Holstein2020.txt", "Schleswig-Holstein_07.txt",
"thuringia2007.txt", "THURINGIA2014-2020.txt", "Andalucia_2007-2013.txt",
"Andalusia_14.txt", "Aragon_14.txt", "Aragon_2007.txt", "Asturias_2007.txt",
"ES12_Asturias.txt", "Baleares_2007.txt", "Balears_14.txt", "Canarias_07.txt",
"Canaries_14.txt", "Cantabria_2007.txt", "ES13_Cantabria_14.txt",
"Castillala_Mancha_2007.txt", "ES42_Castilla-la_mancha.txt",
"CastillayLeon_dic_2007.txt", "ES41_Castilla-Leon.txt", "ES51_Catalonia_14.txt",
"catalonia2007.txt", "Madrid_2007-13.txt", "Madrid_14.txt", "Murcia_14.txt",
"murcia2007.txt", "Valencia_14.txt", "Valenciana_2007.txt", "laRioja2007.txt",
"CombiEngland_07.txt", "EastWales_07.txt", "NorthernIreland_07.txt",
"Scotland_07.txt", "WestWales_07.txt", "EastWales_14.txt", "England_14.txt",
"Northern_Ireland14.txt", "Scotland14.txt", "Westwales_14.txt",
"malta2007-2013.2.txt", "malta2014-2020.txt2.txt"), Funds = c(0.028649302,
0.036198106, 0.041060412, 0.036543709, 0.047044295, 0.01659907,
0.019221094, 0.056763265, 0.052615278, 0.045216842, 0.048176521,
0.038976137, 0.027341846, 0.037721688, 0.049252945, 0.05918185,
0.05440539, 0.017412537, 0.029307636, 0.022385126, 0.019737738,
0.027626844, 0.0334503, 0.043976555, 0.042856083, 0.021046234,
0.018061427, 0.014983543, 0.067145641, 0.019741648, 0.019018285,
0.030614714, 0.019666862, 0.028158874, 0.026009936, 0.019330949,
0.023088856, 0.044273539, 0.021168401, 0.017627883, 0.030486684,
0.017509486, 0.034035728, 0.034106673, 0.043486846, 0.029087254,
0.050564915, 0.047219925, 0.051437475, 0.029694445, 0.008588781,
0.045469371, 0.060967658, 0.049260664, 0.015106536, 0.026186649,
0.023254401, 0.053579943, 0.031056644, 0.045125396, 0.057680642,
0.01125217, 0.042532521, 0.041545015, 0.047940862, 0.036641552,
0.072252939, 0.035679102, 0.067488953, 0.008492444, 0.021052205,
0.020152732, 0.040564092, 0.02921307, 0.018565646, 0.022775302,
0.011711217, 0.019967731, 0.00877454, 0.022250866, 0.003696986,
0.011277284, 0.007740289, 0.02790784, 0.008134596, 0.014931457,
0.03269353, 0.041386999, 0.066164327, 0.011440048, 0.006215758,
0.010688796, 0.003811851, 0.003303556, 0.023094521, 0.010550119,
0.018023822, 0.022757839, 0.017667203, 0.02073341, 0.013537221,
0.011950717, 0.009010298, 0.019796088, 0.011314152, 0.01098032,
0.008832217, 0.040330019, 0.005822583, 0.006599734, 0.016338338,
0.013906508, 0.010973094, 0.010448791, 0.003723683, 0.013769165,
0.007583811, 0.009724543, 0.00237987, 0.005005899, 0.005048481,
0.013000829, 0.012671508, 0.003054379, 0.03508621, 0.012981055,
0.021982606, 0.009448894, 0.014883524, 0.018772709, 0.006068872,
0.018122102, 0.020449118, 0.015102835, 0.005449833, 0.011014679,
0.016602374, 0.006482356, 0.009969209, 0.002646448, 0.01205523,
0.04659564, 0.010866707, 0.0144986, 0.046946229, 0.028629168,
0.034634807, 0.059078927, 0.002919951, 0.016168915, 0.024403654,
0.09171777, 0.009978063, 0.015196456, 0.015174811, 0.047399696,
0.015303701, 0.011753077, 0.014862118, 0.01487099, 0.011742448,
0.018346786, 0.010785336, 0.010421162, 0.013791872, 0.026389358
), Biotech = c(0.024814541, 0.005668351, 0.017716491, 0.00853945,
0.015916015, 0.03888657, 0.001333459, 0.017368849, 0.023781704,
0.051278428, 0.005484117, 0.021759003, 0.027973849, 0.002774256,
0.005744201, 0.004244159, 0.00468969, 0.000581776, 0.022734494,
0.03445351, 0.000800523, 0.000362683, 0.026945766, 0.006823146,
0.005847249, 0.000630851, 0.020794353, 0.035979974, 0.006165474,
0.027793267, 0.00504312, 0.018927097, 0.000760576, 0.012289583,
0.002109001, 0.000442817, 0.000594334, 0.00037428, 0.06596126,
0.027988907, 0.019067461, 0.024872467, 0.015379713, 0.015295277,
9.36e-05, 0.000117979, 4e-05, 0.031220784, 0.001357913, 0.040951957,
0.000438858, 0.038880733, 0.00115553, 0.041152387, 0.042576251,
0.002254845, 0.022345729, 0.002596388, 0.022562024, 0.000243528,
0.000885187, 0.013339204, 0.001418329, 0.028089687, 0.002057198,
0.000244579, 0.000140129, 0.051721762, 0.014989271, 0.001673642,
0.04500578, 0.001615416, 0.00010688, 8.18e-05, 0.000526549, 0.024849247,
0.032961749, 0.033875354, 0.032145136, 0.012619383, 0.003522134,
0.012225185, 0.043464039, 0.077400519, 0.056308327, 0.020638077,
0.049992043, 0.038864222, 0.039459316, 0.034937031, 0.037406742,
0.029987413, 0.002413193, 0.000584526, 0.004584848, 0.012491496,
0.031710331, 0.017858395, 0.030812232, 0.003435739, 0.02648106,
0.006927007, 0.030785802, 0.044329986, 0.009838859, 0.002951219,
0.030722621, 0.020511401, 0.013623405, 0.081263322, 0.029623712,
0.003790876, 0.00335598, 0.018842609, 0.008430911, 0.032611226,
0.057455638, 0.004304486, 0.015733474, 0.043981231, 7.95e-05,
0.004054158, 0.045173701, 0.016378658, 0.015906368, 2.92e-05,
0.00057313, 0.00079682, 0.013209159, 0.039911915, 0.000237856,
0.022373161, 0.015821272, 0.026750309, 0.048698356, 0.041430357,
0.00287091, 0.007965338, 0.034481633, 0.001543219, 0.022152119,
0.041801127, 0.017463336, 0.038010604, 0.050393079, 0.045031199,
0.043613378, 0.037411148, 0.00186188, 0.018962051, 0.043254408,
0.018666636, 0.027696462, 0.024293257, 0.062711642, 0.000519461,
0.001056595, 0.031300324, 0.024742217, 0.024718682, 0.000780182,
0.01862668, 0.000973041, 0.000542227, 0.001011475, 0.011077226
), Transfers = c(0.00473547, 0.00038783, 0.000424567, 0.000695775,
0.000135175, 0.010334213, 0.000106781, 0.003008423, 0.000608193,
0.010326284, 0.000934925, 0.031277279, 0.00572826, 0.000260722,
0.001021529, 0.000154104, 0.000220061, 4.32e-05, 0.018335222,
0.013011634, 2.49e-05, 4.83e-05, 0.021935677, 0.000390414, 0.000130749,
3.77e-05, 0.009460382, 0.146681735, 7.44e-05, 0.082389135, 0.000592343,
0.000562132, 1.53e-05, 0.020403948, 1.31e-05, 2.46e-05, 5.51e-05,
0.000321357, 0.037377138, 0.006516009, 0.022055996, 0.041838049,
0.002549792, 0.00271147, 8.55e-05, 0.001550897, 0.001094715,
0.002059784, 2.73e-05, 0.012813067, 9.84e-06, 0.009924993, 8.74e-05,
0.004619721, 0.013069859, 2.14e-05, 0.053722696, 5.79e-05, 0.006753522,
1.18e-05, 0.005116721, 0.000108002, 2.73e-05, 0.003596542, 2.79e-05,
0.00438903, 8.31e-05, 0.026310482, 0.001005592, 0.000428282,
0.049529581, 1.93e-05, 8.57e-05, 0.001610554, 9.92e-06, 0.094923027,
0.031919217, 0.13955002, 0.083229087, 0.000284159, 0.000267466,
0.000349366, 0.056697448, 0.049064161, 0.075636951, 0.004204928,
0.006115066, 0.007264789, 0.002044115, 0.043477142, 0.046506897,
0.082070827, 0.00035585, 0.010126049, 0.000178782, 0.000133394,
0.019258021, 9.19e-05, 0.069771158, 0.164961859, 0.030302868,
0.008376654, 0.095394069, 0.069931231, 0.000553351, 0.000544636,
0.095332857, 0.001748097, 0.000288915, 0.049584358, 0.095331287,
0.000598831, 0.001574565, 0.124263691, 3.34e-05, 0.107925558,
0.087354139, 0.000618826, 0.000110399, 0.035831715, 5.52e-06,
0.003000538, 0.076722556, 0.001625612, 0.00057855, 2.15e-05,
6.78e-05, 0.000268523, 0.000567245, 0.04113056, 1.71e-05, 0.03401376,
0.001848523, 0.029357767, 0.078771496, 0.05552954, 0.068487283,
0.001617493, 0.045003856, 0.000170027, 0.102169304, 0.033286348,
0.000645582, 0.123061518, 0.024437451, 0.002628661, 0.013120533,
0.002000205, 0.000545963, 0.103891281, 0.01547252, 0.004918401,
0.032767954, 0.084638687, 0.093356166, 0.000156201, 0.000752217,
0.109659324, 0.208642497, 0.208474925, 0.000404265, 0.078084401,
0.000538784, 0.012066067, 0.018067282, 0.000205862), Collab = c(0.030001488,
0.036707564, 0.01458121, 0.026231048, 0.018525526, 0.011553297,
0.058634057, 0.001686141, 0.001348074, 0.006757227, 0.013508918,
0.003715637, 0.002921306, 0.009278328, 0.004626478, 0.002879119,
0.055770088, 0.095661212, 0.017193222, 0.004260887, 0.0994825,
0.094794299, 0.00236101, 0.05708391, 0.070789976, 0.093534164,
0.001109712, 0.009766358, 0.033402635, 0.011669702, 0.06682796,
0.001608723, 0.076258585, 0.0177607, 0.081032098, 0.094412392,
0.105163053, 0.000130001, 0.000308904, 0.000673957, 0.000108183,
0.006185235, 0.001417778, 0.001392482, 0.001763266, 4.19e-05,
0.000316372, 0.000538187, 0.057255911, 0.000888558, 0.117687659,
0.002003037, 0.068194122, 0.000653657, 0.000152612, 0.089555908,
0.002829031, 0.032391752, 0.000114824, 0.001213285, 0.000386851,
0.015705495, 0.049863754, 0.000186015, 0.036288112, 0.000121075,
0.001514642, 0.00150885, 0.000594681, 0.139375952, 0.002323917,
0.075647519, 0.002870689, 3.77e-05, 0.077144908, 0.026437255,
0.000115174, 0.00227099, 0.004700389, 0.041492391, 0.122675327,
0.020817113, 6.89e-05, 0.000303617, 0.000137477, 0.001432608,
0.000184365, 0.001050974, 0.000709209, 0.000270104, 0.000303001,
0.018320147, 0.099247105, 0.082998488, 0.000888759, 0.016183068,
0.006294048, 0.002853816, 0.019514895, 0.038458183, 0.002923949,
0.106293548, 0.011739459, 0.000128574, 0.007004556, 0.114129525,
0.012154148, 0.00942754, 0.009594396, 1.79e-05, 0.003734627,
8.05e-06, 0.119908919, 0.018081544, 0.075305864, 0.008538072,
0.000172614, 0.011539718, 0.001156176, 2.3e-05, 0.06492041, 0.12754611,
0.00024379, 0.006267908, 0.00306844, 0.001193837, 0.013286424,
0.113241894, 0.00550093, 0.000513184, 0.164987722, 0.008430982,
0.01127053, 0.00073653, 0.000330426, 0.002238095, 0.104762755,
0.010050252, 0.000469937, 0.145991698, 0.016278919, 0.000640692,
0.005282822, 0.005445685, 0.00014593, 0.000589578, 0.003085291,
0.003763146, 0.118843056, 0.019891671, 0.007112815, 0.004553507,
0.014161345, 0.011043344, 1.65e-05, 0.05419503, 0.107074967,
0.01952576, 0.015831838, 0.015618949, 0.133629759, 0.016718132,
0.120940954, 0.072855599, 0.066799617, 0.006925232)), .Names = c("Filename",
"Funds", "Biotech", "Transfers", "Collab"), class = "data.frame", row.names = c(NA,
-166L))
As #Cath mentioned, your problem is with the column of text. Removing this works:
EUTopicNetworks2 <- EUTopicNetworks[,-1]
class(EUTopicNetworks2)
library(cluster)
FundDist <- as.matrix(daisy(EUTopicNetworks2, metric = "euclidean", stand = TRUE))
By running this code I was able to answer the question I posed in one of the comments
row.names(EUTopicNetworks) <- EUTopicNetworks[,1]
EUTopicNetworks <- EUTopicNetworks[,-1]
library(cluster)
FundDist <- as.matrix(daisy(EUTopicNetworks, metric = "euclidean", stand = TRUE))

Error in R tbats function

I have 548 weeks of data and am trying to use tbats with little success. I get the following error:
Error in checkForRemoteErrors(val) :
3 nodes produced errors; first error: function cannot be evaluated at initial parameters
my data:
weeklyu <-structure(list(V1 = c(18594L, 13593L, 9854L, 12040L, 12920L,
13302L, 12500L, 13073L, 13801L, 12895L, 13199L, 21568L, 19848L,
13418L, 13188L, 13560L, 21327L, 17724L, 11875L, 12475L, 15130L,
14497L, 16289L, 22388L, 17091L, 21104L, 19579L, 18432L, 13234L,
16728L, 15368L, 18105L, 14715L, 16763L, 16788L, 15701L, 17331L,
18725L, 24336L, 16186L, 14299L, 15144L, 17444L, 19384L, 17035L,
18611L, 25946L, 32773L, 41676L, 59446L, 74874L, 19839L, 18325L,
17417L, 14025L, 15225L, 15323L, 16075L, 14756L, 15567L, 19416L,
15190L, 14349L, 19137L, 17714L, 22033L, 20182L, 16660L, 23325L,
19769L, 19465L, 16379L, 20762L, 19084L, 17395L, 21461L, 17616L,
25190L, 22671L, 21138L, 15302L, 19633L, 18951L, 20609L, 16493L,
18680L, 19583L, 18474L, 17654L, 20000L, 26003L, 17507L, 16547L,
18051L, 18627L, 19451L, 17682L, 19522L, 26240L, 33652L, 44835L,
59187L, 84620L, 32522L, 19829L, 17226L, 14330L, 15146L, 16043L,
16891L, 14569L, 14405L, 15919L, 13953L, 13014L, 16951L, 19543L,
23729L, 21614L, 14385L, 18847L, 17892L, 13140L, 11989L, 31371L,
32555L, 27598L, 29342L, 20787L, 30886L, 31296L, 26188L, 18586L,
22866L, 23160L, 26679L, 19641L, 20722L, 23915L, 16546L, 21480L,
21822L, 32611L, 21739L, 19410L, 17950L, 20800L, 22238L, 22667L,
21158L, 29635L, 38873L, 51334L, 67618L, 102150L, 56709L, 27771L,
20496L, 15617L, 17840L, 19616L, 19477L, 19703L, 17789L, 22365L,
21165L, 19706L, 30054L, 28939L, 26935L, 24446L, 18319L, 27419L,
43941L, 21068L, 18139L, 18385L, 22229L, 23650L, 28577L, 22497L,
27637L, 32822L, 28892L, 22691L, 23788L, 23727L, 22212L, 19853L,
21458L, 24941L, 23761L, 22393L, 20688L, 30884L, 30939L, 19373L,
19446L, 22363L, 25349L, 24333L, 24361L, 25849L, 40634L, 52033L,
68422L, 112772L, 84959L, 31343L, 24789L, 22639L, 19352L, 22176L,
21494L, 20161L, 17960L, 22985L, 24113L, 20326L, 20605L, 23159L,
28641L, 34736L, 22614L, 28310L, 33962L, 23836L, 21205L, 19933L,
23414L, 24127L, 25762L, 27898L, 27069L, 37598L, 32451L, 31210L,
24470L, 26281L, 23764L, 24506L, 21034L, 27204L, 29456L, 26162L,
25692L, 33738L, 32727L, 22314L, 22937L, 23974L, 28979L, 26481L,
27885L, 28264L, 41185L, 53924L, 62340L, 109928L, 97952L, 33023L,
27537L, 19913L, 18757L, 24361L, 22391L, 22402L, 19865L, 23339L,
23995L, 19874L, 19599L, 24435L, 31449L, 24959L, 18649L, 22280L,
32005L, 23227L, 18678L, 17894L, 23540L, 26109L, 26178L, 36432L,
30085L, 34126L, 28556L, 22603L, 21849L, 27871L, 22422L, 23984L,
19919L, 26152L, 28189L, 23459L, 20078L, 28310L, 31234L, 22394L,
20988L, 21401L, 28869L, 29915L, 25649L, 28483L, 40985L, 56049L,
65034L, 107110L, 103296L, 28677L, 23472L, 21035L, 18810L, 21639L,
22750L, 22675L, 19938L, 20674L, 24204L, 18657L, 20852L, 24986L,
26861L, 34310L, 22236L, 32884L, 37194L, 24933L, 18839L, 19396L,
24473L, 27922L, 24582L, 30348L, 23238L, 33199L, 31392L, 24778L,
20016L, 28230L, 24011L, 21890L, 20894L, 25797L, 29816L, 23384L,
21111L, 23517L, 30393L, 32004L, 20316L, 19941L, 25712L, 27371L,
23985L, 26508L, 39417L, 56225L, 65534L, 106220L, 135823L, 34772L,
24237L, 21064L, 19184L, 22146L, 25044L, 21753L, 21482L, 22178L,
25718L, 21384L, 21099L, 26945L, 33711L, 35273L, 24807L, 22027L,
34099L, 29842L, 21348L, 18802L, 25595L, 27276L, 24056L, 29279L,
24938L, 36060L, 33213L, 30601L, 20955L, 24773L, 28693L, 31301L,
24287L, 24545L, 30910L, 27261L, 23929L, 25167L, 34285L, 35096L,
21831L, 22137L, 25630L, 26853L, 25871L, 27499L, 36479L, 52402L,
58148L, 83033L, 122756L, 58313L, 26249L, 22310L, 17733L, 19202L,
22390L, 20969L, 20553L, 17860L, 24034L, 20915L, 19864L, 25003L,
31461L, 30302L, 21518L, 21273L, 24785L, 28366L, 26014L, 20288L,
21098L, 23394L, 21124L, 26181L, 24367L, 33042L, 32558L, 27164L,
20895L, 24235L, 26494L, 26734L, 17734L, 19397L, 25407L, 23536L,
21434L, 22248L, 34186L, 25554L, 18707L, 17292L, 19123L, 23300L,
21337L, 23136L, 27681L, 49923L, 59344L, 77552L, 97665L, 68414L,
27532L, 21217L, 16269L, 17607L, 22626L, 21087L, 20776L, 15611L,
22448L, 20070L, 18562L, 22027L, 25401L, 33810L, 21264L, 28131L,
28179L, 39713L, 23450L, 20752L, 23593L, 27141L, 25511L, 30010L,
23526L, 29145L, 34520L, 32609L, 30214L, 25018L, 26091L, 22625L,
21205L, 21550L, 29100L, 27555L, 21273L, 22519L, 32719L, 29749L,
29160L, 19621L, 23631L, 27312L, 26380L, 25949L, 30285L, 46186L,
59925L, 71215L, 120941L, 87855L, 32558L, 23906L, 22984L, 19685L,
23324L, 20996L, 21947L, 17577L, 23871L, 22242L, 18914L, 18821L,
24463L, 33096L, 27962L, 20848L, 26917L, 34725L, 21951L, 18351L,
17952L, 24975L, 23563L, 23275L, 29248L, 28011L, 37056L)), .Names = "V1", class = "data.frame", row.names = c(NA,
-548L))
The data has 53 weeks in a leap year and there are two seasonalities present: 52.25 and 209.
weeklyts <- msts(weeklyu, seasonal.period=c(52.25,209),
ts.frequency=52.25)
I then try:
weeklytbat <- tbats(weeklyts)
and then get the error above.
It will work if I set seasonal.periods to c(52,209) or c(52.3,209) or c(52.2501,209).
Any help would be much appreciated
This was a bug in the function caused by one seasonal period being a small multiple of the other. It is now fixed in the github version at https://github.com/robjhyndman/forecast. The CRAN version will be updated in due course.
If you run traceback() on your error message, you can see that the error originates from a function call in the parallel package. By default, tbats attempts to use parallel processing.
You can forego parallel processing with use.parallel = FALSE, but then there is a different error message which ties more closely to the source of the issue.
weeklytbat <- tbats(weeklyts, use.parallel=F)
Error in optim(par = param.vector$vect, fn = calcLikelihoodTBATS, method = "Nelder-Mead", :
function cannot be evaluated at initial parameters
I would suggest using one of your other seasonal periods unless you want to dig in to the optimization routine for your data.
HTH

object not found - plot.xy

I'm trying to run codes that are below. And R gives an Error object 'fireworks' not found.
Did anyone came cross such Error. How could I fix it?
plot.xy(attend/10000~temp|skies+day_night,
data=dodgers,
groups=fireworks,
pch=group.symbols,
aspect=1,cex=1.5,
col=group.colors,
fill=group.fill,
layout=c(2,2),
type=c("p","g"),
xlab="Temperature(Degrees Fahrenheit)",
ylab="Attendance(thousands)",
key=list(space="top", text=list(rev(group.labels),
col=rev(group.labels)),
fill=rev(group.fill)))
Eror:
in plot.xy(attend/10000 ~ temp | skies + day_night, data = dodgers, :
object 'fireworks' not found

Resources