예제 #1
0
def test_poisson_bbvi():
    """
	Tests an GASX model estimated with BBVI, and tests that the latent variable
	vector length is correct, and that value are not nan
	"""
    model = pf.GASX(formula="y ~ x1",
                    data=data,
                    ar=1,
                    sc=1,
                    family=pf.GASPoisson())
    x = model.fit('BBVI', iterations=100)
    assert (len(model.latent_variables.z_list) == 4)
    lvs = np.array([i.value for i in model.latent_variables.z_list])
    assert (len(lvs[np.isnan(lvs)]) == 0)
예제 #2
0
def test_poisson_couple_terms():
    """
	Tests the length of the latent variable vector for an GASX model
	with 1 AR and 1 MA term, and tests that the values are not nan
	"""
    model = pf.GASX(formula="y ~ x1",
                    data=data,
                    ar=1,
                    sc=1,
                    family=pf.GASPoisson())
    x = model.fit()
    assert (len(model.latent_variables.z_list) == 4)
    lvs = np.array([i.value for i in model.latent_variables.z_list])
    assert (len(lvs[np.isnan(lvs)]) == 0)
예제 #3
0
def test2_poisson_predict_is_nans():
    """
	Tests that the predictions in-sample are not NaNs
	"""
    model = pf.GASX(formula="y ~ x1 + x2",
                    data=data,
                    ar=1,
                    sc=1,
                    family=pf.GASPoisson())
    x = model.fit()
    x.summary()
    assert (len(
        model.predict_is(h=5).values[np.isnan(
            model.predict_is(h=5).values)]) == 0)
예제 #4
0
def test2_poisson_pml():
    """
	Tests an GASX model estimated with PML, with multiple predictors, and 
	tests that the latent variable vector length is correct, and that value are not nan
	"""
    model = pf.GASX(formula="y ~ x1 + x2",
                    data=data,
                    ar=1,
                    sc=1,
                    family=pf.GASPoisson())
    x = model.fit('PML')
    assert (len(model.latent_variables.z_list) == 5)
    lvs = np.array([i.value for i in model.latent_variables.z_list])
    assert (len(lvs[np.isnan(lvs)]) == 0)
예제 #5
0
def test_poisson_predict_nans():
    """
	Tests that the predictions are not NaNs
	"""
    model = pf.GASX(formula="y ~ x1",
                    data=data,
                    ar=1,
                    sc=1,
                    family=pf.GASPoisson())
    x = model.fit()
    x.summary()
    assert (len(
        model.predict(h=5, oos_data=data_oos).values[np.isnan(
            model.predict(h=5, oos_data=data_oos).values)]) == 0)
예제 #6
0
def test2_poisson_no_terms():
    """
	Tests the length of the latent variable vector for an GASX model
	with no AR or MA terms, and two predictors, and tests that the values 
	are not nan
	"""
    model = pf.GASX(formula="y ~ x1 + x2",
                    data=data,
                    ar=0,
                    sc=0,
                    family=pf.GASPoisson())
    x = model.fit()
    assert (len(model.latent_variables.z_list) == 3)
    lvs = np.array([i.value for i in model.latent_variables.z_list])
    assert (len(lvs[np.isnan(lvs)]) == 0)