class_docstr: Inherits time series methods from TSM parent class.
  
  **** NEURAL NETWORK AUTOREGRESSIVE (NNAR) MODELS ****
  
  Parameters
  ----------
  data : pd.DataFrame or np.ndarray
      Field to specify the univariate time series data that will be used.
  
  ar : int
      Field to specify how many AR lags the model will have.
  
  units : int
      How many units for the neural network
  
  layers : int
      How many layers for the neural networ
  
  activation : function
      E.g. np.tanh, np.array (linear)
  
  family: family object
      E.g. pf.Normal()
class_docstr_tok: ["Inherits","time","series","methods","from","TSM","parent","class",".","*","*","*","*","NEURAL","NETWORK","AUTOREGRESSIVE","(","NNAR",")","MODELS","*","*","*","*","Parameters","--","--","--","--","--","data",":","pd.DataFrame","or","np.ndarray","Field","to","specify","the","univariate","time","series","data","that","will","be","used",".","ar",":","int","Field","to","specify","how","many","AR","lags","the","model","will","have",".","units",":","int","How","many","units","for","the","neural","network","layers",":","int","How","many","layers","for","the","neural","networ","activation",":","function","E.g",".","np.tanh",",","np.array","(","linear",")","family",":","family","object","E.g",".","pf.Normal","(",")"]
code: def __init__(
      self, data, formula, ar, units, layers, family=fam.Normal()
  ):
      # Initialize TSM object
      super(NNARX, self).__init__("NNARX")
  
      # Latent Variable information
      self.ar = ar
      self.units = units
      self.layers = layers
      self.activation = np.tanh
      self.model_name = "NNARX(" + str(self.ar) + ")"
      self.z_no = self.ar + 2
      self.max_lag = self.ar
      self._z_hide = (
          0  # Whether to cutoff latent variables from results table
      )
      self.supported_methods = ["BBVI"]
      self.default_method = "BBVI"
      self.multivariate_model = False
  
      # Format the data
      self.is_pandas = True  # This is compulsory for this model type
      self.data_original = data.copy()
      self.formula = formula
      self.y, self.X = dmatrices(formula, data)
      self.y_name = self.y.design_info.describe()
      self.X_names = self.X.design_info.describe().split(" + ")
      self.y = self.y.astype(np.float)
      self.X = self.X.astype(np.float)
      self.z_no = self.X.shape[1]
      self.data_name = self.y_name
      self.y = np.array([self.y]).ravel()
      self.data = self.y.copy()
      self.X = np.array([self.X])[0]
      self.index = data.index
      self.data_length = self.data.shape[0]
      self.X = self.X[self.ar :, :]
      self.X = np.concatenate([self._ar_matrix().T, self.X], axis=1).T
  
      self._create_latent_variables()
  
      self.family = family
  
      (
          self.model_name2,
          self.link,
          self.scale,
          self.shape,
          self.skewness,
          self.mean_transform,
          self.cythonized,
      ) = self.family.setup()
  
      self.model_name = (
          self.model_name2 + " NNARX(" + str(self.ar) + ")"
      )
  
      # Build any remaining latent variables that are specific to the family chosen
      for no, i in enumerate(self.family.build_latent_variables()):
          self.latent_variables.add_z(i[0], i[1], i[2])
          self.latent_variables.z_list[-1].start = i[3]
  
      self.z_no = len(self.latent_variables.z_list)
      self.family_z_no = len(self.family.build_latent_variables())
  
      # Initialize with random weights
      for var_no in range(
          len(self.latent_variables.z_list) - self.family_z_no
      ):
          self.latent_variables.z_list[
              var_no
          ].start = np.random.normal()
  
      if isinstance(self.family, fam.Normal):
          self.neg_loglik = self.normal_neg_loglik
      else:
          self.neg_loglik = self.general_neg_loglik
  
imports: import sys
  import numpy
  import pandas
  import scipy.stats
  from patsy import dmatrices, dmatrix, demo_data
  from ..None import families
  from ..None import output
  from ..None import tests
  from ..None import tsm
  from ..None import data_check
  from .nn_architecture import neural_network_tanh, neural_network_tanh_mb
label_desc: Use image node_id 1 to create a new NNARX object from inherited base classes: tsm with example: obj = NNARX(data, formula, ar, units, layers, family)