Skip to content

Instantly share code, notes, and snippets.

@jkeirstead
Last active August 29, 2015 14:05
Show Gist options
  • Save jkeirstead/7f228e7cc6a4e677b011 to your computer and use it in GitHub Desktop.
Save jkeirstead/7f228e7cc6a4e677b011 to your computer and use it in GitHub Desktop.
Demo of error in poweRlaw's bootstrap_p
## Define the problem data
x <- read.csv("x-values.csv")$x
## Fit the power law. Looks okay with plots
library(poweRlaw)
mod <- conpl$new(x)
xmin <- estimate_xmin(mod, xmins=head(sort(x), n=10))
mod$setXmin(xmin)
pars <- estimate_pars(mod)
mod$setPars(pars)
## This throws an error; normal `bootstrap` does not.
bs_p <- bootstrap_p(mod, xmins=head(sort(x), 10), no_of_sims=100, threads=1)
> bs_p <- bootstrap_p(mod, xmins=head(sort(x), 10), no_of_sims=100, threads=1)
Error in checkForRemoteErrors(val) :
one node produced an error: 'x' must be an array of at least two dimensions
> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] poweRlaw_0.20.5 plyr_1.8.1 stringr_0.6.2 reshape2_1.4
[5] decctools_0.2.0 XLConnect_0.2-7 R.cache_0.10.0 ggplot2_1.0.0
[9] dplyr_0.2 mapproj_1.2-2 maps_2.3-7 rgeos_0.3-4
[13] maptools_0.8-30 rgdal_0.8-16 sp_1.0-15
loaded via a namespace (and not attached):
[1] MASS_7.3-31 R.methodsS3_1.6.1 R.oo_1.18.0 R.utils_1.32.4
[5] RCurl_1.95-4.1 Rcpp_0.11.2 VGAM_0.9-4 XML_3.98-1.1
[9] assertthat_0.1 colorspace_1.2-4 compiler_3.1.0 digest_0.6.4
[13] foreign_0.8-61 grid_3.1.0 gtable_0.1.2 lattice_0.20-29
[17] lubridate_1.3.3 memoise_0.2.1 munsell_0.4.2 parallel_3.1.0
[21] proto_0.3-10 rJava_0.9-6 scales_0.2.4 stats4_3.1.0
[25] tools_3.1.0
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"x"
238977.445787167
222829.421554204
345852.983698807
146842.613318852
476816.759953662
1054543.19159033
145729.204855821
179954.855837603
230113.35917479
338537.279710548
2387738.86283773
140827.339206303
320002.248677028
278112.637596593
370639.534331114
497691.249962157
335324.414869136
680148.220545513
169994.759788847
112012.86792053
258138.552270288
317866.632668597
231586.976831148
245210.126390886
300734.951759561
117424.611139597
153567.343713797
84781.5762702135
429763.775834514
247199.23530276
126378.121589026
738084.977857337
470260.179955001
787402.049223172
9471810.7119527
186952.76843232
1837145.91134051
210831.392832475
449044.565025654
231203.14760889
788414.79330846
201663.568174885
248535.802574909
645657.146405004
146964.280217154
179069.334746668
246406.416443691
489919.917694196
350674.112763606
417733.662878138
208899.049995251
770976.827665753
349584.831296525
333062.824543775
364753.679233717
272062.764355044
198086.903040638
161706.532078401
325270.351154595
205700.396990574
324172.196135943
97774.6596723435
196906.703487424
669691.445808538
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment