prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  numdifftools dependency
  Original Launchpad bug 653902: https://bugs.launchpad.net/statsmodels/+bug/653902
  Reported by: vincent-vincentdavis (Vincent Davis).
  
  statsmodels/_init_.py imports tsa
  Which then returns an exception from statsmodels/tsa/var.py "raise Warning("You need to install numdifftools to try out the AR model")"
  Should numdifftools be a dependency for all of statsmodels ?
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `statsmodels/tsa/mlemodel.py`
  Content:
  ```
  1 """Base Classes for Likelihood Models in time series analysis
  2 
  3 Warning: imports numdifftools
  4 
  5 
  6 
  7 Created on Sun Oct 10 15:00:47 2010
  8 
  9 Author: josef-pktd
  10 License: BSD
  11 
  12 """
  13 
  14 import numpy as np
  15 
  16 import numdifftools as ndt
  17 
  18 from statsmodels.base.model import LikelihoodModel
  19 
  20 #copied from sandbox/regression/mle.py
  21 #TODO: I take it this is only a stub and should be included in another
  22 # model class?
  23 class TSMLEModel(LikelihoodModel):
  24     """
  25     univariate time series model for estimation with maximum likelihood
  26 
  27     Note: This is not working yet
  28     """
  29 
  30     def __init__(self, endog, exog=None):
  31         #need to override p,q (nar,nma) correctly
  32         super(TSMLEModel, self).__init__(endog, exog)
  33         #set default arma(1,1)
  34         self.nar = 1
  35         self.nma = 1
  36         #self.initialize()
  37 
  38     def geterrors(self, params):
  39         raise NotImplementedError
  40 
  41     def loglike(self, params):
  42         """
  43         Loglikelihood for timeseries model
  44 
  45         Notes
  46         -----
  47         needs to be overwritten by subclass
  48         """
  49         raise NotImplementedError
  50 
  51 
  52     def score(self, params):
  53         """
  54         Score vector for Arma model
  55         """
  56         #return None
  57         #print params
  58         jac = ndt.Jacobian(self.loglike, stepMax=1e-4)
  59         return jac(params)[-1]
  60 
  61     def hessian(self, params):
  62         """
  63         Hessian of arma model.  Currently uses numdifftools
  64         """
  65         #return None
  66         Hfun = ndt.Jacobian(self.score, stepMax=1e-4)
  67         return Hfun(params)[-1]
  68 
  69 
  70     def fit(self, start_params=None, maxiter=5000, method='fmin', tol=1e-08):
  71         '''estimate model by minimizing negative loglikelihood
  72 
  73         does this need to be overwritten ?
  74         '''
  75         if start_params is None and hasattr(self, '_start_params'):
  76             start_params = self._start_params
  77         #start_params = np.concatenate((0.05*np.ones(self.nar + self.nma), [1]))
  78         mlefit = super(TSMLEModel, self).fit(start_params=start_params,
  79                 maxiter=maxiter, method=method, tol=tol)
  80         return mlefit
  81
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/statsmodels/tsa/mlemodel.py b/statsmodels/tsa/mlemodel.py
  --- a/statsmodels/tsa/mlemodel.py
  +++ b/statsmodels/tsa/mlemodel.py
  @@ -13,7 +13,10 @@
   
   import numpy as np
   
  -import numdifftools as ndt
  +try:
  +    import numdifftools as ndt
  +except:
  +    pass
   
   from statsmodels.base.model import LikelihoodModel
  
verification_info: {"golden_diff": "diff --git a/statsmodels/tsa/mlemodel.py b/statsmodels/tsa/mlemodel.py\n--- a/statsmodels/tsa/mlemodel.py\n+++ b/statsmodels/tsa/mlemodel.py\n@@ -13,7 +13,10 @@\n \n import numpy as np\n \n-import numdifftools as ndt\n+try:\n+    import numdifftools as ndt\n+except:\n+    pass\n \n from statsmodels.base.model import LikelihoodModel\n", "issue": "numdifftools dependency\nOriginal Launchpad bug 653902: https://bugs.launchpad.net/statsmodels/+bug/653902\nReported by: vincent-vincentdavis (Vincent Davis).\n\nstatsmodels/_init_.py imports tsa\nWhich then returns an exception from statsmodels/tsa/var.py \"raise Warning(\"You need to install numdifftools to try out the AR model\")\"\nShould numdifftools be a dependency for all of statsmodels ?\n\n", "before_files": [{"content": "\"\"\"Base Classes for Likelihood Models in time series analysis\n\nWarning: imports numdifftools\n\n\n\nCreated on Sun Oct 10 15:00:47 2010\n\nAuthor: josef-pktd\nLicense: BSD\n\n\"\"\"\n\nimport numpy as np\n\nimport numdifftools as ndt\n\nfrom statsmodels.base.model import LikelihoodModel\n\n#copied from sandbox/regression/mle.py\n#TODO: I take it this is only a stub and should be included in another\n# model class?\nclass TSMLEModel(LikelihoodModel):\n    \"\"\"\n    univariate time series model for estimation with maximum likelihood\n\n    Note: This is not working yet\n    \"\"\"\n\n    def __init__(self, endog, exog=None):\n        #need to override p,q (nar,nma) correctly\n        super(TSMLEModel, self).__init__(endog, exog)\n        #set default arma(1,1)\n        self.nar = 1\n        self.nma = 1\n        #self.initialize()\n\n    def geterrors(self, params):\n        raise NotImplementedError\n\n    def loglike(self, params):\n        \"\"\"\n        Loglikelihood for timeseries model\n\n        Notes\n        -----\n        needs to be overwritten by subclass\n        \"\"\"\n        raise NotImplementedError\n\n\n    def score(self, params):\n        \"\"\"\n        Score vector for Arma model\n        \"\"\"\n        #return None\n        #print params\n        jac = ndt.Jacobian(self.loglike, stepMax=1e-4)\n        return jac(params)[-1]\n\n    def hessian(self, params):\n        \"\"\"\n        Hessian of arma model.  Currently uses numdifftools\n        \"\"\"\n        #return None\n        Hfun = ndt.Jacobian(self.score, stepMax=1e-4)\n        return Hfun(params)[-1]\n\n\n    def fit(self, start_params=None, maxiter=5000, method='fmin', tol=1e-08):\n        '''estimate model by minimizing negative loglikelihood\n\n        does this need to be overwritten ?\n        '''\n        if start_params is None and hasattr(self, '_start_params'):\n            start_params = self._start_params\n        #start_params = np.concatenate((0.05*np.ones(self.nar + self.nma), [1]))\n        mlefit = super(TSMLEModel, self).fit(start_params=start_params,\n                maxiter=maxiter, method=method, tol=tol)\n        return mlefit\n", "path": "statsmodels/tsa/mlemodel.py"}], "after_files": [{"content": "\"\"\"Base Classes for Likelihood Models in time series analysis\n\nWarning: imports numdifftools\n\n\n\nCreated on Sun Oct 10 15:00:47 2010\n\nAuthor: josef-pktd\nLicense: BSD\n\n\"\"\"\n\nimport numpy as np\n\ntry:\n    import numdifftools as ndt\nexcept:\n    pass\n\nfrom statsmodels.base.model import LikelihoodModel\n\n#copied from sandbox/regression/mle.py\n#TODO: I take it this is only a stub and should be included in another\n# model class?\nclass TSMLEModel(LikelihoodModel):\n    \"\"\"\n    univariate time series model for estimation with maximum likelihood\n\n    Note: This is not working yet\n    \"\"\"\n\n    def __init__(self, endog, exog=None):\n        #need to override p,q (nar,nma) correctly\n        super(TSMLEModel, self).__init__(endog, exog)\n        #set default arma(1,1)\n        self.nar = 1\n        self.nma = 1\n        #self.initialize()\n\n    def geterrors(self, params):\n        raise NotImplementedError\n\n    def loglike(self, params):\n        \"\"\"\n        Loglikelihood for timeseries model\n\n        Notes\n        -----\n        needs to be overwritten by subclass\n        \"\"\"\n        raise NotImplementedError\n\n\n    def score(self, params):\n        \"\"\"\n        Score vector for Arma model\n        \"\"\"\n        #return None\n        #print params\n        jac = ndt.Jacobian(self.loglike, stepMax=1e-4)\n        return jac(params)[-1]\n\n    def hessian(self, params):\n        \"\"\"\n        Hessian of arma model.  Currently uses numdifftools\n        \"\"\"\n        #return None\n        Hfun = ndt.Jacobian(self.score, stepMax=1e-4)\n        return Hfun(params)[-1]\n\n\n    def fit(self, start_params=None, maxiter=5000, method='fmin', tol=1e-08):\n        '''estimate model by minimizing negative loglikelihood\n\n        does this need to be overwritten ?\n        '''\n        if start_params is None and hasattr(self, '_start_params'):\n            start_params = self._start_params\n        #start_params = np.concatenate((0.05*np.ones(self.nar + self.nma), [1]))\n        mlefit = super(TSMLEModel, self).fit(start_params=start_params,\n                maxiter=maxiter, method=method, tol=tol)\n        return mlefit\n", "path": "statsmodels/tsa/mlemodel.py"}]}