Example #1
0
def test_resid_dist():
    dv = np.array([1, 2, 3, 4, 5])
    # residualizing against self should yield 0
    assert np.allclose(correct._resid_dist(dv, iv=dv), 0)
    # residualizing against perfectly anticorrelated should also yield 0
    assert np.allclose(correct._resid_dist(dv, iv=dv[::-1]), 0)
    # residualizing against scaled self should also yield 0 (intercept incl)
    assert np.allclose(correct._resid_dist(dv, iv=(dv + 10)), 0)
    # residualizing against constant should yield de-meaned input
    assert np.allclose(correct._resid_dist(dv, iv=np.ones_like(dv)),
                       dv - dv.mean())
Example #2
0
def test_resid_dist(dv, independent, expected):
    """
    residualizing against self should yield 0
    residualizing against perfectly anticorrelated should also yield 0
    residualizing against scaled self should also yield 0 (intercept incl)
    residualizing against constant should yield de-meaned input
    """
    assert np.allclose(correct._resid_dist(dv, iv=eval(independent)),
                       eval(expected))