csgillespie / poweRlaw

This package implements both the discrete and continuous maximum likelihood estimators for fitting the power-law distribution to data. Additionally, a goodness-of-fit based approach is used to estimate the lower cutoff for the scaling region.
109 stars 24 forks source link

Bootstrap error: one node produced an error: index 0 outside bounds #56

Closed csgillespie closed 8 years ago

csgillespie commented 9 years ago
library(poweRlaw)
vec<-c(1,1,1,1,1,2,1,1,4,1,1,1,1,1,1,1,1,2,1,1,1,2,2,1,2,1,
       1,2,1,1,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,2)

Can fit the power law and calculate the p-value:

pl=displ$new(vec)
est=estimate_xmin(pl)
bts=bootstrap_p(pl,no_of_sims=30,seed=42)

However, when I increase the number of simulations, to for instance 35, I get the following error:

Error in checkForRemoteErrors(val) : 
  one node produced an error: index 0 outside bounds

From https://stackoverflow.com/questions/33367417/r-error-for-bootstrap-simulation-powerlaw-package

csgillespie commented 8 years ago

Seems to be fixed. Can't reproduce.

atfornes commented 7 years ago

I have the same error happening very often from the data I generate for a simulation project. As suggested here: https://stackoverflow.com/a/33415768/4928558 it might be due to a big number of 1's happening in the distributions.

Distribution example for which I got the errors under bootstrap(pl, no_of_sims=100): [9 8 3 3 2 2 2 1 1 1 1 1 1] [7 4 3 3 2 2 2 2 2 1 1 1 1 1 1 1] [6 3 2 2 2 2 2 2 1 1 1 1 1 1 1] [10 6 4 2 2 1 1 1 1 1 1 1 1 1] [6 5 4 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1] [6 4 3 3 2 2 2 2 1 1 1 1 1 1 1 1 1 1] [7 5 5 3 3 3 3 2 2 2 2 2 1 1 1 1 1 1]

Distributions for which I did not got the error: [12 10 6 6 5 3 2 2 2 1 1 1 1 1 1] [11 10 8 7 4 2 2 2 2 2 1 1 1 1 1 1 1]

Is there a workaround to avoid this errors?

csgillespie commented 7 years ago

What version of powerlaw are you using

atfornes commented 7 years ago

sessionInfo gives me the following version for poweRlaw: poweRlaw_0.70.0

csgillespie commented 7 years ago

Would you run update.packages() and try again. Thanks

atfornes commented 7 years ago

thanks @csgillespie, with version poweRlaw_0.70.1 obtained by running update.packages() the problem is solved. 👍 😄

willgearty commented 5 years ago

I'm running into this problem in poweRlaw_0.70.2.0001. I can reproduce the example in the OP.

csgillespie commented 5 years ago

@willgearty I can't reproduce this error - I think it may also be in the test suite.

What does sessionInfo() give?

willgearty commented 5 years ago
> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] poweRlaw_0.70.2.0001 MASS_7.3-51.1        Hmisc_4.2-0          Formula_1.2-3        survival_2.43-3     
 [6] lattice_0.20-38      qgam_1.2.3           mgcv_1.8-27          nlme_3.1-137         segmented_0.5-3.0   
[11] tidyr_0.8.3          stringr_1.4.0        reshape2_1.4.3       ggplot2_3.1.0.9000   paleoMap_0.1        
[16] boot_1.3-20          dispeRse_0.0.1       geiger_2.0.6.1       Claddis_0.3.0        strap_1.4           
[21] geoscale_2.0         phytools_0.6-60      maps_3.3.0           ape_5.2              usethis_1.4.0       
[26] devtools_2.0.1       investr_1.4.0        raster_2.9-1         sp_1.3-1             plyr_1.8.4          
[31] rgbif_1.2.0         

loaded via a namespace (and not attached):
  [1] backports_1.1.3         fastmatch_1.1-0         VGAM_1.1-1              igraph_1.2.4           
  [5] lazyeval_0.2.1          digest_0.6.18           foreach_1.5.1           htmltools_0.3.6        
  [9] gdata_2.18.0            checkmate_1.9.1         magrittr_1.5            memoise_1.1.0          
 [13] geoaxe_0.1.0            cluster_2.0.7-1         doParallel_1.0.14       remotes_2.0.2          
 [17] prettyunits_1.0.2       colorspace_1.4-1        xfun_0.5                dplyr_0.8.0.1          
 [21] callr_3.1.1             crayon_1.3.4            RCurl_1.95-4.12         jsonlite_1.6           
 [25] roxygen2_6.1.1          phangorn_2.4.0          iterators_1.0.11        glue_1.3.0             
 [29] gtable_0.2.0            pkgbuild_1.0.2          scales_1.0.0            oai_0.2.2              
 [33] mvtnorm_1.0-10          Rcpp_1.0.0              plotrix_3.7-4           viridisLite_0.3.0      
 [37] xtable_1.8-3            htmlTable_1.13.1        foreign_0.8-71          subplex_1.5-4          
 [41] deSolve_1.22            stats4_3.5.2            animation_2.6           htmlwidgets_1.3        
 [45] httr_1.4.0              RColorBrewer_1.1-2      acepack_1.4.1           pkgconfig_2.0.2        
 [49] nnet_7.3-12             tidyselect_0.2.5        labeling_0.3            rlang_0.3.1            
 [53] later_0.8.0             munsell_0.5.0           tools_3.5.2             cli_1.0.1              
 [57] knitr_1.22              processx_3.3.0          fs_1.2.6                purrr_0.3.1            
 [61] whisker_0.3-2           mime_0.6                paleobioDB_0.6.0        xml2_1.2.0             
 [65] compiler_3.5.2          rstudioapi_0.9.0        curl_3.3                clusterGeneration_1.3.4
 [69] tibble_2.0.1            stringi_1.3.1           ps_1.3.0                desc_1.2.0             
 [73] rgeos_0.4-3             Matrix_1.2-16           commonmark_1.7          vegan_2.5-4            
 [77] permute_0.9-4           pillar_1.3.1            combinat_0.0-8          data.table_1.12.0      
 [81] bitops_1.0-6            maptools_0.9-5          httpuv_1.4.5.1          R6_2.4.0               
 [85] latticeExtra_0.6-28     promises_1.0.1          gridExtra_2.3           sessioninfo_1.1.1      
 [89] codetools_0.2-16        gtools_3.8.1            assertthat_0.2.0        pkgload_1.0.2          
 [93] rprojroot_1.3-2         rjson_0.2.20            withr_2.1.2             mnormt_1.5-5           
 [97] expm_0.999-3            parallel_3.5.2          quadprog_1.5-5          grid_3.5.2             
[101] rpart_4.1-13            coda_0.19-2             numDeriv_2016.8-1       scatterplot3d_0.3-41   
[105] shiny_1.2.0             base64enc_0.1-3
csgillespie commented 5 years ago

I think it's the issue at https://github.com/csgillespie/poweRlaw/issues/84

Fix should be soon (ish)

willgearty commented 5 years ago

Awesome, thank you!

csgillespie commented 5 years ago

Could you try the latest version. Thanks

willgearty commented 5 years ago

Yep, it works, thanks for the quick fix!