You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there,
I am currently using statsforecast with statsmodels Calendar Fourier class to include fourier terms as exogenous regressors. Am I able to create a new class as a child class of AutoARIMA where these terms might be included natively. I have tried by implementing the following class but it fails as y is a numpy array and doesn't have an index.
class AutoARIMADHR(AutoARIMA):
def __init__(self, freq='D', monthly_k=0, annual_k=0, *args, **kwargs):
super().__init__(*args, **kwargs)
self.freq = freq
self.monthly_k = monthly_k
self.annual_k = annual_k
self.fourier_terms = None
def fit(self, y, X=None):
# Generate Fourier terms
monthly_fourier = CalendarFourier(freq='MS', order=self.monthly_k)
annual_fourier = CalendarFourier(freq='YS', order=self.annual_k)
# Adjust frequency and order as needed
dp = DeterministicProcess(index=y.index, constant=True, order=1, seasonal=False, additional_terms=[monthly_fourier, annual_fourier])
self.fourier_terms = dp.in_sample()
# Combine original features with Fourier terms
if X is not None:
X = pd.concat([X, self.fourier_terms], axis=1)
else:
X = self.fourier_terms
return super().fit(y, X)
def predict(self, h, X=None):
# Generate future Fourier terms
future_fourier_terms = self.fourier_terms.iloc[-len(h):]
# Combine original features with future Fourier terms
if X is not None:
X = pd.concat([X, future_fourier_terms], axis=1)
else:
X = future_fourier_terms
return super().predict(h, X)
Is this possible? I want to be able to just call the StatsForecast.forecast method and compare multiples of these models simultaneously.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi there,
I am currently using statsforecast with statsmodels Calendar Fourier class to include fourier terms as exogenous regressors. Am I able to create a new class as a child class of AutoARIMA where these terms might be included natively. I have tried by implementing the following class but it fails as y is a numpy array and doesn't have an index.
class AutoARIMADHR(AutoARIMA):
Is this possible? I want to be able to just call the StatsForecast.forecast method and compare multiples of these models simultaneously.
Beta Was this translation helpful? Give feedback.
All reactions