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.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=F,
window=(max(x) - min(x))/(n - 1), split=100, specs=NULL)
## S3 method for class 'regul':
summary(reg)
## S3 method for class 'regul':
plot(reg, series=1, col=c(1, 2), lty, plot.pts=TRUE,
leg=FALSE, llab=c("initial", x$specs$methods[series]),
lpos=c(1.5, 10), ...)
## S3 method for class 'regul':
lines(reg, series=1, col=3, lty=1, plot.pts=TRUE, \dots)
## S3 method for class 'regul':
identify(reg, series=1, col=3, label="#", \dots)
## S3 method for class 'regul':
hist(reg, nclass=30, col=c(4, 5, 2), plotit=TRUE, ...)
## S3 method for class 'regul':
extract(reg, n=ncol(reg$y), series=NULL)
## S3 method for class 'regul':
specs(reg)units. It is often expressed inx. The number of rows must thus match the length of vector xx. By default, the origin is not redefined and thus, the smallest value in x is usedlength(x)x vector. By default units="days". A special value, units="daystoyears" indicates that x is expressed in "days" (1 unit = 1 day) but that we want to obtain the final regular time sefrequency=12 with units="years" means montly sampled observations. Warning! When using units="daystoyears", specify frequfrequency. If both frequency and deltat are provided, then frequency supersedes deltatunits="daystoyears"). If the x vector contains: 1, 3, 6,... (day #1, day #3, day #6,... of the experiment), one can give here the exact date of the first observadatemin is formated. For instance: "d/m/Y", or m/d/Y" (by default), see daystoyears() for more info on date formattingtol=0, observations in each respective series must match exactly, otherwise observations in the regulated series are interpolated. <"left", "right", "both" (by default) or "none". If tol.type="left", corresponding x values are seeked in a window ]xregul-t"constant", "linear", "spline" or "area" (or a unique abbreviation of them). If several time series are provided (y isrule=1 (by default), these entries are not calculated and get NA; with "constant" regulation method. Coefficient giving more weight to the observation at left (f=0, by default), to the observation at right (f=1), or give an intermediate weight to both of these observat"spline" regulation method. Indicate if the time series should be considered as periodic (periodic=TRUE, first value must be equal to the last one). If this is the case, first and second derivates used to calcul"area" regulation method. Size of the window to consider (see regarea()). By default, the mean interval between observations in the initial irregular time series is used. Give the same value as for deltat for wo"area" method. To optimise calculation time and to avoid to saturate memory, very long time series are splitted into smaller subunits (see regarea()). This is transparent for the user. The default value ofspecs.regul object returned by the function specs() applied to a regul object. Allows to collect parameterization of the regul() function and to apply them to another regulationregul object as obtained after using the regul() functionseries=1, corresponding to the first (or possibly the unique) series in the regul objectplot(): the two colors to use to draw respectively the initial irregular series and the final regulated series. col=c(1,2) by default. (2) for hist(): the three colors to use to represent respectively the fisplot.pts=TRUE (by default) then points are also drawn for the regulated series (+). Those points that match observations in the initial irregular series, and are not interpolated, are further marked with a circleleg=FALSE, no legend is added"initial" for the first one and the name of the regulation method used for the second one (see methods argument)label="#"nclass=30plotit=TRUE then the histogram is plotted. Otherwise, it is only calculatedprint(), summary(), plot(), lines(), identify(), hist(), extract() and specs()."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".regul.screen, regul.adj, tseries, is.tseries, regconst, reglin, regspline, regarea, daystoyearsdata(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)Run the code above in your browser using DataLab