Dealing with gaps in time series

in #timeseries7 years ago

When dealing with a time series we often need to answer the problem of "Is it time series complete?". Another question would be "Which is the biggest gap in the dates?" and "Which is the biggest gap in the data?" or "What is the period with biggest consecutive missing data?".

I did not find any R-package solving THOSE specific problems. So I spent some time developing the following functions.

Basically, findNAGap receives a vector dates of Date types and values of Numeric type. It returns a list type object with
maxGap with the size of maximum NA's gap found, dateStart with the first date in time series where this sequence starts and dateEnd, the date where it ends.

Conceptually different, findDateGap receives only a vector dates of Date types. It checks if there are NA's in your sequence of dates or if there are leaps with no NA's reported in the time sequence. The list object returns same list object described in findNAGap.

CumulativeZeros is a support function for the former functions and receives a Numeric type vector x and returns, at any position of vector, the cumulative sum of consecutive zeros occurrences at these point. Returns a numeric vector with the counting.

A small code to test and the source code are in my git.

Coin Marketplace

STEEM 0.16
TRX 0.13
JST 0.027
BTC 60629.29
ETH 2636.33
USDT 1.00
SBD 2.51