code: def rm_corr(data=None, x=None, y=None, subject=None):
      """Repeated measures correlation.
  
      Parameters
      ----------
      data : :py:class:`pandas.DataFrame`
          Dataframe.
      x, y : string
          Name of columns in ``data`` containing the two dependent variables.
      subject : string
          Name of column in ``data`` containing the subject indicator.
  
      Returns
      -------
      stats : :py:class:`pandas.DataFrame`
  
          * ``'r'``: Repeated measures correlation coefficient
          * ``'dof'``: Degrees of freedom
          * ``'pval'``: p-value
          * ``'CI95'``: 95% parametric confidence intervals
          * ``'power'``: achieved power of the test (= 1 - type II error).
  
      See also
      --------
      plot_rm_corr
  
      Notes
      -----
      Repeated measures correlation (rmcorr) is a statistical technique for determining the common
      within-individual association for paired measures assessed on two or more occasions for
      multiple individuals.
  
      From `Bakdash and Marusich (2017)
      <https://doi.org/10.3389/fpsyg.2017.00456>`_:
  
          *Rmcorr accounts for non-independence among observations using analysis
          of covariance (ANCOVA) to statistically adjust for inter-individual
          variability. By removing measured variance between-participants,
          rmcorr provides the best linear fit for each participant using parallel
          regression lines (the same slope) with varying intercepts.
          Like a Pearson correlation coefficient, the rmcorr coefficient
          is bounded by − 1 to 1 and represents the strength of the linear
          association between two variables.*
  
      Results have been tested against the `rmcorr <https://github.com/cran/rmcorr>`_ R package.
  
      Missing values are automatically removed from the dataframe (listwise deletion).
  
      Examples
      --------
      >>> import pingouin as pg
      >>> df = pg.read_dataset('rm_corr')
      >>> pg.rm_corr(data=df, x='pH', y='PacO2', subject='Subject')
                     r  dof      pval           CI95%     power
      rm_corr -0.50677   38  0.000847  [-0.71, -0.23]  0.929579
  
      Now plot using the :py:func:`pingouin.plot_rm_corr` function:
  
      .. plot::
  
          >>> import pingouin as pg
          >>> df = pg.read_dataset('rm_corr')
          >>> g = pg.plot_rm_corr(data=df, x='pH', y='PacO2', subject='Subject')
      """
      from pingouin import ancova, power_corr
  
      # Safety checks
      assert isinstance(data, pd.DataFrame), "Data must be a DataFrame"
      assert x in data.columns, "The %s column is not in data." % x
      assert y in data.columns, "The %s column is not in data." % y
      assert data[x].dtype.kind in "bfiu", "%s must be numeric." % x
      assert data[y].dtype.kind in "bfiu", "%s must be numeric." % y
      assert subject in data.columns, (
          "The %s column is not in data." % subject
      )
      if data[subject].nunique() < 3:
          raise ValueError(
              "rm_corr requires at least 3 unique subjects."
          )
  
      # Remove missing values
      data = data[[x, y, subject]].dropna(axis=0)
  
      # Using PINGOUIN
      # For max precision, make sure rounding is disabled
      old_options = options.copy()
      options["round"] = None
      aov = ancova(dv=y, covar=x, between=subject, data=data)
      options.update(old_options)  # restore options
      bw = aov.bw_  # Beta within parameter
      sign = np.sign(bw)
      dof = int(aov.at[2, "DF"])
      n = dof + 2
      ssfactor = aov.at[1, "SS"]
      sserror = aov.at[2, "SS"]
      rm = sign * np.sqrt(ssfactor / (ssfactor + sserror))
      pval = aov.at[1, "p-unc"]
      ci = compute_esci(stat=rm, nx=n, eftype="pearson").tolist()
      pwr = power_corr(r=rm, n=n, alternative="two-sided")
      # Convert to Dataframe
      stats = pd.DataFrame(
          {
              "r": rm,
              "dof": int(dof),
              "pval": pval,
              "CI95%": [ci],
              "power": pwr,
          },
          index=["rm_corr"],
      )
      return _postprocess_dataframe(stats)
  
imports: import warnings
  import numpy
  import pandas
  import pandas_flavor
  from scipy.spatial.distance import pdist, squareform
  from scipy.stats import pearsonr, spearmanr, kendalltau
  from pingouin.config import options
  from pingouin.power import power_corr
  from pingouin.multicomp import multicomp
  from pingouin.effsize import compute_esci
  from pingouin.utils import remove_na, _perm_pval, _postprocess_dataframe
  from pingouin.bayesian import bayesfactor_pearson
label_desc: Use image node_id 11 for calling a global function with example usage: rm_corr(data, x, y, subject) and returns: _postprocess_dataframe