docstr: VARIMA
  
  Parameters
  ----------
  p : int
      Order (number of time lags) of the autoregressive model (AR)
  d : int
      The order of differentiation; i.e., the number of times the data
      have had past values subtracted. (I) Note that Darts only supports d <= 1 because for
      d > 1 the optimizer often does not result in stable predictions. If results are not stable
      for d = 1 try to set d = 0 and enable the trend parameter
      to account for possible non-stationarity.
  q : int
      The size of the moving average window (MA).
  trend: str
      Parameter controlling the deterministic trend. 'n' indicates no trend,
      'c' a constant term, 't' linear trend in time, and 'ct' includes both.
      Default is 'c' for models without integration, and no trend for models with integration.
  add_encoders
      A large number of future covariates can be automatically generated with `add_encoders`.
      This can be done by adding multiple pre-defined index encoders and/or custom user-made functions that
      will be used as index encoders. Additionally, a transformer such as Darts' :class:`Scaler` can be added to
      transform the generated covariates. This happens all under one hood and only needs to be specified at
      model creation.
      Read :meth:`SequentialEncoder <darts.dataprocessing.encoders.SequentialEncoder>` to find out more about
      ``add_encoders``. Default: ``None``. An example showing some of ``add_encoders`` features:
  
      .. highlight:: python
      .. code-block:: python
  
          def encode_year(idx):
              return (idx.year - 1950) / 50
  
          add_encoders={
              'cyclic': {'future': ['month']},
              'datetime_attribute': {'future': ['hour', 'dayofweek']},
              'position': {'future': ['relative']},
              'custom': {'future': [encode_year]},
              'transformer': Scaler(),
              'tz': 'CET'
          }
      ..
  
  Examples
  --------
  >>> from darts.datasets import ETTh2Dataset
  >>> from darts.models import VARIMA
  >>> from darts.utils.timeseries_generation import holidays_timeseries
  >>> # forecasting the High UseFul Load ("HUFL") and Oil Temperature ("OT")
  >>> series = ETTh2Dataset().load()[:500][["HUFL", "OT"]]
  >>> # optionally, use some future covariates; e.g. encode each timestep whether it is on a holiday
  >>> future_cov = holidays_timeseries(series.time_index, "CN", add_length=6)
  >>> # no clear trend in the dataset
  >>> model = VARIMA(trend="n")
  >>> model.fit(series, future_covariates=future_cov)
  >>> pred = model.predict(6, future_covariates=future_cov)
  >>> # the two targets are predicted together
  >>> pred.values()
  array([[48.11846185, 47.94272629],
         [49.85314633, 47.97713346],
         [51.16145791, 47.99804203],
         [52.14674087, 48.00872598],
         [52.88729152, 48.01166578],
         [53.44242919, 48.00874069]])
docstr_tok: ["VARIMA","Parameters","--","--","--","--","--","p",":","int","Order","(","number","of","time","lags",")","of","the","autoregressive","model","(","AR",")","d",":","int","The","order","of","differentiation",";","i.e.",",","the","number","of","times","the","data","have","had","past","values","subtracted",".","(","I",")","Note","that","Darts","only","supports","d","<","=","1","because","for","d",">","1","the","optimizer","often","does","not","result","in","stable","predictions",".","If","results","are","not","stable","for","d","=","1","try","to","set","d","=","0","and","enable","the","trend","parameter","to","account","for","possible","non-stationarity",".","q",":","int","The","size","of","the","moving","average","window","(","MA",")",".","trend",":","str","Parameter","controlling","the","deterministic","trend",".","'n","'","indicates","no","trend",",","'","c","'","a","constant","term",",","'t","'","linear","trend","in","time",",","and","'ct","'","includes","both",".","Default","is","'","c","'","for","models","without","integration",",","and","no","trend","for","models","with","integration",".","add_encoders","A","large","number","of","future","covariates","can","be","automatically","generated","with","`","add_encoders","`",".","This","can","be","done","by","adding","multiple","pre-defined","index","encoders","and\/or","custom","user-made","functions","that","will","be","used","as","index","encoders",".","Additionally",",","a","transformer","such","as","Darts","'",":","class",":","`","Scaler","`","can","be","added","to","transform","the","generated","covariates",".","This","happens","all","under","one","hood","and","only","needs","to","be","specified","at","model","creation",".","Read",":","meth",":","`","SequentialEncoder","<","darts.dataprocessing.encoders.SequentialEncoder",">","`","to","find","out","more","about","``","add_encoders","``",".","Default",":","``","None","``",".","An","example","showing","some","of","``","add_encoders","``","features",":","..","highlight",":",":","python","..","code-block",":",":","python","def","encode_year","(","idx",")",":","return","(","idx.year","-","1950",")","\/","50","add_encoders=","{","'cyclic","'",":","{","'future","'",":","[","'month","'","]","}",",","'datetime_attribute","'",":","{","'future","'",":","[","'hour","'",",","'dayofweek","'","]","}",",","'position","'",":","{","'future","'",":","[","'relative","'","]","}",",","'custom","'",":","{","'future","'",":","[","encode_year","]","}",",","'transformer","'",":","Scaler","(",")",",","'tz","'",":","'CET'","}","..","Examples","--","--","--","--",">",">",">","from","darts.datasets","import","ETTh2Dataset",">",">",">","from","darts.models","import","VARIMA",">",">",">","from","darts.utils.timeseries_generation","import","holidays_timeseries",">",">",">","#","forecasting","the","High","UseFul","Load","(","``","HUFL","''",")","and","Oil","Temperature","(","``","OT","''",")",">",">",">","series","=","ETTh2Dataset","(",")",".load","(",")","[",":500","]","[","[","``","HUFL","''",",","``","OT","''","]","]",">",">",">","#","optionally",",","use","some","future","covariates",";","e.g",".","encode","each","timestep","whether","it","is","on","a","holiday",">",">",">","future_cov","=","holidays_timeseries","(","series.time_index",",","``","CN","''",",","add_length=6",")",">",">",">","#","no","clear","trend","in","the","dataset",">",">",">","model","=","VARIMA","(","trend=","''","n","''",")",">",">",">","model.fit","(","series",",","future_covariates=future_cov",")",">",">",">","pred","=","model.predict","(","6",",","future_covariates=future_cov",")",">",">",">","#","the","two","targets","are","predicted","together",">",">",">","pred.values","(",")","array","(","[","[","48.11846185",",","47.94272629","]",",","[","49.85314633",",","47.97713346","]",",","[","51.16145791",",","47.99804203","]",",","[","52.14674087",",","48.00872598","]",",","[","52.88729152",",","48.01166578","]",",","[","53.44242919",",","48.00874069","]","]",")"]
code: def __init__(
      self,
      p: int = 1,
      d: int = 0,
      q: int = 0,
      trend: Optional[str] = None,
      add_encoders: Optional[dict] = None,
  ):
      """VARIMA
  
      Parameters
      ----------
      p : int
          Order (number of time lags) of the autoregressive model (AR)
      d : int
          The order of differentiation; i.e., the number of times the data
          have had past values subtracted. (I) Note that Darts only supports d <= 1 because for
          d > 1 the optimizer often does not result in stable predictions. If results are not stable
          for d = 1 try to set d = 0 and enable the trend parameter
          to account for possible non-stationarity.
      q : int
          The size of the moving average window (MA).
      trend: str
          Parameter controlling the deterministic trend. 'n' indicates no trend,
          'c' a constant term, 't' linear trend in time, and 'ct' includes both.
          Default is 'c' for models without integration, and no trend for models with integration.
      add_encoders
          A large number of future covariates can be automatically generated with `add_encoders`.
          This can be done by adding multiple pre-defined index encoders and/or custom user-made functions that
          will be used as index encoders. Additionally, a transformer such as Darts' :class:`Scaler` can be added to
          transform the generated covariates. This happens all under one hood and only needs to be specified at
          model creation.
          Read :meth:`SequentialEncoder <darts.dataprocessing.encoders.SequentialEncoder>` to find out more about
          ``add_encoders``. Default: ``None``. An example showing some of ``add_encoders`` features:
  
          .. highlight:: python
          .. code-block:: python
  
              def encode_year(idx):
                  return (idx.year - 1950) / 50
  
              add_encoders={
                  'cyclic': {'future': ['month']},
                  'datetime_attribute': {'future': ['hour', 'dayofweek']},
                  'position': {'future': ['relative']},
                  'custom': {'future': [encode_year]},
                  'transformer': Scaler(),
                  'tz': 'CET'
              }
          ..
  
      Examples
      --------
      >>> from darts.datasets import ETTh2Dataset
      >>> from darts.models import VARIMA
      >>> from darts.utils.timeseries_generation import holidays_timeseries
      >>> # forecasting the High UseFul Load ("HUFL") and Oil Temperature ("OT")
      >>> series = ETTh2Dataset().load()[:500][["HUFL", "OT"]]
      >>> # optionally, use some future covariates; e.g. encode each timestep whether it is on a holiday
      >>> future_cov = holidays_timeseries(series.time_index, "CN", add_length=6)
      >>> # no clear trend in the dataset
      >>> model = VARIMA(trend="n")
      >>> model.fit(series, future_covariates=future_cov)
      >>> pred = model.predict(6, future_covariates=future_cov)
      >>> # the two targets are predicted together
      >>> pred.values()
      array([[48.11846185, 47.94272629],
             [49.85314633, 47.97713346],
             [51.16145791, 47.99804203],
             [52.14674087, 48.00872598],
             [52.88729152, 48.01166578],
             [53.44242919, 48.00874069]])
      """
      super().__init__(add_encoders=add_encoders)
      self.p = p
      self.d = d
      self.q = q
      self.trend = trend
      self.model = None
  
      assert d <= 1, "d > 1 not supported."
  
file_path: darts/darts/models/forecasting/varima.py
imports: from typing import Optional
  import numpy
  import pandas
  from statsmodels.tsa.api import VARMAX
  from darts.logging import get_logger, raise_if
  from darts.models.forecasting.forecasting_model import TransferableFutureCovariatesLocalForecastingModel
  from darts.timeseries import TimeSeries
label_desc: Use image node_id 1 to create a new VARIMA object from inherited base classes: TransferableFutureCovariatesLocalForecastingModel with example: obj = VARIMA(p, d, q, trend, add_encoders)