Build a design matrix for polynomial regression.

polynomX(date, degree = 2, origin = NULL)

Arguments

date

A vector with class "Date" or that can be coerced to this class.

degree

The maximal degree \(d\). The basis contains \(d + 1\) functions \(t^0\), \(t^1\), ..., \(t^d\).

origin

Optional vector of length 1 with class "Date" or character that can be coerced to this class. Gives the origin for the transformation of dates into numeric values. The default value is 1970-01-01, see Date.

Value

An object with class "bts" inheriting from "matrix". This is essentially a numeric matrix having the value of the basis functions as its columns. Each row corresponds to an element of the given date vector. By convention, the columns are named Cst then t1, t2, ....

Details

The provided date is converted into a numeric variable \(t\) corresponding to the number of years from the origin. The basis functions are functions of this variable \(t\). A year is defined as 365.25 days, so \(t\) can not take only integer values.

Note

This function is intended to provide regressors for Time Varying GEV models corresponding to TVGEV objects. Since the response then usually corresponds to block maxima, the date variable gives either the begining or the end of each block.

Caution

As a general rule, it is a good practice to choose origin close to the centre of the time period. This is especially important when a polynomial of degree \(>= 2\) is used since problems of convergence are likely to occur otherwise.

See also

breaksX for a basis of Truncated Power functions. and TVGEV to for Time Varying GEV models.

Examples


date <- seq(from = as.Date("1996-01-01"),
            to = as.Date("2016-12-31"), by = "years")

X <- polynomX(date)
plot(X)