def neg_loglik(self,beta):
""" Creates the negative log-likelihood of the model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
The negative logliklihood of the model
"""
mu, Y = self._model(beta)
if self.use_ols_covariance is False:
cm = self.custom_covariance(beta)
else:
cm = self.ols_covariance()
diff = Y.T - mu.T
ll1 = -(mu.T.shape[0]*mu.T.shape[1]/2.0)*np.log(2.0*np.pi) - (mu.T.shape[0]/2.0)*np.linalg.slogdet(cm)[1]
inverse = np.linalg.pinv(cm)
return var_likelihood(ll1, mu.T.shape[0], diff, inverse)
评论列表
文章目录