Esempio n. 1
0
def test_ou_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.OrnsteinUhlenbeck())
    x = model.fit()
    assert (model.predict_is(h=5).shape[0] == 5)
Esempio n. 2
0
def test_ou_predict_nans():
    """
	Tests that the predictions are not nans
	"""
    model = pf.GPNARX(data=data, ar=2, kernel=pf.OrnsteinUhlenbeck())
    x = model.fit()
    x.summary()
    assert (len(
        model.predict(h=5).values[np.isnan(model.predict(h=5).values)]) == 0)
Esempio n. 3
0
def test_ou_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.OrnsteinUhlenbeck())
    x = model.fit('PML')
    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)
Esempio n. 4
0
def test_ou_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.OrnsteinUhlenbeck())
    x = model.fit('M-H', nsims=300)
    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)
Esempio n. 5
0
def test_ou_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.OrnsteinUhlenbeck())
    x = model.fit('BBVI', iterations=100)
    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)
Esempio n. 6
0
def test_ou_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.OrnsteinUhlenbeck())
    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)