statsmodels.tsa.deterministic.CalendarFourier¶
-
class
statsmodels.tsa.deterministic.
CalendarFourier
(freq: str, order: int)[source]¶ Fourier series deterministic terms based on calendar time
- Parameters
Notes
Both a sine and a cosine term are included for each i=1, …, order
fi,s,t=sin(2πiτt)fi,c,t=cos(2πiτt)where m is the length of the period and τt is the frequency normalized time. For example, when freq is “D” then an observation with a timestamp of 12:00:00 would have τt=0.5.
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)
- Attributes
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
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