class_docstr: Inherits time series methods from TSM class.
  
  **** LOCAL LINEAR TREND MODEL ****
  
  Parameters
  ----------
  data : pd.DataFrame or np.array
      Field to specify the time series data that will be used.
  
  integ : int (default : 0)
      Specifies how many time to difference the time series.
  
  target : str (pd.DataFrame) or int (np.array)
      Specifies which column name or array index to use. By default, first
      column/array will be selected as the dependent variable.
class_docstr_tok: ["Inherits","time","series","methods","from","TSM","class",".","*","*","*","*","LOCAL","LINEAR","TREND","MODEL","*","*","*","*","Parameters","--","--","--","--","--","data",":","pd.DataFrame","or","np.array","Field","to","specify","the","time","series","data","that","will","be","used",".","integ",":","int","(","default",":","0",")","Specifies","how","many","time","to","difference","the","time","series",".","target",":","str","(","pd.DataFrame",")","or","int","(","np.array",")","Specifies","which","column","name","or","array","index","to","use",".","By","default",",","first","column\/array","will","be","selected","as","the","dependent","variable","."]
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
  
  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","Returns","--","--","--","--","--","-","pd.DataFrame","with","predictions"]
code: def predict(self, h=5, intervals=False, **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
  
      Returns
      ----------
      - pd.DataFrame with predictions
      """
  
      nsims = kwargs.get("nsims", 200)
  
      if self.latent_variables.estimated is False:
          raise Exception("No latent variables estimated!")
      else:
          # 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
              date_index = self.shift_dates(h)
  
              for i in range(nsims):
                  t_params = self.draw_latent_variables(nsims=1).T[0]
                  a, P = self._forecast_model(t_params, h)
  
                  forecasted_values = a[0][-h:]
                  lower_5 = forecasted_values - 1.96 * np.power(
                      P[0][0][-h:]
                      + self.latent_variables.z_list[0].prior.transform(
                          t_params[0]
                      ),
                      0.5,
                  )
                  upper_95 = forecasted_values + 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 = forecasted_values - 2.575 * np.power(
                      P[0][0][-h:]
                      + self.latent_variables.z_list[0].prior.transform(
                          t_params[0]
                      ),
                      0.5,
                  )
                  upper_99 = forecasted_values + 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:
              # Retrieve data, dates and (transformed) latent variables
              a, P = self._forecast_model(
                  self.latent_variables.get_z_values(), h
              )
              date_index = self.shift_dates(h)
              forecasted_values = a[0][-h:]
  
              if intervals is False:
                  result = pd.DataFrame(forecasted_values)
                  result.rename(
                      columns={0: self.data_name}, inplace=True
                  )
              else:
                  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 ..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 LLT obj's underlying member method code with example usage: obj.predict(h, intervals) and returns: result, result