code: def test_Ragreement():
      # This code would fit the two-way ANOVA model in R
  
      # X = read.table('http://www-stat.stanford.edu/~jtaylo/courses/stats191/data/kidney.table', header=T)
      # names(X)
      # X$Duration = factor(X$Duration)
      # X$Weight = factor(X$Weight)
      # lm(Days~Duration*Weight, X)
      # A = anova(lm(Days~Duration*Weight, X))
  
      # rA = rpy.r('A')
      rA = {
          "Df": [1, 2, 2, 54],
          "F value": [
              7.2147239263803673,
              13.120973926380339,
              1.8813266871165633,
              np.nan,
          ],
          "Mean Sq": [
              209.06666666666663,
              380.21666666666584,
              54.51666666666663,
              28.977777777777778,
          ],
          "Pr(>F)": [
              0.0095871255601553771,
              2.2687781292164585e-05,
              0.16224035152442268,
              np.nan,
          ],
          "Sum Sq": [
              209.06666666666663,
              760.43333333333169,
              109.03333333333326,
              1564.8,
          ],
      }
  
      # rn = rpy.r('rownames(A)')
      rn = ["Duration", "Weight", "Duration:Weight", "Residuals"]
  
      pairs = [
          (rn.index("Duration"), "Duration"),
          (rn.index("Weight"), "Weight"),
          (rn.index("Duration:Weight"), "Interaction"),
      ]
  
      for i, j in pairs:
          assert_almost_equal(F[j], rA["F value"][i])
          assert_almost_equal(p[j], rA["Pr(>F)"][i])
          assert_almost_equal(MS[j], rA["Mean Sq"][i])
          assert_almost_equal(df[j], rA["Df"][i])
          assert_almost_equal(SS[j], rA["Sum Sq"][i])
  
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 2 for calling a global function with example usage: test_Ragreement() without return types