Created
November 26, 2021 11:09
-
-
Save sachinsdate/bde270bf7e49832a36c4dba100b188a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nloglikeobs(self, params): | |
#Reconstitute the q and beta matrices from the current values of all the params | |
self.reconstitute_parameter_matrices(params) | |
#Build the regime wise matrix of Poisson means | |
self.compute_regime_specific_poisson_means() | |
#Build the matrix of Markov transition probabilities by standardizing all the q values to | |
# the 0 to 1 range | |
self.compute_markov_transition_probabilities() | |
#Build the (len(y) x k) matrix delta of Markov state probabilities distribution. k state | |
# probabilities corresponding to k regimes, times, number of time steps (i.e. observations) | |
self.compute_markov_state_probabilities() | |
#Let's increment the iteration count | |
self.iter_num=self.iter_num+1 | |
# Compute all the log-likelihood values for the Poisson Markov model | |
ll = self.compute_loglikelihood() | |
#Print out the iteration summary | |
print('ITER='+str(self.iter_num) + ' ll='+str(((-ll).sum(0)))) | |
#Return the negated array of log-likelihood values | |
return -ll |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment