get.reference.values: Get Reference Values for Aggregation Periods

Description Usage Arguments Details Value See Also Examples

View source: R/get.reference.values.R

Description

Function to get the reference values for aggregation periods

Usage

1
2
3
get.reference.values(date, ref.data, agg.length, agg.fun = "sum",
  ref.years = NULL, ref.length = 30, agg.na.thres = 10,
  agg.interpolation = c("none", "linear", "mean", "zeros"))

Arguments

date

date for which the reference values from other years are determined

ref.data

an xts object containing daily reference data

agg.length

length of the aggregation period in days

agg.fun

function on x to apply to the aggregation data, default is 'sum'

ref.years

years to be used as reference period, default (NULL) is to use all years in ref.data. If ref.years is set to NA, ref.length is used to determine the reference period.

ref.length

if ref.years is null, the ref.length number of years (default = 30) preceding (but not including) the index.out timestamp are used as reference period

agg.na.thres

threshold for the percentage of na values allowed in the aggregation period data, default = 10

agg.interpolation

interpolation type for missing values in individual aggregation period data before applying agg.fun: 'none' (default, NA's are removed), 'linear', 'mean', or 'zeros'

Details

This function determines the dates in each of the aggregation periods for standardized index calculation, extracts the corresponding data from ref.data and applies an aggregation function to the data of each individual aggregation period (default is 'sum', but any function on x can be passed). Reference periods are set by using the ref.years argument to pass specific years to be used as reference period (e.g. for 1981 to 2010, pass seq(1981,2010)). When ref.years is set to NULL, all possible years in ref.data are used. Alternatively, ref.years can be set to NA, in which case ref.length (default = 30) will determine the length of the reference period preceding, but not including, the date for which the reference values are being determined. Warnings will be generated when the requested reference period falls outside ref.data, or when expected aggregation period dates are not present in ref.data.

Value

A named vector with reference period data.

See Also

standardized.index, codefit.distribution

Examples

1
2
3
4
5
6
7
8
data(Ukkel_RR)
date <- as.Date('2018-07-01')
# get all reference values for the 30 day-period preceding date
get.reference.values(date = date, ref.data = Ukkel_RR, agg.length=30)
# get 1981-2010 reference values for the 30 day-period preceding date
get.reference.values(date = date, ref.data = Ukkel_RR, agg.length=30, ref.years=seq(1981,2010))
# get the previos 30 years' reference values for the 30 day-period preceding date
get.reference.values(date = date, ref.data = Ukkel_RR, agg.length=30, ref.years=NA, ref.length=30)

WillemMaetens/standaRdized documentation built on May 21, 2019, 10:29 a.m.