def _sim_prediction_bayes(self, h, simulations):
        """ Simulates a h-step ahead mean prediction

        Same as _mean_prediction() but now we repeat the process 
        by a number of times (simulations) and shock the process
        with random draws from the family, e.g. Normal shocks.

        Parameters
        ----------
        h : int
            How many steps ahead for the prediction

        simulations : int
            How many simulations to perform

        Returns
        ----------
        Matrix of simulations
        """     

        sim_vector = np.zeros([simulations,h])

        for n in range(0, simulations):

            t_z = self.draw_latent_variables(nsims=1).T[0]
            mu, Y = self._model(t_z)  
            t_z = np.array([self.latent_variables.z_list[k].prior.transform(t_z[k]) for k in range(t_z.shape[0])])

            model_scale, model_shape, model_skewness = self._get_scale_and_shape(t_z)

            # Create arrays to iteratre over        
            Y_exp = Y.copy()
            mu_exp = mu.copy()

            # Loop over h time periods          
            for t in range(0,h):

                new_value = t_z[0]

                if self.ar != 0:
                    for j in range(1, self.ar+1):
                        new_value += t_z[j]*Y_exp[-j]

                if self.ma != 0:
                    for k in range(1, self.ma+1):
                        if (k-1) >= t:
                            new_value += t_z[k+self.ar]*(Y_exp[-k]-mu_exp[-k])

                if self.model_name2 == "Exponential":
                    rnd_value = self.family.draw_variable(1.0/self.link(new_value), model_scale, model_shape, model_skewness, 1)[0]
                else:
                    rnd_value = self.family.draw_variable(self.link(new_value), model_scale, model_shape, model_skewness, 1)[0]

                Y_exp = np.append(Y_exp, [rnd_value])
                mu_exp = np.append(mu_exp, [0]) # For indexing consistency

                sim_vector[n] = Y_exp[-h:]
            del Y_exp
            del mu_exp
        return np.transpose(sim_vector)
def _sim_prediction_bayes ( self , h , simulations ) : sim_vector = np . zeros ( [ simulations , h ] ) for n in range ( 0 , simulations ) : t_z = self . draw_latent_variables ( nsims = 1 ) . T [ 0 ] mu , Y = self . _model ( t_z ) t_z = np . array ( [ self . latent_variables . z_list [ k ] . prior . transform ( t_z [ k ] ) for k in range ( t_z . shape [ 0 ] ) ] ) model_scale , model_shape , model_skewness = self . _get_scale_and_shape ( t_z ) Y_exp = Y . copy ( ) mu_exp = mu . copy ( ) for t in range ( 0 , h ) : new_value = t_z [ 0 ] if self . ar != 0 : for j in range ( 1 , self . ar + 1 ) : new_value += t_z [ j ] * Y_exp [ - j ] if self . ma != 0 : for k in range ( 1 , self . ma + 1 ) : if ( k - 1 ) >= t : new_value += t_z [ k + self . ar ] * ( Y_exp [ - k ] - mu_exp [ - k ] ) if self . model_name2 == "Exponential" : rnd_value = self . family . draw_variable ( 1.0 / self . link ( new_value ) , model_scale , model_shape , model_skewness , 1 ) [ 0 ] else : rnd_value = self . family . draw_variable ( self . link ( new_value ) , model_scale , model_shape , model_skewness , 1 ) [ 0 ] Y_exp = np . append ( Y_exp , [ rnd_value ] ) mu_exp = np . append ( mu_exp , [ 0 ] ) sim_vector [ n ] = Y_exp [ - h : ] del Y_exp del mu_exp return np . transpose ( sim_vector )
Simulates a h-step ahead mean prediction

        Same as _mean_prediction() but now we repeat the process 
        by a number of times (simulations) and shock the process
        with random draws from the family, e.g. Normal shocks.

        Parameters
        ----------
        h : int
            How many steps ahead for the prediction

        simulations : int
            How many simulations to perform

        Returns
        ----------
        Matrix of simulations