Exemplo n.º 1
0
 def bse(self):
     params = self.params
     if not fast_kalman or self.model.method == "css":
         if len(params) == 1:  # can't take an inverse
             return np.sqrt(-1.0 / approx_hess_cs(params, self.model.loglike, epsilon=1e-5))
         return np.sqrt(np.diag(-inv(approx_hess_cs(params, self.model.loglike, epsilon=1e-5))))
     else:
         if len(params) == 1:
             return np.sqrt(-1.0 / approx_hess(params, self.model.loglike, epsilon=1e-3)[0])
         return np.sqrt(np.diag(-inv(approx_hess(params, self.model.loglike, epsilon=1e-3)[0])))
Exemplo n.º 2
0
 def bse(self):
     params = self.params
     if not fast_kalman or self.model.method == "css":
         if len(params) == 1: # can't take an inverse
             return np.sqrt(-1./approx_hess_cs(params,
                 self.model.loglike, epsilon=1e-5))
         return np.sqrt(np.diag(-inv(approx_hess_cs(params,
             self.model.loglike, epsilon=1e-5))))
     else:
         if len(params) == 1:
             return np.sqrt(-1./approx_hess(params,
                 self.model.loglike, epsilon=1e-3)[0])
         return np.sqrt(np.diag(-inv(approx_hess(params,
             self.model.loglike, epsilon=1e-3)[0])))
Exemplo n.º 3
0
 def cov_params(self):  # add scale argument?
     func = self.model.loglike
     x0 = self.params
     if not fast_kalman or self.model.method == "css":
         return -inv(approx_hess_cs(x0, func))
     else:
         return -inv(approx_hess(x0, func, epsilon=1e-3)[0])
Exemplo n.º 4
0
 def cov_params(self): # add scale argument?
     func = self.model.loglike
     x0 = self.params
     if not fast_kalman or self.model.method == "css":
         return -inv(approx_hess_cs(x0, func))
     else:
         return -inv(approx_hess(x0, func, epsilon=1e-3)[0])
Exemplo n.º 5
0
    def hessian(self, params):
        """
        Compute the Hessian at params,

        Notes
        -----
        This is a numerical approximation.
        """
        loglike = self.loglike
        #if self.transparams:
        #    params = self._invtransparams(params)
        if not fast_kalman or self.method == "css":
            return approx_hess_cs(params, loglike, epsilon=1e-5)
        else:
            return approx_hess(params, self.loglike, epsilon=1e-3)[0]
Exemplo n.º 6
0
    def hessian(self, params):
        """
        Compute the Hessian at params,

        Notes
        -----
        This is a numerical approximation.
        """
        loglike = self.loglike
        #if self.transparams:
        #    params = self._invtransparams(params)
        if not fast_kalman or self.method == "css":
            return approx_hess_cs(params, loglike, epsilon=1e-5)
        else:
            return approx_hess(params, self.loglike, epsilon=1e-3)[0]