statsmodels.tsa.deterministic.CalendarFourier¶
- class statsmodels.tsa.deterministic.CalendarFourier(freq, order)[source]¶
Fourier series deterministic terms based on calendar time
Notes
Both a sine and a cosine term are included for each i=1, …, order
where m is the length of the period and
is the frequency normalized time. For example, when freq is “D” then an observation with a timestamp of 12:00:00 would have .Examples
Here we simulate irregularly spaced hourly data and construct the calendar Fourier terms for the data.
>>> import numpy as np >>> import pandas as pd >>> base = pd.Timestamp("2020-1-1") >>> gen = np.random.default_rng() >>> gaps = np.cumsum(gen.integers(0, 1800, size=1000)) >>> times = [base + pd.Timedelta(gap, unit="s") for gap in gaps] >>> index = pd.DatetimeIndex(pd.to_datetime(times))
>>> from statsmodels.tsa.deterministic import CalendarFourier >>> cal_fourier_gen = CalendarFourier("D", 2) >>> cal_fourier_gen.in_sample(index)
Methods
in_sample
(index)Produce deterministic trends for in-sample fitting.
out_of_sample
(steps, index[, forecast_index])Produce deterministic trends for out-of-sample forecasts
Properties
The frequency of the deterministic terms
Flag indicating whether the values produced are dummy variables
The order of the Fourier terms included
Last update:
Oct 03, 2024