(self, maxOrder, method='BIC')
Estimates the optimal order of a Markov model
            based on Likelihood, BIC or AIC
Estimates the optimal order of a Markov model
            based on Likelihood, BIC or AIC
Estimates the optimal order of a Markov model based on Likelihood BIC or AIC
def estimateOrder(self, maxOrder, method='BIC'):
        """ Estimates the optimal order of a Markov model
            based on Likelihood, BIC or AIC """

        assert method == 'BIC' or method == 'AIC' or method == 'Likelihood', "Error: Expecting method 'AIC', 'BIC' or 'Likelihood'"

        values = []
        orders = []

        # We need k < m for the BIC and AIC calculation, which
        # is why we only test up to maxOrder - 1
        for k in range(1, maxOrder):
            if k not in self.P:
                self.fitMarkovModel(k)

            orders.append(k)

            if method == 'AIC':
                values.append(self.getAIC(k, maxOrder))
            elif method == 'BIC':
                values.append(self.getBIC(k, maxOrder))
            elif method == 'Likelihood':
                values.append(self.getLikelihood(k, log=True))

        if method == 'Likelihood':
            values.append(self.getLikelihood(maxOrder, log=True))
            orders.append(maxOrder)

            # return order at which likelihood is maximized
            return orders[_np.argmax(values)]
        else:
            # return order at which BIC/AIC are minimized
            return orders[_np.argmin(values)]
def estimateOrder ( self , maxOrder , method = 'BIC' ) : assert method == 'BIC' or method == 'AIC' or method == 'Likelihood' , "Error: Expecting method 'AIC', 'BIC' or 'Likelihood'" values = [ ] orders = [ ] # We need k < m for the BIC and AIC calculation, which # is why we only test up to maxOrder - 1 for k in range ( 1 , maxOrder ) : if k not in self . P : self . fitMarkovModel ( k ) orders . append ( k ) if method == 'AIC' : values . append ( self . getAIC ( k , maxOrder ) ) elif method == 'BIC' : values . append ( self . getBIC ( k , maxOrder ) ) elif method == 'Likelihood' : values . append ( self . getLikelihood ( k , log = True ) ) if method == 'Likelihood' : values . append ( self . getLikelihood ( maxOrder , log = True ) ) orders . append ( maxOrder ) # return order at which likelihood is maximized return orders [ _np . argmax ( values ) ] else : # return order at which BIC/AIC are minimized return orders [ _np . argmin ( values ) ]