'Loglikelihood for SVAR model
Notes
This method assumes that the autoregressive parameters are
first estimated, then likelihood with structural parameters
is estimated'

def loglike(self, params):

    A = self.A
    B = self.B
    A_mask = self.A_mask
    B_mask = self.B_mask
    A_len = len(A[A_mask])
    B_len = len(B[B_mask])
    if (A is not None):
        A[A_mask] = params[:A_len]
    if (B is not None):
        B[B_mask] = params[A_len:(A_len + B_len)]
    nobs = self.nobs
    neqs = self.neqs
    sigma_u = self.sigma_u
    W = np.dot(npl.inv(B), A)
    trc_in = np.dot(np.dot(W.T, W), sigma_u)
    (sign, b_logdet) = slogdet((B ** 2))
    b_slogdet = (sign * b_logdet)
    likl = (((- nobs) / 2.0) * ((((neqs * np.log((2 * np.pi))) - np.log((npl.det(A) ** 2))) + b_slogdet) + np.trace(trc_in)))
    return likl
