Exemplo n.º 1
0
def test_approx_perm_test_with_n_based_estimator(dataset_n):
    """Test the approximate permutation test on an sample size-based Estimator."""
    results = SampleSizeBasedLikelihoodEstimator().fit_dataset(
        dataset_n).summary()
    pmr = results.permutation_test(100)
    assert pmr.n_perm == 100
    assert not pmr.exact
    assert isinstance(pmr.results, MetaRegressionResults)
    assert pmr.perm_p["fe_p"].shape == (1, 1)
    assert pmr.perm_p["tau2_p"].shape == (1, )
Exemplo n.º 2
0
def test_sample_size_based_maximum_likelihood_estimator(dataset_n):
    # test values have not been verified for convergence with other packages
    est = SampleSizeBasedLikelihoodEstimator(method='ML').fit(dataset_n)
    results = est.summary()
    beta = results.fe_params
    sigma2 = results.estimator.params_['sigma2']
    tau2 = results.tau2
    assert np.allclose(beta, [-2.0951], atol=1e-4)
    assert np.allclose(sigma2, 12.777, atol=1e-3)
    assert np.allclose(tau2, 2.8268, atol=1e-4)
Exemplo n.º 3
0
def test_sample_size_based_restricted_maximum_likelihood_estimator(dataset_n):
    """Test SampleSizeBasedLikelihoodEstimator REML estimator."""
    # test values have not been verified for convergence with other packages
    est = SampleSizeBasedLikelihoodEstimator(
        method="REML").fit_dataset(dataset_n)
    results = est.summary()
    beta = results.fe_params
    sigma2 = results.estimator.params_["sigma2"]
    tau2 = results.tau2
    assert np.allclose(beta, [-2.1071], atol=1e-4)
    assert np.allclose(sigma2, 13.048, atol=1e-3)
    assert np.allclose(tau2, 3.2177, atol=1e-4)
Exemplo n.º 4
0
def test_approx_perm_test_with_n_based_estimator(dataset_n):
    results = SampleSizeBasedLikelihoodEstimator().fit(dataset_n).summary()
    pmr = permutation_test(results, 100)
    assert pmr.n_perm == 100
    assert not pmr.exact
    assert isinstance(pmr.results, MetaRegressionResults)
    assert pmr.fe_p.shape == (1, 1)
    assert pmr.tau2_p.shape == (1, )
Exemplo n.º 5
0
def test_sample_size_based_restricted_maximum_likelihood_estimator(dataset_n):
    # test values have not been verified for convergence with other packages
    results = SampleSizeBasedLikelihoodEstimator(method='REML').fit(dataset_n)
    beta = results['beta']['est']
    sigma2 = results['sigma2']['est']
    tau2 = results['tau2']['est']
    assert np.allclose(beta, [-2.1071], atol=1e-4)
    assert np.allclose(sigma2, 13.048, atol=1e-4)
    assert np.allclose(tau2, 3.2177, atol=1e-4)