trigonometric_variables | R Documentation |
Computes trigonometric variables at different frequencies.
trigonometric_variables(frequency, start, length, s, seasonal_frequency = NULL)
frequency |
Frequency of the series, number of periods per year (12,4,3,2..) |
start , length |
First date (array with the first year and the first period)
(for instance |
s |
time series used to get the dates for the trading days variables. If supplied the
parameters |
seasonal_frequency |
the seasonal frequencies. By default the fundamental seasonal frequency and all the harmonics are used. |
Denote by P
the value of frequency
(= the period) and
f_1
, ..., f_n
the frequencies provides by seasonal_frequency
(if seasonal_frequency = NULL
then n=\lfloor P/2\rfloor
and f_i
=i).
trigonometric_variables
returns a matrix of size length\times(2n)
.
For each date t
associated to the period m
(m\in[1,P]
),
the columns 2i
and 2i-1
are equal to:
\cos \left(
\frac{2 \pi}{P} \times m \times f_i
\right)
\text{ and }
\sin \left(
\frac{2 \pi}{P} \times m \times f_i
\right)
Take for example the case when the first date (date
) is a January, frequency = 12
(monthly time series), length = 12
and seasonal_frequency = NULL
.
The first frequency, \lambda_1 = 2\pi /12
represents the fundamental seasonal frequency and the
other frequencies (\lambda_2 = 2\pi /12 \times 2
, ..., \lambda_6 = 2\pi /12 \times 6
)
are the five harmonics. The output matrix will be equal to:
\begin{pmatrix}
\cos(\lambda_1) & \sin (\lambda_1) & \cdots &
\cos(\lambda_6) & \sin (\lambda_6) \\
\cos(\lambda_1\times 2) & \sin (\lambda_1\times 2) & \cdots &
\cos(\lambda_6\times 2) & \sin (\lambda_6\times 2)\\
\vdots & \vdots & \cdots & \vdots & \vdots \\
\cos(\lambda_1\times 12) & \sin (\lambda_1\times 12) & \cdots &
\cos(\lambda_6\times 12) & \sin (\lambda_6\times 12)
\end{pmatrix}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.