code: def statsmodels_baseline(
      genotype_df,
      phenotype_df,
      covariate_df,
      offset_dfs=None,
      add_intercept=True,
  ):
      # Project out covariates from genotypes and phenotypes
      C = covariate_df.to_numpy("float64")
      num_samples = C.shape[0] if C.size else genotype_df.shape[0]
      if add_intercept:
          C = gwas_fx._add_intercept(C, num_samples)
      Y = phenotype_df.to_numpy("float64")
      X = genotype_df.to_numpy("float64")
      phenotype_df.columns = phenotype_df.columns.astype("str")
      dof = C.shape[0] - C.shape[1] - 1
      effects = []
      errors = []
      tvalues = []
      pvalues = []
      for phenotype_idx in range(Y.shape[1]):
          for genotype_idx in range(X.shape[1]):
              phenotype = Y[:, phenotype_idx].copy()
              phenotype_mask = ~np.isnan(phenotype)
              phenotype[~phenotype_mask] = 0
              phenotype -= phenotype.mean()
              phenotype = residualize(phenotype, C) * phenotype_mask
              phenotype_scale = np.sqrt(
                  (phenotype**2).sum()
                  / (phenotype_mask.sum() - C.shape[1])
              )
              phenotype /= phenotype_scale
              if offset_dfs:
                  offset = (
                      offset_dfs[genotype_idx]
                      .iloc[:, phenotype_idx]
                      .to_numpy("float64")
                  )
                  phenotype = phenotype - offset
              phenotype[~phenotype_mask] = np.nan
  
              genotype = residualize(X[:, genotype_idx], C)
              genotype = pd.Series(genotype, name="genotype")
  
              model = sm.OLS(phenotype, genotype, missing="drop")
              model.df_resid = dof
              results = model.fit()
  
              effects.append(results.params.genotype * phenotype_scale)
              errors.append(results.bse.genotype * phenotype_scale)
              tvalues.append(results.tvalues.genotype)
              pvalues.append(results.pvalues.genotype)
      return pd.DataFrame(
          {
              "effect": effects,
              "standard_error": errors,
              "tvalue": tvalues,
              "pvalue": pvalues,
              "phenotype": phenotype_df.columns.to_series().repeat(
                  genotype_df.shape[1]
              ),
          }
      )
  
imports: import functions
  import numpy
  import statsmodels.api
  import pandas
  import glow.gwas.functions
  import glow.gwas.lin_reg
  import pytest
label_desc: Use image node_id 4 for calling a global function with example usage: statsmodels_baseline(genotype_df, phenotype_df, covariate_df, offset_dfs, add_intercept) and returns: pd