class_docstr: Maximum Likelihood Estimation pareto distribution
  
  first version: iid case, with constant parameters
class_docstr_tok: ["Maximum","Likelihood","Estimation","pareto","distribution","first","version",":","iid","case",",","with","constant","parameters"]
docstr: fit Pareto with nested optimization
  
  originally published on stackoverflow
docstr_tok: ["fit","Pareto","with","nested","optimization","originally","published","on","stackoverflow"]
code: def fit_ks1_trim(self):
      """fit Pareto with nested optimization
  
      originally published on stackoverflow
  
      """
      self.nobs = self.endog.shape[0]
      rvs = np.sort(self.endog)
      rvsmin = rvs.min()
  
      def pareto_ks(loc, rvs):
          # start_scale = rvs.min() - loc # not used yet
          est = stats.pareto.fit_fr(rvs, frozen=[np.nan, loc, np.nan])
          args = (est[0], loc, est[1])
          return stats.kstest(rvs, "pareto", args)[0]
  
      # locest = optimize.fmin(pareto_ks, rvsmin*0.7, (rvs,))
      maxind = min(
          np.floor(self.nobs * 0.95).astype(int), self.nobs - 10
      )
      res = []
      for trimidx in range(self.nobs // 2, maxind):
          xmin = loc = rvs[trimidx]
          res.append([trimidx, pareto_ks(loc - 1e-10, rvs[trimidx:])])
      res = np.array(res)
      bestidx = res[np.argmin(res[:, 1]), 0].astype(int)
      print(bestidx)
      locest = rvs[bestidx]
  
      est = stats.pareto.fit_fr(
          rvs[bestidx:], 1.0, frozen=[np.nan, locest, np.nan]
      )
      args = (est[0], locest, est[1])
      return args
  
file_path: statsmodels/statsmodels/examples/ex_generic_mle_tdist.py
imports: import numpy
  from scipy import stats, special, optimize
  import statsmodels.api
  from statsmodels.base.model import GenericLikelihoodModel
  from statsmodels.tools.numdiff import approx_hess
  import statsmodels.sandbox.distributions.sppatch
label_desc: Use image node_id 5 for calling the MyPareto obj's underlying member method code with example usage: obj.fit_ks1_trim() and returns: args, stats