code: def test_scipy_stats():
      # Using scipy.stats.models
  
      X, cons = twoway.design(D, contrasts=contrasts)
      Y = D["Days"]
      m = OLSModel(X)
      f = m.fit(Y)
  
      F_m = {}
      df_m = {}
      p_m = {}
  
      for n, c in cons.items():
          r = f.Fcontrast(c)
          F_m[n] = r.F
          df_m[n] = r.df_num
          p_m[n] = scipy.stats.f.sf(F_m[n], df_m[n], r.df_den)
          assert_almost_equal(F[n], F_m[n])
          assert_almost_equal(df[n], df_m[n])
          assert_almost_equal(p[n], p_m[n])
  
file_path: nipy/nipy/algorithms/statistics/models/tests/test_anova.py
imports: from io import StringIO
  import numpy
  import scipy.stats
  from nipy.testing import assert_almost_equal
  from ....utils.matrices import matrix_rank
  from ...formula.formulae import Factor, make_recarray
  from ..regression import OLSModel
label_desc: Use image node_id 3 for calling a global function with example usage: test_scipy_stats() without return types