def test_doubleml_cluster_not_yet_implemented():
    dml_pliv_cluster = DoubleMLPLIV(dml_cluster_data_pliv, ml_g, ml_m, ml_r)
    dml_pliv_cluster.fit()
    msg = 'bootstrap not yet implemented with clustering.'
    with pytest.raises(NotImplementedError, match=msg):
        _ = dml_pliv_cluster.bootstrap()

    smpls = dml_plr.smpls
    msg = ('Externally setting the sample splitting for DoubleML is '
           'not yet implemented with clustering.')
    with pytest.raises(NotImplementedError, match=msg):
        _ = dml_pliv_cluster.set_sample_splitting(smpls)

    df = dml_cluster_data_pliv.data.copy()
    df['cluster_var_k'] = df['cluster_var_i'] + df['cluster_var_j'] - 2
    dml_cluster_data_multiway = DoubleMLClusterData(df, y_col='Y', d_cols='D', x_cols=['X1', 'X5'], z_cols='Z',
                                                    cluster_cols=['cluster_var_i', 'cluster_var_j', 'cluster_var_k'])
    assert dml_cluster_data_multiway.n_cluster_vars == 3
    msg = r'Multi-way \(n_ways > 2\) clustering not yet implemented.'
    with pytest.raises(NotImplementedError, match=msg):
        _ = DoubleMLPLIV(dml_cluster_data_multiway, ml_g, ml_m, ml_r)

    msg = (r'No cross-fitting \(`apply_cross_fitting = False`\) '
           'is not yet implemented with clustering.')
    with pytest.raises(NotImplementedError, match=msg):
        _ = DoubleMLPLIV(dml_cluster_data_pliv, ml_g, ml_m, ml_r,
                         n_folds=1)
    with pytest.raises(NotImplementedError, match=msg):
        _ = DoubleMLPLIV(dml_cluster_data_pliv, ml_g, ml_m, ml_r,
                         apply_cross_fitting=False, n_folds=2)
Example #2
0
                       Lasso(),
                       dml_procedure='dml1',
                       n_rep=n_rep,
                       n_folds=n_folds)
plr_dml1.fit()
plr_dml1.bootstrap(n_rep_boot=n_rep_boot)

pliv_dml1 = DoubleMLPLIV(dml_data_pliv,
                         Lasso(),
                         Lasso(),
                         Lasso(),
                         dml_procedure='dml1',
                         n_rep=n_rep,
                         n_folds=n_folds)
pliv_dml1.fit()
pliv_dml1.bootstrap(n_rep_boot=n_rep_boot)

irm_dml1 = DoubleMLIRM(dml_data_irm,
                       Lasso(),
                       LogisticRegression(),
                       dml_procedure='dml1',
                       n_rep=n_rep,
                       n_folds=n_folds)
irm_dml1.fit()
irm_dml1.bootstrap(n_rep_boot=n_rep_boot)

iivm_dml1 = DoubleMLIIVM(dml_data_iivm,
                         Lasso(),
                         LogisticRegression(),
                         LogisticRegression(),
                         dml_procedure='dml1',