code: def test_r_method(self):
      def r_step(losses, indices):
          # A basic but direct implementation of the r method
          k = losses.shape[1]
          b = len(indices)
          mean_diffs = losses.mean(0)
          loss_diffs = np.zeros((k, k))
          variances = np.zeros((k, k))
          bs_diffs = np.zeros(b)
          stat_candidates = []
          for i in range(k):
              for j in range(i, k):
                  if i == j:
                      variances[i, i] = 1.0
                      loss_diffs[i, j] = 0.0
                      continue
                  loss_diffs_vec = losses[:, i] - losses[:, j]
                  loss_diffs_vec = (
                      loss_diffs_vec - loss_diffs_vec.mean()
                  )
                  loss_diffs[i, j] = mean_diffs[i] - mean_diffs[j]
                  loss_diffs[j, i] = mean_diffs[j] - mean_diffs[i]
                  for n in range(b):
                      # Compute bootstrapped versions
                      bs_diffs[n] = loss_diffs_vec[indices[n]].mean()
                  variances[j, i] = variances[i, j] = (
                      bs_diffs**2
                  ).mean()
                  std_diffs = np.abs(bs_diffs) / np.sqrt(
                      variances[i, j]
                  )
                  stat_candidates.append(std_diffs)
          stat_candidates = np.array(stat_candidates).T
          stat_distn = np.max(stat_candidates, 1)
          std_loss_diffs = loss_diffs / np.sqrt(variances)
          stat = np.max(std_loss_diffs)
          pval = np.mean(stat <= stat_distn)
          loc = np.argwhere(std_loss_diffs == stat)
          drop_index = loc.flat[0]
          return pval, drop_index
  
      losses = self.losses[:, :10]  # Limit size
      mcs = MCS(losses, 0.05, reps=200, seed=23456)
      mcs.compute()
      m = 5  # Number of direct
      pvals = np.zeros(m) * np.nan
      indices = np.zeros(m) * np.nan
      for i in range(m):
          removed = list(indices[np.isfinite(indices)])
          include = list(set(list(range(10))).difference(removed))
          include.sort()
          pval, drop_index = r_step(
              losses[:, np.array(include)], mcs._bootstrap_indices
          )
          pvals[i] = pval if i == 0 else np.max([pvals[i - 1], pval])
          indices[i] = include[drop_index]
      direct = pd.DataFrame(
          pvals,
          index=np.array(indices, dtype=np.int64),
          columns=["Pvalue"],
      )
      direct.index.name = "Model index"
      assert_frame_equal(mcs.pvalues.iloc[:m], direct)
  
imports: from typing import NamedTuple
  import numpy
  from numpy import linspace
  from numpy.random import RandomState
  from numpy.testing import assert_allclose, assert_equal
  import pandas
  from pandas.testing import assert_frame_equal, assert_series_equal
  import pytest
  import scipy.stats
  from arch.bootstrap import CircularBlockBootstrap, MovingBlockBootstrap, StationaryBootstrap
  from arch.bootstrap.multiple_comparison import MCS, SPA, StepM
label_desc: Use image node_id 2 for calling the TestMCS obj's underlying member method code with example usage: obj.test_r_method() and returns: pval,  drop_index