class_docstr: MI performs multiple imputation using a provided imputer object.
  
  Parameters
  ----------
  imp : object
      An imputer class, such as BayesGaussMI.
  model : model class
      Any statsmodels model class.
  model_args_fn : function
      A function taking an imputed dataset as input and returning
      endog, exog.  If the model is fit using a formula, returns
      a DataFrame used to build the model.  Optional when a formula
      is used.
  model_kwds_fn : function, optional
      A function taking an imputed dataset as input and returning
      a dictionary of model keyword arguments.
  formula : str, optional
      If provided, the model is constructed using the `from_formula`
      class method, otherwise the `__init__` method is used.
  fit_args : list-like, optional
      List of arguments to be passed to the fit method
  fit_kwds : dict-like, optional
      Keyword arguments to be passed to the fit method
  xfunc : function mapping ndarray to ndarray
      A function that is applied to the complete data matrix
      prior to fitting the model
  burn : int
      Number of burn-in iterations
  nrep : int
      Number of imputed data sets to use in the analysis
  skip : int
      Number of Gibbs iterations to skip between successive
      multiple imputation fits.
  
  Notes
  -----
  The imputer object must have an 'update' method, and a 'data'
  attribute that contains the current imputed dataset.
  
  xfunc can be used to introduce domain constraints, e.g. when
  imputing binary data the imputed continuous values can be rounded
  to 0/1.
class_docstr_tok: ["MI","performs","multiple","imputation","using","a","provided","imputer","object",".","Parameters","--","--","--","--","--","imp",":","object","An","imputer","class",",","such","as","BayesGaussMI",".","model",":","model","class","Any","statsmodels","model","class",".","model_args_fn",":","function","A","function","taking","an","imputed","dataset","as","input","and","returning","endog",",","exog",".","If","the","model","is","fit","using","a","formula",",","returns","a","DataFrame","used","to","build","the","model",".","Optional","when","a","formula","is","used",".","model_kwds_fn",":","function",",","optional","A","function","taking","an","imputed","dataset","as","input","and","returning","a","dictionary","of","model","keyword","arguments",".","formula",":","str",",","optional","If","provided",",","the","model","is","constructed","using","the","`","from_formula","`","class","method",",","otherwise","the","`","__init__","`","method","is","used",".","fit_args",":","list-like",",","optional","List","of","arguments","to","be","passed","to","the","fit","method","fit_kwds",":","dict-like",",","optional","Keyword","arguments","to","be","passed","to","the","fit","method","xfunc",":","function","mapping","ndarray","to","ndarray","A","function","that","is","applied","to","the","complete","data","matrix","prior","to","fitting","the","model","burn",":","int","Number","of","burn-in","iterations","nrep",":","int","Number","of","imputed","data","sets","to","use","in","the","analysis","skip",":","int","Number","of","Gibbs","iterations","to","skip","between","successive","multiple","imputation","fits",".","Notes","--","--","-","The","imputer","object","must","have","an","'update","'","method",",","and","a","'data'","attribute","that","contains","the","current","imputed","dataset",".","xfunc","can","be","used","to","introduce","domain","constraints",",","e.g",".","when","imputing","binary","data","the","imputed","continuous","values","can","be","rounded","to","0\/1","."]
docstr: Impute datasets, fit models, and pool results.
  
  Parameters
  ----------
  results_cb : function, optional
      If provided, each results instance r is passed through `results_cb`,
      then appended to the `results` attribute of the MIResults object.
      To save complete results, use `results_cb=lambda x: x`.  The default
      behavior is to save no results.
  
  Returns
  -------
  A MIResults object.
docstr_tok: ["Impute","datasets",",","fit","models",",","and","pool","results",".","Parameters","--","--","--","--","--","results_cb",":","function",",","optional","If","provided",",","each","results","instance","r","is","passed","through","`","results_cb","`",",","then","appended","to","the","`","results","`","attribute","of","the","MIResults","object",".","To","save","complete","results",",","use","`","results_cb=lambda","x",":","x","`",".","The","default","behavior","is","to","save","no","results",".","Returns","--","--","--","-","A","MIResults","object","."]
code: def fit(self, results_cb=None):
      """
      Impute datasets, fit models, and pool results.
  
      Parameters
      ----------
      results_cb : function, optional
          If provided, each results instance r is passed through `results_cb`,
          then appended to the `results` attribute of the MIResults object.
          To save complete results, use `results_cb=lambda x: x`.  The default
          behavior is to save no results.
  
      Returns
      -------
      A MIResults object.
      """
  
      par, cov = [], []
      all_results = []
  
      for k in range(self.nrep):
          for k in range(self.skip + 1):
              self.imp.update()
  
          da = self.imp.data
  
          if self.xfunc is not None:
              da = self.xfunc(da)
  
          if self.formula is None:
              model = self.model(
                  *self.model_args_fn(da), **self.model_kwds_fn(da)
              )
          else:
              model = self.model.from_formula(
                  self.formula,
                  *self.model_args_fn(da),
                  **self.model_kwds_fn(da),
              )
  
          result = model.fit(*self.fit_args(da), **self.fit_kwds(da))
  
          if results_cb is not None:
              all_results.append(results_cb(result))
  
          par.append(np.asarray(result.params.copy()))
          cov.append(np.asarray(result.cov_params().copy()))
  
      params, cov_params, fmi = self._combine(par, cov)
  
      r = MIResults(self, model, params, cov_params)
      r.fmi = fmi
  
      r.results = all_results
  
      return r
  
file_path: statsmodels/statsmodels/imputation/bayes_mi.py
imports: import numpy
  import pandas
  from statsmodels.base.model import LikelihoodModelResults
label_desc: Use image node_id 2 for calling the MI obj's underlying member method code with example usage: obj.fit(results_cb) and returns: r