trigseas | R Documentation |
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.
trigseas(n, s, harmonics = NULL)
n |
length of time series; |
s |
seasonal period; |
harmonics |
vector of harmonics to be used: the cosine and sine
functions are computed at frequencies |
It returns a matrix with n rows and so many columns
as the harmonics (by default these are s-1
).
y <- log(AirPassengers)
X <- trigseas(length(y), 12)
X <- cbind(X, t = 1:length(y))
reg <- lm(y~X)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.