Exemple #1
0
def test_rq_predict_is_length():
    """
	Tests that the prediction IS dataframe length is equal to the number of steps h
	"""
    model = pf.GPNARX(data=data, ar=2, kernel=pf.RationalQuadratic())
    x = model.fit()
    assert (model.predict_is(h=5).shape[0] == 5)
Exemple #2
0
def test_rq_predict_nans():
    """
	Tests that the predictions are not nans
	"""
    model = pf.GPNARX(data=data, ar=2, kernel=pf.RationalQuadratic())
    x = model.fit()
    x.summary()
    assert (len(
        model.predict(h=5).values[np.isnan(model.predict(h=5).values)]) == 0)
Exemple #3
0
def test_rq_pml():
    """
	Tests a PML model estimated with Laplace approximation and that the length of the 
	latent variable list is correct, and that the estimated latent variables are not nan
	"""
    model = pf.GPNARX(data=data, ar=1, kernel=pf.RationalQuadratic())
    x = model.fit('PML')
    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)
Exemple #4
0
def test_rq_mh():
    """
	Tests an GPNARX model estimated with Metropolis-Hastings and that the length of the 
	latent variable list is correct, and that the estimated latent variables are not nan
	"""
    model = pf.GPNARX(data=data, ar=1, kernel=pf.RationalQuadratic())
    x = model.fit('M-H', nsims=300)
    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)
Exemple #5
0
def test_rq_bbvi():
    """
	Tests an GPNARX model estimated with BBVI and that the length of the latent variable
	list is correct, and that the estimated latent variables are not nan
	"""
    model = pf.GPNARX(data=data, ar=1, kernel=pf.RationalQuadratic())
    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)
Exemple #6
0
def test_rq_couple_terms_integ():
    """
	Tests an GPNARX model with 1 AR term, integrated once, and that
	the latent variable list length is correct, and that the estimated
	latent variables are not nan
	"""
    model = pf.GPNARX(data=data, ar=1, integ=1, kernel=pf.RationalQuadratic())
    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)