rstatisticspower-law

R: error for bootstrap simulation poweRlaw package


I am using the poweRlaw package to fit some data and calculate p-values. I noticed that in some cases, where there is not so much variation in the data combined with a relatively small number of observations, I am unable to calculate a p-value once the number of simulations passes a certain threshold.

Consider the following data:

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

Actually I don't really understand what the error means practically. I guess an issue here is that the observed data probably doesn't follow a power law, at least not at this relatively low number of observations. But how come that this error occurs at 35 simulations but not 30?


Solution

  • Solution This issue was fixed in poweRlaw version 0.7.1

    Run update.packages().


    I think the error arises because during the bootstrap procedure, when mainly 1 are selected. This leads to numerical instability when estimating the scaling parameter.

    I've created an issue at https://github.com/csgillespie/poweRlaw/issues/56