Home>

Please tell me how to input sarimax exogenous variables.
I keep copying various sutras, but it doesn't work.
Can anyone give me some advice or the correct code?

sarima_model2 = sm.tsa.SARIMAX (data ['test'], exog = data ['formula'], order = (0,0,1), seasonal_order = (2,1,0,12)). fit ()
predict2 = sarima_model2.predict ('2020-04-01', '2021-04-01', exog = data ['formula'])


The error code that is occurring is

ValueError Traceback (most recent call last)
<ipython-input-34-9f246332e100>in<module>()
      1 fig = plt.figure (figsize = (12,4))
---->2 predict2 = sarima_model2.predict ('2020-04-01', '2021-04-01', exog = row_data ['formula'])
~ \ AppData \ Local \ Continuum \ anaconda3 \ lib \ site-packages \ statsmodels \ base \ wrapper.py in wrapper (self, * args, ** kwargs)
     93 obj = data.wrap_output (func (results, * args, ** kwargs), how [0], how [1:])
     94 elif how:
--->95 obj = data.wrap_output (func (results, * args, ** kwargs), how)
     96 return obj
     97
~ \ AppData \ Local \ Continuum \ anaconda3 \ lib \ site-packages \ statsmodels \ tsa \ statespace \ mlemodel.py in predict (self, start, end, dynamic, ** kwargs)
   2432 "" "
   2433 # Perform the prediction
->2434 prediction_results = self.get_prediction (start, end, dynamic, ** kwargs)
   2435 return prediction_results.predicted_mean
   2436
~ \ AppData \ Local \ Continuum \ anaconda3 \ lib \ site-packages \ statsmodels \ tsa \ statespace \ sarimax.py in get_prediction (self, start, end, dynamic, index, exog, ** kwargs)
   1944'appropriate shape. Required% s, got% s.'
   1945% (str (required_exog_shape),
->1946 str (exog.shape)))
   1947 exog = np.c_ [self.model.data.orig_exog.T, exog.T] .T
   1948
ValueError: Provided exogenous values ​​are not of the appropriate shape. Required (7, 1), got (37,).
<Figure size 864x288 with 0 Axes>