robjhyndman / tsfeatures

Time series features
http://pkg.robjhyndman.com/tsfeatures
253 stars 42 forks source link

error in hurst #31

Closed jmablans closed 4 years ago

jmablans commented 4 years ago

Dear professor Hyndman,

Thank you very much for this very useful library.

I ran into some errors while applying this package to tiny time series. Shouldn't NA be returned when no value can be calculated?

Below a reprex with the generated errors or output in comments.

Thank you in advance and kind regards, Jan Blans

ts <- as.ts(c(1,1))
tsfeatures::tsfeatures(ts, features = c('hurst'))
# error in na.contiguous.default(x) : all times contain an NA

ts <- as.ts(c(1,1,1))
tsfeatures::tsfeatures(ts, features = c('hurst'))
# error in na.contiguous.default(x) : all times contain an NA

ts <- as.ts(c(1,1,0))
tsfeatures::tsfeatures(ts, features = c('hurst'))
# no error:
# # A tibble: 1 x 1
#  hurst
#   <dbl>
# 1 0.500

ts <- as.ts(c(1,0))
tsfeatures::tsfeatures(ts, features = c('hurst'))
# no error:
# # A tibble: 1 x 1
#  hurst
#   <dbl>
# 1 0.500

ts <- as.ts(c(0,1))
tsfeatures::tsfeatures(ts, features = c('hurst'))
# no error:
# # A tibble: 1 x 1
#  hurst
#   <dbl>
# 1 0.500
robjhyndman commented 4 years ago

I can't replicate these ones using the current github version of tsfeatures, with fracdiff v1.4-2 under R v3.6.1. Can you please post your sessionInfo()?

jmablans commented 4 years ago

I updated R and reinstalled the latest version of fracdiff. The errors persist.

ts <- as.ts(c(1,1))
tsfeatures::tsfeatures(ts, features = c('hurst'))
# Error in na.contiguous.default(x) : all times contain an NA

ts <- as.ts(c(1,1,1))
tsfeatures::tsfeatures(ts, features = c('hurst'))
# Error in na.contiguous.default(x) : all times contain an NA
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

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.6/Resources/lib/libRlapack.dylib

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 

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] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] fracdiff_1.4-2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3        magrittr_1.5      forecast_8.9     
 [4] munsell_0.5.0     colorspace_1.4-1  lattice_0.20-38  
 [7] R6_2.4.1          rlang_0.4.1       quadprog_1.5-7   
[10] TTR_0.23-5        xts_0.11-2        tools_3.6.1      
[13] quantmod_0.4-15   nnet_7.3-12       parallel_3.6.1   
[16] grid_3.6.1        nlme_3.1-140      timeDate_3043.102
[19] gtable_0.3.0      urca_1.3-0        tseries_0.10-47  
[22] lazyeval_0.2.2    lmtest_0.9-37     tibble_2.1.3     
[25] lifecycle_0.1.0   crayon_1.3.4      purrr_0.3.3      
[28] ggplot2_3.2.1     tsfeatures_1.0.1  curl_4.2         
[31] compiler_3.6.1    pillar_1.4.2      scales_1.1.0     
[34] pkgconfig_2.0.3   zoo_1.8-6