Skip to contents

Create designs for time series regression (linear regression or quantile regression) for meteorological time series.

Usage

tsDesign(
  dt,
  type = c("polynom", "trigo", "sinwave"),
  df = 3,
  period = "year",
  phi = NULL,
  keepTrig = FALSE,
  origin = NULL
)

Arguments

dt

A POSIXct or Date object.

type

Type of design.

df

Number of basis functions, or "degree of freedom".

period

Not used. Can only be one year and is used only in the trigonometric case.

phi

Numeric vector of phases used only when type is "sinwave".

keepTrig

Logical. Used only when type is "sinwave". If TRUE the base trigonometric functions sinj1, sinj2, ..., cosj1, cosj2, ... are kept in the result, along with the functions sinjPhi1, sinjPhi2, ...

origin

An origin for the time. Used only in the polynomial case. The same value must be used in fits and predictions.

Value

A list with an element named X containing the matrix.

Details

The choice is for now between polynomial functions that can be used to describe a trend) and trigonometric functions with period one year (365.25 days) that can be used for the seasonality.

  • "polynom" Can be used to describe a polynomial with degree <= df - 1. The df basis functions are named "Cst", then: "t1", "t2", ...

  • "trigo" The basis contains df = 2 * K + 1 trigonometric functions given in the order of increasing harmonics. These are: the constant function "Cst" and then the K couples of one cosine function and one sine function, with names "cosj1", "sinj1", "cosj2", "sinj2", ...

  • "sinwave" With K = df %/% 2, the K + 1 basis functions are the constant "Cst", then K sine wave functions in the order of increasing harmonics with names "sinjPhi1", "sinjPhi2", ...

Note

For both designs "trigo" and "sinwave", df must be taken as an odd integer, in order to allow the use of an arbitrary phase for each of the harmonics. Mind that the corresponding bases are (nearly) orthogonal only when full years are used.