'Conditional Sum of Squares likelihood function.'

def loglike_css(self, params, set_sigma2=True):

    k_ar = self.k_ar
    k_ma = self.k_ma
    k = (self.k_exog + self.k_trend)
    y = self.endog.copy().astype(params.dtype)
    nobs = self.nobs
    if self.transparams:
        newparams = self._transparams(params)
    else:
        newparams = params
    if (k > 0):
        y -= dot(self.exog, newparams[:k])
    (b, a) = (np.r_[(1, (- newparams[k:(k + k_ar)]))], np.r_[(1, newparams[(k + k_ar):])])
    zi = np.zeros(max(k_ar, k_ma), dtype=params.dtype)
    for i in range(k_ar):
        zi[i] = sum(((- b[:(i + 1)][::(-1)]) * y[:(i + 1)]))
    errors = lfilter(b, a, y, zi=zi)[0][k_ar:]
    ssr = np.dot(errors, errors)
    sigma2 = (ssr / nobs)
    if set_sigma2:
        self.sigma2 = sigma2
    llf = ((((- nobs) / 2.0) * (log((2 * pi)) + log(sigma2))) - (ssr / (2 * sigma2)))
    return llf
