| fourier_vars | R Documentation |
Constructs sine and cosine regressors to capture seasonal variation at intrayearly and intramonthly frequencies in weekly time series. The Fourier terms are defined using the day-of-year and day-of-month corresponding to each observation date, allowing the seasonal frequencies to adapt to varying month and year lengths.
fourier_vars(k = 1, l = 1, dates)
k |
Integer. Number of yearly-cycle Fourier harmonics (pairs of sine and cosine terms) to include. |
l |
Integer. Number of monthly-cycle Fourier harmonics (pairs of sine and cosine terms) to include. |
dates |
A vector of class |
A numeric matrix with length(dates) rows and 2 * (k + l)
columns containing the Fourier regressors. Columns are ordered with yearly
terms first, followed by monthly terms. If both k = 0 and l = 0,
NULL is returned.
# create a vector of dates
dates=seq.Date(from=as.Date("2023-01-02"),by="weeks",length.out = 100)
# Create a matrix with 20 yearly and 6 monthly pairs of sine and cosine variables
X=fourier_vars(k=20,l=6,dates=dates)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.