Esempio n. 1
0
    def test_mantel_test_two_sided(self):
        """Test two-sided mantel test."""
        # This test output was verified by R (their mantel function does a
        # one-sided greater test, but I modified their output to do a two-sided
        # test).
        m1 = np.array([[0, 1, 2], [1, 0, 3], [2, 3, 0]])
        m2 = np.array([[0, 2, 7], [2, 0, 6], [7, 6, 0]])
        m3 = np.array([[0, 0.5, 0.25], [0.5, 0, 0.1], [0.25, 0.1, 0]])
        p, stat, perms = mantel_t(m1, m1, 999, alt='two sided')
        np.testing.assert_allclose(stat, 1.0)
        self.assertEqual(len(perms), 999)
        self.assertCorrectPValue(0.20, 0.45, mantel_t, (m1, m1, 999),
                                 {'alt': 'two sided'})

        p, stat, perms = mantel_t(m1, m2, 999, alt='two sided')
        np.testing.assert_allclose(stat, 0.755928946018)
        self.assertEqual(len(perms), 999)
        self.assertCorrectPValue(0.6, 0.75, mantel_t, (m1, m2, 999),
                                 {'alt': 'two sided'})

        p, stat, perms = mantel_t(m1, m3, 999, alt='two sided')
        np.testing.assert_allclose(stat, -0.989743318611)
        self.assertEqual(len(perms), 999)
        self.assertCorrectPValue(0.2, 0.45, mantel_t, (m1, m3, 999),
                                 {'alt': 'two sided'})
Esempio n. 2
0
    def test_mantel_test_two_sided(self):
        """Test two-sided mantel test."""
        # This test output was verified by R (their mantel function does a
        # one-sided greater test, but I modified their output to do a two-sided
        # test).
        m1 = np.array([[0, 1, 2], [1, 0, 3], [2, 3, 0]])
        m2 = np.array([[0, 2, 7], [2, 0, 6], [7, 6, 0]])
        m3 = np.array([[0, 0.5, 0.25], [0.5, 0, 0.1], [0.25, 0.1, 0]])
        p, stat, perms = mantel_t(m1, m1, 999, alt='two sided')
        np.testing.assert_allclose(stat, 1.0)
        self.assertEqual(len(perms), 999)
        self.assertCorrectPValue(0.20, 0.45, mantel_t, (m1, m1, 999),
                                 {'alt': 'two sided'})

        p, stat, perms = mantel_t(m1, m2, 999, alt='two sided')
        np.testing.assert_allclose(stat, 0.755928946018)
        self.assertEqual(len(perms), 999)
        self.assertCorrectPValue(0.6, 0.75, mantel_t, (m1, m2, 999),
                                 {'alt': 'two sided'})

        p, stat, perms = mantel_t(m1, m3, 999, alt='two sided')
        np.testing.assert_allclose(stat, -0.989743318611)
        self.assertEqual(len(perms), 999)
        self.assertCorrectPValue(0.2, 0.45, mantel_t, (m1, m3, 999),
                                 {'alt': 'two sided'})
Esempio n. 3
0
    def test_mantel_test_one_sided_greater(self):
        """Test one-sided mantel test (greater)."""
        # This test output was verified by R (their mantel function does a
        # one-sided greater test).
        m1 = np.array([[0, 1, 2], [1, 0, 3], [2, 3, 0]])
        m2 = np.array([[0, 2, 7], [2, 0, 6], [7, 6, 0]])
        p, stat, perms = mantel_t(m1, m1, 999, alt='greater')
        np.testing.assert_allclose(stat, 1.0)
        self.assertEqual(len(perms), 999)

        self.assertCorrectPValue(0.09, 0.25, mantel_t, (m1, m1, 999),
                                 {'alt': 'greater'})

        p, stat, perms = mantel_t(m1, m2, 999, alt='greater')
        np.testing.assert_allclose(stat, 0.755928946018)
        self.assertEqual(len(perms), 999)
        self.assertCorrectPValue(0.2, 0.5, mantel_t, (m1, m2, 999),
                                 {'alt': 'greater'})
Esempio n. 4
0
    def test_mantel_test_one_sided_greater(self):
        """Test one-sided mantel test (greater)."""
        # This test output was verified by R (their mantel function does a
        # one-sided greater test).
        m1 = np.array([[0, 1, 2], [1, 0, 3], [2, 3, 0]])
        m2 = np.array([[0, 2, 7], [2, 0, 6], [7, 6, 0]])
        p, stat, perms = mantel_t(m1, m1, 999, alt='greater')
        np.testing.assert_allclose(stat, 1.0)
        self.assertEqual(len(perms), 999)

        self.assertCorrectPValue(0.09, 0.25, mantel_t, (m1, m1, 999),
                                 {'alt': 'greater'})

        p, stat, perms = mantel_t(m1, m2, 999, alt='greater')
        np.testing.assert_allclose(stat, 0.755928946018)
        self.assertEqual(len(perms), 999)
        self.assertCorrectPValue(0.2, 0.5, mantel_t, (m1, m2, 999),
                                 {'alt': 'greater'})