get.quantiles: Estimate quantiles of a normalized time series

Description Usage Arguments Value Notes on inputted quantiles to be estimated Notes on estimation

View source: R/get_quantiles.R

Description

get.quantiles performs quantile regressions on the time series model.y to estimate the quantiles given by q_bulk and q_tail, after normalizing using q_norm. Specifically,

  1. the quantiles q_norm are estimated on model.y

  2. model.y is normalized, by subtracting the estimated quantile q_norm[2] and dividing by the IQR of estimated quantiles q_norm[3]-q_norm[1]

  3. the quantiles q_bulk are estimated on the normalized model.y

  4. the high tail and low tail are calculated by subtracting the max and min estimated quantile (from 3.) from the normalized model.y

  5. the quantiles q_tail are estimated from the high tail and low tail exceedences (so from exceedence[exceedence>0] for the high and low)

Usage

1
2
3
4
get.quantiles(model.y, norm.x.df, bulk.x.df, tail.x.df, q_norm, q_bulk, q_tail,
  year.range = c(1920, 2099), lat = numeric(), lon = numeric(), bases.dir,
  norm.x = numeric(), bulk.x = numeric(), tail.x = numeric(),
  get.volc = TRUE)

Arguments

model.y

the temperature time series, as either a numeric vector or an xts object. If multiple runs are analyzed, they should be end-to-end (so [run 1 1979-2099, run 2 1979-2099, etc...]). The number of runs is inferred from the length of the time series and the year.range parameter below.

norm.x.df, bulk.x.df, tail.x.df

degrees of freedom for the basis functions, as 3 x 1 vectors giving the dfs for the seasonal cycle, long-term trend, and interaction, respectively

q_norm

a 3 x 1 vector giving the quantiles used to normalize model.y; the estimated q_norm[2] is subtracted from model.y, and the resultant time series is divided by the IQR q_norm[3]-q_norm[1] (i.e. c(0.1,0.5,0.9) - q_norm[2] should probably always be 0.5, and q_norm[c(1,3)] should probably always be symmetric)

q_bulk

a vector giving the non-tail quantiles to be estimated

q_tail

a vector giving the tail quantiles to be estimated - these are calculated with respect to the min and max of q_bulk, so if you set q_tail[1] to 0.75, that 'real' value of that quantile is actually max(q_bulk)+(1-max(q_bulk))*0.75, and so forth.

year.range

manual specification of the year range (as a 2 x 1 vector giving the first and last year of the inputted time series. This is to allow for a general treatment of inputted time series with multiple runs - xts objects are ordered, which is problematic when you have 40 data points for the same date in what should be separate time series).

lat, lon

the latitude/longitude of the pixel. If get.volc=TRUE, lat is used to determine which base function to load. lon (and lat, if get.volc=FALSE) is merely outputted directly into the output list. Can be left empty.

bases.dir

directory where the basis functions are stored. Within the normal file structure, this would be "[defaults$aux.dir],bases/".

norm.x, bulk.x, tail.x

directly input bases (calculated with get.predictors) if desired. Otherwise, the code will first attempt to load them in bases.dir, then recalculate using get.predictors if not found. Can be left empty.

get.volc

if loading or calculating basis functions, sets whether or not to include the volcanic CO2 fit in the normalization basis function (by default FALSE).

Value

A list is returned, with list members giving the fit coefficients for the normalization, bulk/primary, and tail fits (coef_norm, coef_bulk, and coef_tail, respectively), in addition to the inputted q_bulk, q_tail, q_norm, q_all (a listing of all the estimated quantiles), norm.x.df, bulk.x.df, and tail.x.df, and lat, lon, and year.range.

Notes on inputted quantiles to be estimated

q_norm

quantiles used for normalization. model.y is normalized by subtracting the estimated q_norm[2] and dividing by the estimated IQR q_norm[3]-q_norm[1]. We therefore suggest to keep q_norm[2] == 0.5 (the median).

q_bulk

primary, non-tail quantiles to estimate (post-normalization)

q_tail

tail quantiles to estimate; based on exceedences of the post- normalized model.y beyond the max and min estimated q_bulk. Note that q_tail is based on the exceedence, so if you set q_tail[1] to 0.75, that 'real' value of that quantile is actually max(q_bulk)+(1-max(q_bulk))*0.75, and so forth.

Notes on estimation

Quantiles are estimated using quantile regression, with cubic spline basis functions, with degrees of freedom set by norm.x.df, bulk.x.df, and tail.x.df, for the normalization, bulk, and tail exceedence quantile calculations, respectively. The basis functions are either loaded (if they exist in the bases.dir, this requires bases to be calculated using get.predictors), calculated from scratch using get.predictors, or directly inputted using the function parameters norm.x, bulk.x, and tail.x. Loading pre- calculated bases is generally the fastest method.

Each of norm.x.df, bulk.x.df, and tail.x.df is a 3 x 1 vector giving the degrees of freedom for the seasonal cycle (based only on the month-of-year), the long-term change (based only on the year), and the interaction (changing seasonal cycle, based on both month-of-year and year), respectively.


ks905383/quantproj documentation built on Nov. 1, 2020, 9:12 p.m.