code: def test_example_compare_to_R_output():
      # Testing basic functions and compare to R output
  
      # R code for producing the results:
      # library(psych)
      # library(GPArotation)
      # Basal = c(2.068,	2.068,	2.09,	2.097,	2.117,	2.14,	2.045,	2.076,	2.09,	2.111,	2.093,	2.1,	2.104)
      # Occ = c(2.07,	2.074,	2.09,	2.093,	2.125,	2.146,	2.054,	2.088,	2.093,	2.114,	2.098,	2.106,	2.101)
      # Max = c(1.58,	1.602,	1.613,	1.613,	1.663,	1.681,	1.58,	1.602,	1.643,	1.643,	1.653,	1.623,	1.653)
      # id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
      # Y <- cbind(Basal, Occ, Max, id)
      # a <- fa(Y, nfactors=2, fm="pa", rotate="none", SMC=FALSE, min.err=1e-10)
      # b <- cbind(a$loadings[,1], -a$loadings[,2])
      # b
      # a <- fa(Y, nfactors=2, fm="pa", rotate="Promax", SMC=TRUE, min.err=1e-10)
      # b <- cbind(a$loadings[,1], a$loadings[,2])
      # b
      # a <- fa(Y, nfactors=2, fm="pa", rotate="Varimax", SMC=TRUE, min.err=1e-10)
      # b <- cbind(a$loadings[,1], a$loadings[,2])
      # b
      # a <- fa(Y, nfactors=2, fm="pa", rotate="quartimax", SMC=TRUE, min.err=1e-10)
      # b <- cbind(a$loadings[,1], -a$loadings[,2])
      # b
      # a <- fa(Y, nfactors=2, fm="pa", rotate="oblimin", SMC=TRUE, min.err=1e-10)
      # b <- cbind(a$loadings[,1], a$loadings[,2])
      # b
  
      # No rotation without squared multiple correlations prior
      # produce same results as in R `fa`
      mod = Factor(X.iloc[:, 1:-1], 2, smc=False)
      results = mod.fit(tol=1e-10)
      a = np.array(
          [
              [0.965392158864, 0.225880658666255],
              [0.967587154301, 0.212758741910989],
              [0.929891035996, -0.000603217967568],
              [0.486822656362, -0.869649573289374],
          ]
      )
      assert_array_almost_equal(results.loadings, a, decimal=8)
  
      # No rotation WITH squared multiple correlations prior
      # produce same results as in R `fa`
      mod = Factor(X.iloc[:, 1:-1], 2, smc=True)
      results = mod.fit()
      a = np.array(
          [
              [0.97541115, 0.20280987],
              [0.97113975, 0.17207499],
              [0.9618705, -0.2004196],
              [0.37570708, -0.45821379],
          ]
      )
      assert_array_almost_equal(results.loadings, a, decimal=8)
  
      # Same as R GRArotation
      results.rotate("varimax")
      a = np.array(
          [
              [0.98828898, -0.12587155],
              [0.97424206, -0.15354033],
              [0.84418097, -0.502714],
              [0.20601929, -0.55558235],
          ]
      )
      assert_array_almost_equal(results.loadings, a, decimal=8)
  
      results.rotate("quartimax")  # Same as R fa
      a = np.array(
          [
              [0.98935598, 0.98242714, 0.94078972, 0.33442284],
              [0.117190049, 0.086943252, -0.283332952, -0.489159543],
          ]
      )
      assert_array_almost_equal(results.loadings, a.T, decimal=8)
  
      results.rotate("equamax")  # Not the same as R fa
  
      results.rotate("promax")  # Not the same as R fa
  
      results.rotate("biquartimin")  # Not the same as R fa
  
      results.rotate("oblimin")  # Same as R fa
      a = np.array(
          [
              [
                  1.02834170170,
                  1.00178840104,
                  0.71824931384,
                  -0.00013510048,
              ],
              [0.06563421, 0.03096076, -0.39658839, -0.59261944],
          ]
      )
      assert_array_almost_equal(results.loadings, a.T, decimal=8)
  
      # Testing result summary string
      results.rotate("varimax")
      desired = """   Factor analysis results
  =============================
        Eigenvalues
  -----------------------------
   Basal   Occ    Max      id
  -----------------------------
   2.9609 0.3209 0.0000 -0.0000
  -----------------------------
  
  -----------------------------
        Communality
  -----------------------------
    Basal   Occ    Max     id
  -----------------------------
    0.9926 0.9727 0.9654 0.3511
  -----------------------------
  
  -----------------------------
     Pre-rotated loadings
  -----------------------------------
              factor 0       factor 1
  -----------------------------------
  Basal         0.9754         0.2028
  Occ           0.9711         0.1721
  Max           0.9619        -0.2004
  id            0.3757        -0.4582
  -----------------------------
  
  -----------------------------
     varimax rotated loadings
  -----------------------------------
              factor 0       factor 1
  -----------------------------------
  Basal         0.9883        -0.1259
  Occ           0.9742        -0.1535
  Max           0.8442        -0.5027
  id            0.2060        -0.5556
  =============================
  """
      actual = results.summary().as_text()
      actual = (
          "\n".join(line.rstrip() for line in actual.splitlines())
          + "\n"
      )
      assert_equal(actual, desired)
  
file_path: statsmodels/statsmodels/multivariate/tests/test_factor.py
imports: import warnings
  from statsmodels.compat.pandas import PD_LT_1_4
  import os
  import numpy
  import pandas
  from statsmodels.multivariate.factor import Factor
  from numpy.testing import assert_equal, assert_array_almost_equal, assert_, assert_raises, assert_array_equal, assert_array_less, assert_allclose
  import pytest
label_desc: Use image node_id 4 for calling a global function with example usage: test_example_compare_to_R_output() without return types