trigseas: Trigonometric seasonal variables

View source: R/util.R

trigseasR Documentation

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)

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.

Value

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

Examples

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

jumps documentation built on April 4, 2025, 2:22 a.m.