简体   繁体   English

tsfeatures()无意义错误(需要至少两个非NA值进行插值,但所有值均为非NA)

[英]tsfeatures() non-sense error (need at least two non-NA values to interpolate, but all values are non-NA)

tsfeatures() says that approx() fails due to needing at least two non-NA values to interpolate. tsfeatures()表示, approx()由于失败需要至少两个非NA值来内插。 I can't find any NAs in my time series or the time series index, and I can construct a toy example with no NA values, ordered and unique indices, and still reproduce the error. 我在我的时间序列或时间序列索引中找不到任何NA,并且可以构造一个没有NA值,有序且唯一的索引的玩具示例,并且仍然可以重现错误。

There appear to be a number of previous questions concerning R's tsfeatures() function, but I can't find one that explains why I'm receiving the error: 以前似乎有很多关于R的tsfeatures()函数的问题,但是我找不到一个可以解释为什么收到错误的问题:

Error in approx(idx, x[idx], tt, rule = 2) : 
  need at least two non-NA values to interpolate
# datetimes has type POSIXct
Browse[3]> class(datetimes[1:3])
[1] "POSIXct" "POSIXt"

# the first three date times are unique and ordered
Browse[3]> datetimes[1:3]
[1] "2019-06-18 19:59:48 PDT" "2019-06-18 20:00:48 PDT" "2019-06-18 20:01:48 PDT"

# create our time series
Browse[3]> temp = xts(x = c(0, 0, 0), order.by = datetimes[1:3])
Browse[3]> temp
                    [,1]
2019-06-18 19:59:48    0
2019-06-18 20:00:48    0
2019-06-18 20:01:48    0

# try to get our features:
Browse[3]> tsfeatures(temp)
Error in approx(idx, x[idx], tt, rule = 2) : 
  need at least two non-NA values to interpolate

Edit: My teammate and I discovered that the error message is displayed if the time series consists of entirely the same value: 编辑:我和我的队友发现,如果时间序列完全相同,则显示错误消息:

Browse[3]> tsfeatures(xts(x = c(1, 1, 1), order.by = datetimes[1:3]))
Error in approx(idx, x[idx], tt, rule = 2) : 
  need at least two non-NA values to interpolate

Browse[3]> tsfeatures(xts(x = c(1, 2, 1), order.by = datetimes[1:3]))
# A tibble: 1 x 16
  frequency nperiods seasonal_period    trend spike linearity curvature e_acf1 e_acf10 entropy x_acf1 x_acf10 diff1_acf1 diff1_acf10 diff2_acf1 diff2_acf10
      <dbl>    <dbl>           <dbl>    <dbl> <dbl>     <dbl>     <dbl>  <dbl>   <dbl>   <dbl>  <dbl>   <dbl>      <dbl>       <dbl>      <dbl>       <dbl>
1    0.0167        0          0.0167 1.11e-16 0.333 -6.04e-32  3.49e-32 -0.667      NA      NA -0.667      NA       -0.5        0.25         NA           0

Can someone explain the error message? 有人可以解释该错误信息吗?

The error is due to the fact that tsfeatures() automatically scales the time series by default. 该错误是由于tsfeatures()默认情况下会自动缩放时间序列。 When you pass a constant series, scaling reduces the series to NaN s. 当您传递一个常数序列时,按比例缩放会将序列减小为NaN s。 This is now prevented in the current github version -- fixed here . 现在在当前的github版本中已阻止了此问题- 此处已修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM