code: def compare_r_output_dogs_data(method, model):
      """Testing within-subject effect interact with 2 between-subject effect
      Compares with R car library Anova(, type=3) output
  
      Note: The test statistis Phillai, Wilks, Hotelling-Lawley
            and Roy are the same as R output but the approximate F and degree
            of freedoms can be different. This is due to the fact that this
            implementation is based on SAS formula [1]
  
      .. [*] https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_introreg_sect012.htm
      """
  
      # Repeated measures with orthogonal polynomial contrasts coding
      mod = model.from_formula(
          "Histamine0 + Histamine1 + Histamine3 + Histamine5 ~ Drug * Depleted",
          data,
      )
      r = mod.fit(method=method)
      r = r.mv_test()
      a = [
          [2.68607660e-02, 4, 6, 5.43435304e01, 7.59585610e-05],
          [9.73139234e-01, 4, 6, 5.43435304e01, 7.59585610e-05],
          [3.62290202e01, 4, 6, 5.43435304e01, 7.59585610e-05],
          [3.62290202e01, 4, 6, 5.43435304e01, 7.59585610e-05],
      ]
      assert_array_almost_equal(
          r["Intercept"]["stat"].values, a, decimal=6
      )
      a = [
          [
              8.39646619e-02,
              8,
              1.20000000e01,
              3.67658068e00,
              2.12614444e-02,
          ],
          [
              1.18605382e00,
              8,
              1.40000000e01,
              2.55003861e00,
              6.01270701e-02,
          ],
          [
              7.69391362e00,
              8,
              6.63157895e00,
              5.50814270e00,
              2.07392260e-02,
          ],
          [
              7.25036952e00,
              4,
              7.00000000e00,
              1.26881467e01,
              2.52669877e-03,
          ],
      ]
      assert_array_almost_equal(r["Drug"]["stat"].values, a, decimal=6)
      a = [
          [0.32048892, 4.0, 6.0, 3.18034906, 0.10002373],
          [0.67951108, 4.0, 6.0, 3.18034906, 0.10002373],
          [2.12023271, 4.0, 6.0, 3.18034906, 0.10002373],
          [2.12023271, 4.0, 6.0, 3.18034906, 0.10002373],
      ]
      assert_array_almost_equal(
          r["Depleted"]["stat"].values, a, decimal=6
      )
      a = [
          [0.15234366, 8.0, 12.0, 2.34307678, 0.08894239],
          [1.13013353, 8.0, 14.0, 2.27360606, 0.08553213],
          [3.70989596, 8.0, 6.63157895, 2.65594824, 0.11370285],
          [3.1145597, 4.0, 7.0, 5.45047947, 0.02582767],
      ]
      assert_array_almost_equal(
          r["Drug:Depleted"]["stat"].values, a, decimal=6
      )
  
imports: import os.path
  import numpy
  import pandas
  import pytest
  from statsmodels.regression.linear_model import OLS
  from statsmodels.multivariate.multivariate_ols import _MultivariateOLS, MultivariateLS
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_raises
  import patsy
label_desc: Use image node_id 1 for calling a global function with example usage: compare_r_output_dogs_data(method, model) without return types