Learn R Programming

pems.utils (version 0.3.0.7)

4.3.time.handlers: pems Data Time Handlers

Description

Time handlers are subset of pems.utils functions that work on or with time records (time.stamp and local.time).

Usage

regularize(data, Hz=1, method=1, ...)

repairLocalTime(data, local.time, ref, ..., reset.count = TRUE, fun.name = "repairLocalTime")

Value

regularize returns the supplied dataset (data) with time-series (time.stamp and local.time) are regularized at the requestion time resolution, based on Hz value. It uses

approx or data binning to estimate associated changes for other data-series.

repairLocalTime returns a repaired local.time

pem.element, typically the supplied local.time with any holes (NAs) it can fill filled.

Arguments

data

(Required, typically pems) The dataset to be worked with. For regularize, the dataset to regularize (see below).

Hz

(For regularize) (Required numeric) The time resolution to regularize the data to in Hertz. So, the default, Hz=1 is one measurement (or row of data) per second.

method

(For regularize) (Required numeric) The regularization method to apply. The default, method=1 uses approx to linearly interpolate regular time-series for all supplied time-series. The alternative method=2 uses a bin-and-average strategy.

...

(Optional) Other arguments, typically passed on.

local.time

(For repairLocalTime) (Required pems.element) The local.time pems.element to work been repaired.

ref, reset.count

(For repairLocalTime) (Other arguments) ref is a second source that local.time can be inferred from in cases where local.time records are missing. If TRUE, reset.count resets local.time so it starts at 0.

fun.name

(character) (pems handler) argument used by pems.utils. These can typically be ignored.

Author

Karl Ropkins

Details

regularize attempts to extrapolate a regular series, generated at the time resolution requested, from the supplied data. Both methods can be used for the regularization of irregularly time-logged data, but differ in their data handling. Method 1 estimates measurements at regular intervals by linearly interpolating between the last valid point and the next valid point in supplied time-series. It therefore hole-fills gaps in time-series and is perhaps best suited for use with sparser data-sets. It can also be used to interolate time-series to higher time-resolutions, but should not be used aggressively, e.g. to convert 1Hz data data to 10Hz. By contrast, method 2 uses data binning to aggregate all supplied measurements (e.g. all measurements between -0.5 and +0.5 seconds of requested times when returning 1 Hz data) and (mean) average these. It is better suited for use with higher resolution time-series (e.g. gong from about 10Hz to 1Hz) and does not hole-fill empty time intervals. If you want mean binning and hole-filling, apply method 2 then method 1, e.g.:

new.data <- regularize(regularize(my.data, method=2), method=1)

repairLocalTime attempts to repair an incomplete local.time record. For example, if you merge two datasets with overlapping but different time ranges, one may not track the time range of the other and this can generate incomplete time records. This function attempts to hole-fill such cases.

References

regularize(..., method=1) uses approx:

Base R Stats package function based on Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

A lot of leg-work testing regularize was done by then Leeds MSc Student Adrian Felipe Ortega Calle.

See Also

approx regarding data regularization methods.