Learn R Programming

FeedbackTS (version 1.5)

kdd.from.raw.data: Build a KDD object from raw data

Description

Build a KDD (Key Day Dataset) object from a matrix or a data frame containing a time series and other attributes.

Usage

kdd.from.raw.data(raw.data, keyday.threshold, nb.days, col.series, col.date, 
na.rm = TRUE, filter = NULL)

Arguments

raw.data

a data frame or a matrix containing raw data.

keyday.threshold

a numeric providing the threshold value above which a day is considered as a key day (i.e. if the value \(y_i\) of the times series is greater than or equal to keyday.threshold at day \(i\), then day \(i\) is a key day).

nb.days

an integer specifying the number of days considered after and before each key day.

col.series

an integer specifying the number of the column containing the time series.

col.date

an integer vector of size three specifying the numbers of the columns containing the vector of years, the vector of months and the vector of days in numeric format.

na.rm

a logical indicating whether key days \(i\) with missing values in the sub-series \(y_{i-K},\ldots,y_{i+K}\) have to be discarded. If na.rm = TRUE, these key days are discarded (default is TRUE).

filter

a list of lists specifying the filters to carry out over the time series (default is NULL).

Value

an object from the KDD class.

Details

The filter argument is a list of lists, each list having the following arguments:

apply.over:

a character string that must be one of "keyday" or "range", and that indicates whether the filter concerns only the key days or also the range of days considered around the key days (\(K\) days before and \(K\) days after each key day).

column:

an integer specifying the column of raw.data which the filter is applied to.

value:

a value that must be taken by the variable determined by the argument column.

Let \(i\) denote a key day. Let \(z_i\) denote the value, at day \(i\), of the variable determined by the argument column. If apply.over = "keyday" and \(z_i\) = value, then key day \(i\) is kept, otherwise it is discarded. If apply.over = "range" and \(z_j\) = value for all \(j\in\{i-K,\ldots,i+K\}\), then key day \(i\) is kept, otherwise it is discarded.

References

Soubeyrand, S., Morris, C. E. and Bigg, E. K. (2014). Analysis of fragmented time directionality in time series to elucidate feedbacks in climate data. Environmental Modelling and Software 61: 78-86.

See Also

KDD, kdd, rain.site.6008

Examples

Run this code
# NOT RUN {
#### load data for site 6008 (Callagiddy station)
data(rain.site.6008)

#### build KDD objects from raw data (site 6008: Callagiddy station)
## using a threshold value equal to 25
KDD=kdd.from.raw.data(raw.data=rain.site.6008,keyday.threshold=25,nb.days=20,
   col.series=5,col.date=c(2,3,4),na.rm=TRUE,filter=NULL)
summary(KDD)

#### build KDD objects from raw data (site 6008: Callagiddy station)
## using a threshold value equal to 25
## using filters
rain.site.6008b=cbind(rain.site.6008,rain.site.6008[["Year"]]>=1960)
KDD2=kdd.from.raw.data(raw.data=rain.site.6008b,keyday.threshold=25,nb.days=20,
   col.series=5,col.date=c(2,3,4),na.rm=TRUE,
   filter=list(list(apply.over="range",column=6,value=TRUE)))
summary(KDD2)
# }

Run the code above in your browser using DataLab