Learn R Programming

jumps (version 1.0)

trigseas: Trigonometric seasonal variables

Description

It produces a matrix with seasonal sinusoids to be used as regressors. By default, for \(t=1,\ldots,n\) and \(j = 1, \ldots, \lfloor s/2\rfloor\), it computes $$\cos(2\pi j/s), \qquad \sin(2\pi j/s)$$. Notice that if $s$ is even the sine function at highest frequency is omitted because it equals zero for all $t$. The used can select a different set of harmonics.

Usage

trigseas(n, s, harmonics = NULL)

Value

It returns a matrix with n rows and so many columns as the harmonics (by default these are \(s-1\)).

Arguments

n

length of time series;

s

seasonal period;

harmonics

vector of harmonics to be used: the cosine and sine functions are computed at frequencies 2*pi*harmonics/s, if there is an element of harmonics for which 2*pi*harmonics/s is equal to \(\pi\) the corresponding sine is omitted.

Examples

Run this code
y <- log(AirPassengers)
X <- trigseas(length(y), 12)
X <- cbind(X, t = 1:length(y))
reg <- lm(y~X)

Run the code above in your browser using DataLab