code: def multiOLS(
      model,
      dataframe,
      column_list=None,
      method="fdr_bh",
      alpha=0.05,
      subset=None,
      model_type=OLS,
      **kwargs,
  ):
      """apply a linear model to several endogenous variables on a dataframe
  
      Take a linear model definition via formula and a dataframe that will be
      the environment of the model, and apply the linear model to a subset
      (or all) of the columns of the dataframe. It will return a dataframe
      with part of the information from the linear model summary.
  
      Parameters
      ----------
      model : str
          formula description of the model
      dataframe : pandas.dataframe
          dataframe where the model will be evaluated
      column_list : list[str], optional
          Names of the columns to analyze with the model.
          If None (Default) it will perform the function on all the
          eligible columns (numerical type and not in the model definition)
      model_type : model class, optional
          The type of model to be used. The default is the linear model.
          Can be any linear model (OLS, WLS, GLS, etc..)
      method : str, optional
          the method used to perform the pvalue correction for multiple testing.
          default is the Benjamini/Hochberg, other available methods are:
  
              `bonferroni` : one-step correction
              `sidak` : on-step correction
              `holm-sidak` :
              `holm` :
              `simes-hochberg` :
              `hommel` :
              `fdr_bh` : Benjamini/Hochberg
              `fdr_by` : Benjamini/Yekutieli
  
      alpha : float, optional
          the significance level used for the pvalue correction (default 0.05)
      subset : bool array
          the selected rows to be used in the regression
  
      all the other parameters will be directed to the model creation.
  
      Returns
      -------
      summary : pandas.DataFrame
          a dataframe containing an extract from the summary of the model
          obtained for each columns. It will give the model complexive f test
          result and p-value, and the regression value and standard deviarion
          for each of the regressors. The DataFrame has a hierachical column
          structure, divided as:
  
              - params: contains the parameters resulting from the models. Has
              an additional column named _f_test containing the result of the
              F test.
              - pval: the pvalue results of the models. Has the _f_test column
              for the significativity of the whole test.
              - adj_pval: the corrected pvalues via the multitest function.
              - std: uncertainties of the model parameters
              - statistics: contains the r squared statistics and the adjusted
              r squared.
  
      Notes
      -----
      The main application of this function is on system biology to perform
      a linear model testing of a lot of different parameters, like the
      different genetic expression of several genes.
  
      See Also
      --------
      statsmodels.stats.multitest
          contains several functions to perform the multiple p-value correction
  
      Examples
      --------
      Using the longley data as dataframe example
  
      >>> import statsmodels.api as sm
      >>> data = sm.datasets.longley.load_pandas()
      >>> df = data.exog
      >>> df['TOTEMP'] = data.endog
  
      This will perform the specified linear model on all the
      other columns of the dataframe
      >>> multiOLS('GNP + 1', df)
  
      This select only a certain subset of the columns
      >>> multiOLS('GNP + 0', df, ['GNPDEFL', 'TOTEMP', 'POP'])
  
      It is possible to specify a trasformation also on the target column,
      conforming to the patsy formula specification
      >>> multiOLS('GNP + 0', df, ['I(GNPDEFL**2)', 'center(TOTEMP)'])
  
      It is possible to specify the subset of the dataframe
      on which perform the analysis
      >> multiOLS('GNP + 1', df, subset=df.GNPDEFL > 90)
  
      Even a single column name can be given without enclosing it in a list
      >>> multiOLS('GNP + 0', df, 'GNPDEFL')
      """
      # data normalization
      # if None take all the numerical columns that are not present in the model
      # it's not waterproof but is a good enough criterion for everyday use
      if column_list is None:
          column_list = [
              name
              for name in dataframe.columns
              if dataframe[name].dtype != object and name not in model
          ]
      # if it's a single string transform it in a single element list
      if isinstance(column_list, str):
          column_list = [column_list]
      if subset is not None:
          dataframe = dataframe.loc[subset]
      # perform each model and retrieve the statistics
      col_results = {}
      # as the model will use always the same endogenous variables
      # we can create them once and reuse
      model_exog = dmatrix(
          model, data=dataframe, return_type="dataframe"
      )
      for col_name in column_list:
          # it will try to interpret the column name as a valid dataframe
          # index as it can be several times faster. If it fails it
          # interpret it as a patsy formula (for example for centering)
          try:
              model_endog = dataframe[col_name]
          except KeyError:
              model_endog = dmatrix(col_name + " + 0", data=dataframe)
          # retrieve the result and store them
          res = _model2dataframe(
              model_endog, model_exog, model_type, **kwargs
          )
          col_results[col_name] = res
      # mangle them togheter and sort by complexive p-value
      summary = pd.DataFrame(col_results)
      # order by the p-value: the most useful model first!
      summary = summary.T.sort_values([("pvals", "_f_test")])
      summary.index.name = "endogenous vars"
      # implementing the pvalue correction method
      smt = stats.multipletests
      for key1, key2 in summary:
          if key1 != "pvals":
              continue
          p_values = summary[key1, key2]
          corrected = smt(p_values, method=method, alpha=alpha)[1]
          # extend the dataframe of results with the column
          # of the corrected p_values
          summary["adj_" + key1, key2] = corrected
      return summary
  
file_path: statsmodels/statsmodels/sandbox/multilinear.py
imports: from patsy import dmatrix
  import pandas
  from statsmodels.api import OLS
  from statsmodels.api import stats
  import numpy
  import logging
label_desc: Use image node_id 2 for calling a global function with example usage: multiOLS(model, dataframe, column_list, method, alpha, subset, model_type) and returns: summary