1\name{is.regular}
2\alias{is.regular}
3\alias{is.regular.zoo}
4\alias{is.regular.ts}
5\alias{is.regular.zooreg}
6\alias{is.regular.default}
7
8\title{Check Regularity of a Series}
9
10\description{
11\code{is.regular} is a regular function for checking whether a series of ordered observations
12has an underlying regularity or is even strictly regular.
13}
14
15\usage{
16is.regular(x, strict = FALSE)
17}
18
19\arguments{
20  \item{x}{an object (representing a series of ordered observations).}
21  \item{strict}{logical. Should strict regularity be checked? See details.}
22}
23
24\details{
25A time series can either be irregular (unequally spaced), strictly regular (equally spaced)
26or have an underlying regularity, i.e., be created from a regular series by
27omitting some observations. Here, the latter property is called \emph{regular}.
28Consequently, regularity follows from strict regularity but not vice versa.
29
30\code{is.regular} is a generic function for checking regularity (default) or
31strict regularity. Currently, it has methods for \code{"ts"} objects (which are
32always strictly regular), \code{"zooreg"} objects (which are at least regular),
33\code{"zoo"} objects (which can be either irregular, regular or even strictly regular)
34and a default method. The latter coerces \code{x} to \code{"zoo"} before checking
35its regularity.
36}
37
38\value{
39A logical is returned indicating whether \code{x} is (strictly) regular.
40}
41
42\seealso{\code{\link{zooreg}}, \code{\link{zoo}}}
43
44\examples{
45## checking of a strictly regular zoo series
46z <- zoo(1:10, seq(2000, 2002.25, by = 0.25), frequency = 4)
47z
48class(z)
49frequency(z) ## extraction of frequency attribute
50is.regular(z)
51is.regular(z, strict = TRUE)
52## by omitting observations, the series is not strictly regular
53is.regular(z[-3])
54is.regular(z[-3], strict = TRUE)
55
56## checking of a plain zoo series without frequency attribute
57## which is in fact regular
58z <- zoo(1:10, seq(2000, 2002.25, by = 0.25))
59z
60class(z)
61frequency(z) ## data driven computation of frequency
62is.regular(z)
63is.regular(z, strict = TRUE)
64## by omitting observations, the series is not strictly regular
65is.regular(z[-3])
66is.regular(z[-3], strict = TRUE)
67
68suppressWarnings(RNGversion("3.5.0"))
69set.seed(1)
70
71## checking of an irregular zoo series
72z <- zoo(1:10, rnorm(10))
73z
74class(z)
75frequency(z) ## attempt of data-driven frequency computation
76is.regular(z)
77is.regular(z, strict = TRUE)
78}
79\keyword{ts}
80