Tools for checking if a series of timestamps is 'regular' meaning that
it has no duplicates, and no gaps. Checking for regularity can be
tricky. For example, if you have monthly observations with
POSIXt timestamps then gaps
between timestamps can be 28, 29, 30, or 31 days, but the series is
NoDuplicates(timestamps) NoGaps(timestamps) IsRegular(timestamps) HasDuplicateTimestamps(bsts.object)
A set of (possibly irregular or non-unique)
timestamps. This could be a set of integers (like 1, 2, , 3...), a
set of numeric like (1945, 1945.083, 1945.167, ...) indicating years
and fractions of years, a
A bsts model object.
All four functions return scalar logical values.
TRUE if all elements of
timestamps are unique.
NoGaps examines the smallest nonzero gap between time points.
As long as no gaps between time points are more than twice as wide as
the smallest gap, it returns
TRUE, indicating that there are no
missing timestamps. Otherwise it returns
NoGaps both return
FALSE if the data used to
fit bsts.model either has NULL timestamps, or if the timestamps
contain no duplicate values.
Steven L. Scott email@example.com
first <- as.POSIXct("2015-04-19 08:00:04") monthly <- seq(from = first, length.out = 24, by = "month") IsRegular(monthly) ## TRUE skip.one <- monthly[-8] IsRegular(skip.one) ## FALSE has.duplicates <- monthly has.duplicates <- has.duplicates IsRegular(has.duplicates) ## FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.