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 m_ln error: one node produced an error: index 0 outside bounds #87

Closed vvzhukov closed 4 years ago

vvzhukov commented 4 years ago

Hello there!

Have a bug similar to https://github.com/csgillespie/poweRlaw/issues/56, yet reproduced for the lognormal model.

Code:

x = c(3, 3, 1, 3, 3, 3, 2, 3, 3, 3, 3, 1, 2, 3, 3, 1, 3, 3, 3, 3, 3)
m_ln <- dislnorm$new(x)
bsLN <- bootstrap(m_ln, no_of_sims= 1, seed=1)  

Error:

Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : index 0 outside bounds

sessionInfo()

R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS 10.15.1

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages: [1] data.table_1.12.2 dplyr_0.8.3 pander_0.6.3 knitr_1.23 igraph_1.2.4.1
[6] EnvStats_2.3.1 truncdist_1.0-2 evd_2.3-3 nortest_1.0-4 STAND_2.0
[11] survival_2.44-1.1 MASS_7.3-51.4 car_3.0-3 carData_3.0-2 poweRlaw_0.70.2.0003 [16] moments_0.14

loaded via a namespace (and not attached): [1] Rcpp_1.0.2 lattice_0.20-38 prettyunits_1.0.2 ps_1.3.0 rprojroot_1.3-2
[6] assertthat_0.2.1 zeallot_0.1.0 digest_0.6.20 R6_2.4.0 cellranger_1.1.0 [11] backports_1.1.4 evaluate_0.14 ggplot2_3.2.0 pillar_1.4.2 rlang_0.4.0
[16] lazyeval_0.2.2 curl_4.0 readxl_1.3.1 rstudioapi_0.10 callr_3.3.1
[21] Matrix_1.2-17 rmarkdown_1.14 desc_1.2.0 devtools_2.2.1 splines_3.5.0
[26] foreign_0.8-72 munsell_0.5.0 compiler_3.5.0 xfun_0.8 pkgconfig_2.0.2
[31] pkgbuild_1.0.3 htmltools_0.3.6 tidyselect_0.2.5 tibble_2.1.3 rio_0.5.16
[36] withr_2.1.2 crayon_1.3.4 grid_3.5.0 gtable_0.3.0 magrittr_1.5
[41] scales_1.0.0 zip_2.0.3 cli_1.1.0 fs_1.3.1 remotes_2.1.0
[46] testthat_2.2.1 ellipsis_0.3.0 vctrs_0.2.0 openxlsx_4.1.0.1 tools_3.5.0
[51] forcats_0.4.0 glue_1.3.1 purrr_0.3.2 hms_0.5.0 processx_3.4.1
[56] abind_1.4-5 pkgload_1.0.2 parallel_3.5.0 yaml_2.2.0 colorspace_1.4-1 [61] sessioninfo_1.1.1 VGAM_1.1-2 memoise_1.1.0 haven_2.1.1 usethis_1.5.1

Thank you! Best, Vitalii

csgillespie commented 4 years ago

Thanks for the report. The latest version tries to give a more informative error version

Error in bootstrap(m_ln, no_of_sims = 1, seed = 1) : Unable to estimate initial parameters using estimate_xmin, so we can't bootstrap.

vvzhukov commented 4 years ago

Here is another issue (could be the same problem): x = c(2,1,1,4,2,1,1,3,3,1,3,3,3,1,4,2,2,1,3,1,4,1,3,2,1,3,2,1) m_ln <- dislnorm$new(x) bsLN <- bootstrap(m_ln, no_of_sims= 100, seed=1) Leads to:

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

Works fine with no_of_sims <= 71. 72 or more simulations gives 'bounds' error.

poweRlaw_0.70.2

csgillespie commented 4 years ago

It's the same issue, but with a bad error message. During bootstrapping, we sampled only three unique values, this means we can't estimate the parameters.

I'll try and improve the error message

csgillespie commented 4 years ago

Pushed the latest version to CRAN.