class_docstr: Inherits time series methods from TSM class.
  
  **** DYNAMIC REGRESSION MODEL ****
  
  Parameters
  ----------
  
  formula : string
      patsy string describing the regression
  
  data : pd.DataFrame
      Field to specify the data that will be used
docstr: Makes forecast with the estimated model
  
  Parameters
  ----------
  h : int (default : 5)
      How many steps ahead would you like to forecast?
  
  intervals : boolean (default: False)
      Whether to return prediction intervals
  
  oos_data : pd.DataFrame
      Data for the variables to be used out of sample (ys can be NaNs)
  
  Returns
  ----------
  - pd.DataFrame with predictions
docstr_tok: ["Makes","forecast","with","the","estimated","model","Parameters","--","--","--","--","--","h",":","int","(","default",":","5",")","How","many","steps","ahead","would","you","like","to","forecast","?","intervals",":","boolean","(","default",":","False",")","Whether","to","return","prediction","intervals","oos_data",":","pd.DataFrame","Data","for","the","variables","to","be","used","out","of","sample","(","ys","can","be","NaNs",")","Returns","--","--","--","--","--","-","pd.DataFrame","with","predictions"]
code: def predict(self, h=5, intervals=False, oos_data=None, **kwargs):
      """Makes forecast with the estimated model
  
      Parameters
      ----------
      h : int (default : 5)
          How many steps ahead would you like to forecast?
  
      intervals : boolean (default: False)
          Whether to return prediction intervals
  
      oos_data : pd.DataFrame
          Data for the variables to be used out of sample (ys can be NaNs)
  
      Returns
      ----------
      - pd.DataFrame with predictions
      """
  
      nsims = kwargs.get("nsims", 200)
  
      if self.latent_variables.estimated is False:
          raise Exception("No latent variables estimated!")
      else:
          _, X_oos = dmatrices(self.formula, oos_data)
          X_oos = np.array([X_oos])[0]
          full_X = self.X.copy()
          full_X = np.append(full_X, X_oos, axis=0)
          Z = full_X
          date_index = self.shift_dates(h)
  
          # Retrieve data, dates and (transformed) latent variables
          if self.latent_variables.estimation_method in ["M-H"]:
              lower_1_final = 0
              upper_99_final = 0
              lower_5_final = 0
              upper_95_final = 0
              forecasted_values_final = 0
  
              for i in range(nsims):
                  t_params = self.draw_latent_variables(nsims=1).T[0]
                  a, P = self._forecast_model(t_params, Z, h)
  
                  smoothed_series = np.zeros(h)
                  series_variance = np.zeros(h)
  
                  for t in range(h):
                      smoothed_series[t] = np.dot(
                          Z[self.y.shape[0] + t],
                          a[:, self.y.shape[0] + t],
                      )
                      series_variance[t] = np.dot(
                          np.dot(
                              Z[self.y.shape[0] + t],
                              P[:, :, self.y.shape[0] + t],
                          ),
                          Z[self.y.shape[0] + t].T,
                      )
  
                  forecasted_values = smoothed_series
                  lower_5 = smoothed_series - 1.96 * np.power(
                      P[0][0][-h:]
                      + self.latent_variables.z_list[0].prior.transform(
                          t_params[0]
                      ),
                      0.5,
                  )
                  upper_95 = smoothed_series + 1.96 * np.power(
                      P[0][0][-h:]
                      + self.latent_variables.z_list[0].prior.transform(
                          t_params[0]
                      ),
                      0.5,
                  )
                  lower_5_final += lower_5
                  upper_95_final += upper_95
                  lower_1 = smoothed_series - 2.575 * np.power(
                      P[0][0][-h:]
                      + self.latent_variables.z_list[0].prior.transform(
                          t_params[0]
                      ),
                      0.5,
                  )
                  upper_99 = smoothed_series + 2.575 * np.power(
                      P[0][0][-h:]
                      + self.latent_variables.z_list[0].prior.transform(
                          t_params[0]
                      ),
                      0.5,
                  )
                  lower_1_final += lower_1
                  upper_99_final += upper_99
                  forecasted_values_final += forecasted_values
  
              forecasted_values_final = forecasted_values_final / nsims
              lower_1_final = lower_1_final / nsims
              lower_5_final = lower_5_final / nsims
              upper_95_final = upper_95_final / nsims
              upper_99_final = upper_99_final / nsims
  
              if intervals is False:
                  result = pd.DataFrame(forecasted_values_final)
                  result.rename(
                      columns={0: self.data_name}, inplace=True
                  )
              else:
                  prediction_05 = lower_5_final
                  prediction_95 = upper_95_final
                  prediction_01 = lower_1_final
                  prediction_99 = upper_99_final
  
                  result = pd.DataFrame(
                      [
                          forecasted_values_final,
                          prediction_01,
                          prediction_05,
                          prediction_95,
                          prediction_99,
                      ]
                  ).T
                  result.rename(
                      columns={
                          0: self.data_name,
                          1: "1% Prediction Interval",
                          2: "5% Prediction Interval",
                          3: "95% Prediction Interval",
                          4: "99% Prediction Interval",
                      },
                      inplace=True,
                  )
  
              result.index = date_index[-h:]
  
              return result
  
          else:
              t_params = self.latent_variables.get_z_values()
              a, P = self._forecast_model(t_params, Z, h)
              smoothed_series = np.zeros(h)
  
              for t in range(h):
                  smoothed_series[t] = np.dot(
                      Z[self.y.shape[0] + t], a[:, self.y.shape[0] + t]
                  )
  
              # Retrieve data, dates and (transformed) latent variables
              forecasted_values = smoothed_series
  
              if intervals is False:
                  result = pd.DataFrame(forecasted_values)
                  result.rename(
                      columns={0: self.data_name}, inplace=True
                  )
              else:
                  series_variance = np.zeros(h)
  
                  for t in range(h):
                      series_variance[t] = np.dot(
                          np.dot(
                              Z[self.y.shape[0] + t],
                              P[:, :, self.y.shape[0] + t],
                          ),
                          Z[self.y.shape[0] + t].T,
                      )
  
                  prediction_05 = forecasted_values - 1.96 * np.power(
                      P[0][0][-h:]
                      + self.latent_variables.z_list[0].prior.transform(
                          self.latent_variables.get_z_values()[0]
                      ),
                      0.5,
                  )
                  prediction_95 = forecasted_values + 1.96 * np.power(
                      P[0][0][-h:]
                      + self.latent_variables.z_list[0].prior.transform(
                          self.latent_variables.get_z_values()[0]
                      ),
                      0.5,
                  )
                  prediction_01 = forecasted_values - 2.575 * np.power(
                      P[0][0][-h:]
                      + self.latent_variables.z_list[0].prior.transform(
                          self.latent_variables.get_z_values()[0]
                      ),
                      0.5,
                  )
                  prediction_99 = forecasted_values + 2.575 * np.power(
                      P[0][0][-h:]
                      + self.latent_variables.z_list[0].prior.transform(
                          self.latent_variables.get_z_values()[0]
                      ),
                      0.5,
                  )
  
                  result = pd.DataFrame(
                      [
                          forecasted_values,
                          prediction_01,
                          prediction_05,
                          prediction_95,
                          prediction_99,
                      ]
                  ).T
                  result.rename(
                      columns={
                          0: self.data_name,
                          1: "1% Prediction Interval",
                          2: "5% Prediction Interval",
                          3: "95% Prediction Interval",
                          4: "99% Prediction Interval",
                      },
                      inplace=True,
                  )
  
              result.index = date_index[-h:]
  
              return result
  
imports: import copy
  import sys
  import numpy
  import pandas
  import scipy.stats
  from patsy import dmatrices, dmatrix, demo_data
  from ..None import families
  from ..None import tsm
  from ..None import data_check
  from .kalman import *
label_desc: Use image node_id 10 for calling the DynReg obj's underlying member method code with example usage: obj.predict(h, intervals, oos_data) and returns: result, result