code: def test_framing_example_moderator():
      # moderation without formulas, generally not useful but test anyway
  
      cur_dir = os.path.dirname(os.path.abspath(__file__))
      data = pd.read_csv(
          os.path.join(cur_dir, "results", "framing.csv")
      )
  
      outcome = np.asarray(data["cong_mesg"])
      outcome_exog = patsy.dmatrix(
          "emo + treat + age + educ + gender + income",
          data,
          return_type="dataframe",
      )
      outcome_model = sm.GLM(
          outcome,
          outcome_exog,
          family=sm.families.Binomial(link=sm.families.links.Probit()),
      )
  
      mediator = np.asarray(data["emo"])
      mediator_exog = patsy.dmatrix(
          "treat + age + educ + gender + income",
          data,
          return_type="dataframe",
      )
      mediator_model = sm.OLS(mediator, mediator_exog)
  
      tx_pos = [
          outcome_exog.columns.tolist().index("treat"),
          mediator_exog.columns.tolist().index("treat"),
      ]
      med_pos = outcome_exog.columns.tolist().index("emo")
  
      ix = (
          outcome_exog.columns.tolist().index("age"),
          mediator_exog.columns.tolist().index("age"),
      )
      moderators = {ix: 20}
      med = Mediation(
          outcome_model,
          mediator_model,
          tx_pos,
          med_pos,
          moderators=moderators,
      )
  
      # Just a smoke test
      np.random.seed(4231)
      med_rslt = med.fit(method="parametric", n_rep=100)
  
file_path: statsmodels/statsmodels/stats/tests/test_mediation.py
imports: import numpy
  import statsmodels.api
  import os
  from statsmodels.stats.mediation import Mediation
  import pandas
  from numpy.testing import assert_allclose
  import patsy
  import pytest
label_desc: Use image node_id 2 for calling a global function with example usage: test_framing_example_moderator() without return types