title: Getting "ValueError: Insufficient degrees of freedom to estimate" when trying to use ARIMA to predict energy consumption
body: <p>I'm trying to predict energy consumption using ARIMA model to benchmark and compare accuracy for deep learning. I get the "ValueError Insufficient degrees of freedom to estimate" when trying to run my code in Google's Colab.</p>
  
  <p>I tried different P, D, Q values, but quite honestly I don't fully understand how they should be chosen.</p>
  
  <p>Sorry for messy code - this is what I'm running block by block in Colab.</p>
  
  <p>Also, excluded the GDrive auth process in the beginning.</p>
  
  <pre><code># Get the csv file from Drive
  import pandas as pd
  downloaded = drive.CreateFile({'id':id}) 
  downloaded.GetContentFile('11124.csv')  
  df = pd.read_csv('11124.csv', sep = ';', index_col = 1)
  df = df.drop(['building'], axis = 1)
  df.index = pd.to_datetime(df.index)
  df.dtypes
  df = df[(df.T != 0).any()]
  import matplotlib as plt
  df.plot()
  df.shape
  from matplotlib import pyplot
  from statsmodels.tsa.arima_model import ARIMA
  #Function that calls ARIMA model to fit and forecast the data
  def StartARIMAForecasting(Actual, P, D, Q):
      model = ARIMA(Actual, order=(P, D, Q))
      model_fit = model.fit(disp=0)
      prediction = model_fit.forecast()[0]
      return prediction
  #Get exchange rates
  ActualData = df
  #Size of exchange rates
  NumberOfElements = len(ActualData)
  #Use 70% of data as training, rest 30% to Test model
  TrainingSize = int(NumberOfElements * 0.7)
  TrainingData = ActualData[0:TrainingSize]
  TestData = ActualData[TrainingSize:NumberOfElements]
  #New arrays to store actual and predictions
  Actual = [x for x in TrainingData]
  Predictions = list()
  #In a for loop, predict values using ARIMA model
  for timepoint in range(len(TestData)):
      ActualValue =  TestData.iloc[timepoint]
      #forcast value
      Prediction = StartARIMAForecasting(Actual,3,1,0)    
      print('Actual=%f, Predicted=%f' % (ActualValue, Prediction))
      #add it in the list
      Predictions.append(Prediction)
      Actual.append(ActualValue)
  </code></pre>
  
  <hr>
  
  <pre><code>ValueError                                Traceback (most recent call 
  last)
  &lt;ipython-input-133-8cddd294ae3f&gt; in &lt;module&gt;()
    2         ActualValue =  TestData.iloc[timepoint]
    3         #forcast value
  ----&gt; 4         Prediction = StartARIMAForecasting(Actual,3,1,0)
    5         print('Actual=%f, Predicted=%f' % (ActualValue, Prediction))
    6         #add it in the list
  
  &lt;ipython-input-122-b2acac5bc03e&gt; in StartARIMAForecasting(Actual, P, D, 
  Q)
    1 def StartARIMAForecasting(Actual, P, D, Q):
  ----&gt; 2         model = ARIMA(Actual, order=(P, D, Q))
    3         model_fit = model.fit(disp=0)
    4         prediction = model_fit.forecast()[0]
    5         return prediction
  
  /usr/local/lib/python3.6/dist-packages/statsmodels/tsa/arima_model.py in     
  __new__(cls, endog, order, exog, dates, freq, missing)
  998         else:
  999             mod = super(ARIMA, cls).__new__(cls)
  -&gt; 1000             mod.__init__(endog, order, exog, dates, freq, 
  missing)
  1001             return mod
  1002 
  
  /usr/local/lib/python3.6/dist-packages/statsmodels/tsa/arima_model.py in 
  __init__(self, endog, order, exog, dates, freq, missing)
  1013             # in the predict method
  1014             raise ValueError("d &gt; 2 is not supported")
  -&gt; 1015         super(ARIMA, self).__init__(endog, (p, q), exog, dates, 
  freq, missing)
  1016         self.k_diff = d
  1017         self._first_unintegrate = unintegrate_levels(self.endog[:d], 
  d)
  
  /usr/local/lib/python3.6/dist-packages/statsmodels/tsa/arima_model.py in 
  __init__(self, endog, order, exog, dates, freq, missing)
  452         super(ARMA, self).__init__(endog, exog, dates, freq, 
  missing=missing)
  453         exog = self.data.exog  # get it after it's gone through 
  processing
  --&gt; 454         _check_estimable(len(self.endog), sum(order))
  455         self.k_ar = k_ar = order[0]
  456         self.k_ma = k_ma = order[1]
  
  /usr/local/lib/python3.6/dist-packages/statsmodels/tsa/arima_model.py in 
  _check_estimable(nobs, n_params)
  438 def _check_estimable(nobs, n_params):
  439     if nobs &lt;= n_params:
  --&gt; 440         raise ValueError("Insufficient degrees of freedom to 
  estimate")
  441 
  442 
  ValueError: Insufficient degrees of freedom to estimate
  </code></pre>