def gradient_momcond(self, params, epsilon=1e-4, method='centered'): momcond = self.momcond_mean if method == 'centered': gradmoms = (approx_fprime1(params, momcond, epsilon=epsilon) + approx_fprime1(params, momcond, epsilon=-epsilon))/2 else: gradmoms = approx_fprime1(params, momcond, epsilon=epsilon) return gradmoms
def grad(self, params=None, **kwds): if params is None: params = self.params kwds.setdefault("epsilon", 1e-4) from gwstatsmodels.sandbox.regression.numdiff import approx_fprime1 return approx_fprime1(params, self.fun, **kwds)