code: def test_pca_svd():
      xreduced, factors, evals, evecs = pca(xf)
      factors_wconst = np.c_[factors, np.ones((factors.shape[0], 1))]
      beta = np.dot(np.linalg.pinv(factors_wconst), xf)
      # np.dot(np.linalg.pinv(factors_wconst),x2/1000.).T[:,:4] - evecs
      assert_array_almost_equal(beta.T[:, :4], evecs, 14)
  
      xred_svd, factors_svd, evals_svd, evecs_svd = pcasvd(
          xf, keepdim=0
      )
      assert_array_almost_equal(evals_svd, evals, 14)
      msign = (evecs / evecs_svd)[0]
      assert_array_almost_equal(msign * evecs_svd, evecs, 13)
      assert_array_almost_equal(msign * factors_svd, factors, 12)
      assert_array_almost_equal(xred_svd, xreduced, 13)
  
      pcares = pca(xf, keepdim=2)
      pcasvdres = pcasvd(xf, keepdim=2)
      check_pca_svd(pcares, pcasvdres)
  
file_path: statsmodels/statsmodels/sandbox/tests/test_pca.py
imports: import numpy
  from numpy.testing import assert_array_almost_equal
  from statsmodels.sandbox.tools import pca, pcasvd
  from statsmodels.multivariate.tests.results.datamlw import princomp1, princomp2, princomp3, data
label_desc: Use image node_id 4 for calling a global function with example usage: test_pca_svd() without return types