Skip to content

Instantly share code, notes, and snippets.

@sachinsdate
Created November 26, 2021 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sachinsdate/bde270bf7e49832a36c4dba100b188a2 to your computer and use it in GitHub Desktop.
Save sachinsdate/bde270bf7e49832a36c4dba100b188a2 to your computer and use it in GitHub Desktop.
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