code: def fit(self, data, debug=False):
          
          with log_start_finish('fitting model {}'.format(self.name), logger):
              fit = fit_model(data, self.fit_filters, self.str_model_expression)
  
          self.model_fit = fit
          self.fit_parameters = _model_fit_to_table(fit)
          if debug:
              index = util.apply_filter_query(data, self.fit_filters).index
              assert len(fit.model.exog) == len(index), (
                  "The estimate data is unequal in length to the original "
                  "dataframe, usually caused by nans")
              df = pd.DataFrame(
                  fit.model.exog, columns=fit.model.exog_names, index=index)
              df[fit.model.endog_names] = fit.model.endog
              df["fittedvalues"] = fit.fittedvalues
              df["residuals"] = fit.resid
              self.est_data = df
          return fit
docs: Fit the model to data and store/return the results.
  
          Parameters
          ----------
          data : pandas.DataFrame
              Data to use for fitting the model. Must contain all the
              columns referenced by the `model_expression`.
          debug : bool
              If debug is set to true, this sets the attribute "est_data"
              to a dataframe with the actual data used for estimation of
              this model.
  
          Returns
          -------
          fit : statsmodels.regression.linear_model.OLSResults
              This is returned for inspection, but also stored on the
              class instance for use during prediction.