Пример #1
0
def test_limited_redundancy():
    data = generate_data(0,
                         datatype="numpy",
                         const=False,
                         other_effects=1,
                         ntk=(25, 200, 5))
    for i in range(0, data.x.shape[1], 7):
        data.x[1, i, :] = data.x[0, i, :]
    mod = FamaMacBeth(data.y, data.x)
    res = mod.fit()
    assert np.any(np.isnan(res.all_params))
Пример #2
0
def test_fitted_effects_residuals(data):
    mod = FamaMacBeth(data.y, data.x)
    res = mod.fit()

    expected = mod.exog.values2d @ res.params.values
    expected = pd.DataFrame(expected,
                            index=mod.exog.index,
                            columns=['fitted_values'])
    assert_allclose(res.fitted_values, expected)
    assert_frame_similar(res.fitted_values, expected)

    expected.iloc[:, 0] = mod.dependent.values2d - expected.values
    expected.columns = ['idiosyncratic']
    assert_allclose(res.idiosyncratic, expected)
    assert_frame_similar(res.idiosyncratic, expected)

    expected.iloc[:, 0] = np.nan
    expected.columns = ['estimated_effects']
    assert_allclose(res.estimated_effects, expected)
    assert_frame_similar(res.estimated_effects, expected)