Check Regularity of a Series
is.regular.Rdis.regular is a regular function for checking whether a series of ordered observations
has an underlying regularity or is even strictly regular.
Details
A time series can either be irregular (unequally spaced), strictly regular (equally spaced) or have an underlying regularity, i.e., be created from a regular series by omitting some observations. Here, the latter property is called regular. Consequently, regularity follows from strict regularity but not vice versa.
is.regular is a generic function for checking regularity (default) or
strict regularity. Currently, it has methods for "ts" objects (which are
always strictly regular), "zooreg" objects (which are at least regular),
"zoo" objects (which can be either irregular, regular or even strictly regular)
and a default method. The latter coerces x to "zoo" before checking
its regularity.
Examples
## checking of a strictly regular zoo series
z <- zoo(1:10, seq(2000, 2002.25, by = 0.25), frequency = 4)
z
#> 2000 Q1 2000 Q2 2000 Q3 2000 Q4 2001 Q1 2001 Q2 2001 Q3 2001 Q4 2002 Q1 2002 Q2
#> 1 2 3 4 5 6 7 8 9 10
class(z)
#> [1] "zooreg" "zoo"
frequency(z) ## extraction of frequency attribute
#> [1] 4
is.regular(z)
#> [1] TRUE
is.regular(z, strict = TRUE)
#> [1] TRUE
## by omitting observations, the series is not strictly regular
is.regular(z[-3])
#> [1] TRUE
is.regular(z[-3], strict = TRUE)
#> [1] FALSE
## checking of a plain zoo series without frequency attribute
## which is in fact regular
z <- zoo(1:10, seq(2000, 2002.25, by = 0.25))
z
#> 2000 2000.25 2000.5 2000.75 2001 2001.25 2001.5 2001.75 2002 2002.25
#> 1 2 3 4 5 6 7 8 9 10
class(z)
#> [1] "zoo"
frequency(z) ## data driven computation of frequency
#> [1] 4
is.regular(z)
#> [1] TRUE
is.regular(z, strict = TRUE)
#> [1] TRUE
## by omitting observations, the series is not strictly regular
is.regular(z[-3])
#> [1] TRUE
is.regular(z[-3], strict = TRUE)
#> [1] FALSE
suppressWarnings(RNGversion("3.5.0"))
set.seed(1)
## checking of an irregular zoo series
z <- zoo(1:10, rnorm(10))
z
#> -0.8356 -0.8205 -0.6265 -0.3054 0.1836 0.3295 0.4874 0.5758 0.7383 1.5953
#> 3 6 1 10 2 5 7 9 8 4
class(z)
#> [1] "zoo"
frequency(z) ## attempt of data-driven frequency computation
#> NULL
is.regular(z)
#> [1] FALSE
is.regular(z, strict = TRUE)
#> [1] FALSE