regul {pastecs} | R Documentation |
Regulation of one or several time series using various methods
Description
Regulate irregular time series or regular time series with gaps. Create a regul
object from whose one or several regular time series can be extracted using extract()
or tseries()
. This is the function to apply most of the time to create regular time series ('rts' objects in Splus or 'ts' objects in R) that will be further analyzed by other functions that apply to regular time series.
Usage
regul(x, y=NULL, xmin=min(x), n=length(x), units="days", frequency=NULL,
deltat=1/frequency, datemin=NULL, dateformat="m/d/Y", tol=NULL,
tol.type="both", methods="linear", rule=1, f=0, periodic=FALSE,
window=(max(x) - min(x))/(n - 1), split=100, specs=NULL)
## S3 method for class 'regul'
print(x, ...)
## S3 method for class 'regul'
summary(object, ...)
## S3 method for class 'summary.regul'
print(x, ...)
## S3 method for class 'regul'
plot(x, series=1, col=c(1, 2), lty=c(par("lty"), par("lty")), plot.pts=TRUE,
leg=FALSE, llab=c("initial", x$specs$methods[series]), lpos=c(1.5, 10),
xlab=paste("Time (", x$units, ")", sep = ""), ylab="Series",
main=paste("Regulation of", names(x$y)[series]), ...)
## S3 method for class 'regul'
lines(x, series=1, col=3, lty=1, plot.pts=TRUE, ...)
## S3 method for class 'regul'
identify(x, series=1, col=3, label="#", ...)
## S3 method for class 'regul'
hist(x, nclass=30, col=c(4, 5, 2),
xlab=paste("Time distance in", x$units, "with start =", min(x$x),
", n = ", length(x$x), ", deltat =", x$tspar$deltat),
ylab=paste("Frequency, tol =", x$specs$tol),
main="Number of matching observations", plotit=TRUE, ...)
## S3 method for class 'regul'
extract(e, n, series=NULL, ...)
## S3 method for class 'regul'
specs(x, ...)
## S3 method for class 'specs.regul'
print(x, ...)
Arguments
x |
for regul: a vector containing times at which observations are sampled in the initial irregular time series. It can be expressed in any unit ("years", "days", "weeks", "hours", "min", "sec",...) as defined by the argument |
y |
a vector (single series) or a matrix/data frame whose columns correspond to the various irregular time series to regulate. Rows are observations made at corresponding times in |
xmin |
allows to respecify the origin of time in |
n |
the number of observations in the regular time series. By default, it is the same number than in the original irregular time series (i.e., |
units |
the time unit for the |
frequency |
the frequency of the regulated time series in the corresponding time unit. For instance, |
deltat |
the interval between two observations in the regulated time series. It is the inverse of |
datemin |
this is mostly useful for converting "days" in "years" time-scales ( |
dateformat |
indicate how |
tol |
the tolerance in the time-scale to determine if a measured value is used to approximate a regulated value. If |
tol.type |
the type of adjustment to use for the time-tolerance: |
methods |
the method(s) to use to regulate the time series. Currently, it can be: |
rule |
the rule to use for extrapolated values (observations in the final regular time series that are outside the range of observed values in the initial time series). With |
f |
parameter for the |
periodic |
parameter for the |
window |
parameter for the |
split |
other parameter for the |
specs |
a |
object |
A |
e |
A |
series |
the series to plot. By default, |
col |
(1) for |
lty |
the style to use to draw lines for the initial series and the regulated series, respectively. The default style is used for both lines if this argument is not provided |
plot.pts |
if |
leg |
do we add a legend to the graph? By default, |
llab |
the labels to use for the initial irregular and the final regulated series, respectively. By default, it is |
lpos |
the position of the top-left corner of the legend box (x,y), in the graph coordinates |
xlab |
the label of the x-axis |
ylab |
the label of the y-axis |
main |
the main title of the graph |
label |
the character to use to mark points interactively selected on the graph. By default, |
nclass |
the number of classes to calculate in the histogram. This is indicative and this value is automatically adjusted to obtain a nicely-formatted histogram. By default, |
plotit |
If |
... |
additional parameters |
Details
Several irregular time series (for instance, contained in a data frame) can be treated at once. Specify a vector with "constant"
, "linear"
, "spline"
or "area"
for the argument methods
to use a different regulation method for each series. See corresponding fonctions (regconst()
, reglin()
, regspline()
and regarea()
), respectively, for more details on these methods. Arguments can be saved in a specs
object and reused for other similar regulation processes. Functions regul.screen()
and regul.adj()
are useful to chose best time interval in the computed regular time series. If you want to work on seasonal effects in the time series, you will better use a "years" time-scale (1 unit = 1 year), or convert into such a scale. If initial time unit is "days" (1 unit = 1 day), a conversion can be operated at the same time as the regulation by specifying units="daystoyears"
.
Value
An object of type 'regul' is returned. It has methods print()
, summary()
, plot()
, lines()
, identify()
, hist()
, extract()
and specs()
.
Author(s)
Fr?d?ric Ibanez (ibanez@obs-vlfr.fr), Philippe Grosjean (phgrosjean@sciviews.org)
References
Lancaster, P. & K. Salkauskas, 1986. Curve and surface fitting. Academic Press, England, 280 pp.
Fox, W.T. & J.A. Brown, 1965. The use of time-trend analysis for environmental interpretation of limestones. J. Geol., 73:510-518.
Ibanez, F., 1991. Treatment of the data deriving from the COST 647 project on coastal benthic ecology: The within-site analysis. In: B. Keegan (ed). Space and Time Series Data Analysis in Coastal Benthic Ecology. Pp 5-43.
Ibanez, F. & J.C. Dauvin, 1988. Long-term changes (1977-1987) on a muddy fine sand Abra alba - Melinna palmata population community from the Western English Channel. J. Mar. Ecol. Prog. Ser., 49:65-81.
See Also
regul.screen
, regul.adj
, tseries
, is.tseries
, regconst
, reglin
, regspline
, regarea
, daystoyears
Examples
data(releve)
# The series in this data frame are very irregularly sampled in time:
releve$Day
length(releve$Day)
intervals <- releve$Day[2:61]-releve$Day[1:60]
intervals
range(intervals)
mean(intervals)
# The series must be regulated to be converted in a 'rts' or 'ts object
rel.reg <- regul(releve$Day, releve[3:8], xmin=9, n=63, deltat=21,
tol=1.05, methods=c("s","c","l","a","s","a"), window=21)
rel.reg
plot(rel.reg, 5)
specs(rel.reg)
# Now we can extract one or several regular time series
melo.ts <- extract(rel.reg, series="Melosul")
is.tseries(melo.ts)
# One can convert time-scale from "days" to "years" during regulation
# This is most useful for analyzing seasonal cycles in a second step
melo.regy <- regul(releve$Day, releve$Melosul, xmin=6, n=87,
units="daystoyears", frequency=24, tol=2.2, methods="linear",
datemin="21/03/1989", dateformat="d/m/Y")
melo.regy
plot(melo.regy, main="Regulation of Melosul")
# In this case, we have only one series in 'melo.regy'
# We can use also 'tseries()' instead of 'extract()'
melo.tsy <- tseries(melo.regy)
is.tseries(melo.tsy)