Beispiel #1
0
def test2_skewt_predict_is_length():
	"""
	Tests that the length of the predict IS dataframe is equal to no of steps h
	"""
	model = pf.GASX(formula="y ~ x1 + x2", data=data, ar=1, sc=1, family=pf.GASSkewt())
	x = model.fit()
	assert(model.predict_is(h=5).shape[0] == 5)
def test_skewt_predict_is_length():
	"""
	Tests that the prediction IS dataframe length is equal to the number of steps h
	"""
	model = pf.GASLLT(data=data, family=pf.GASSkewt())
	x = model.fit()
	assert(model.predict_is(h=5).shape[0] == 5)
Beispiel #3
0
def test_skewt_predict_length():
    """
	Tests that the length of the predict dataframe is equal to no of steps h
	"""
    model = pf.GASReg(formula="y ~ x1", data=data, family=pf.GASSkewt())
    x = model.fit()
    x.summary()
    assert (model.predict(h=5, oos_data=data_oos).shape[0] == 5)
Beispiel #4
0
def test_skewt_predict_is_nans():
	"""
	Tests that the in-sample predictions are not nans
	"""
	model = pf.GAS(data=data, ar=1, sc=1, family=pf.GASSkewt())
	x = model.fit()
	x.summary()
	assert(len(model.predict_is(h=5).values[np.isnan(model.predict_is(h=5).values)]) == 0)
Beispiel #5
0
def test_skewt_predict_length():
	"""
	Tests that the prediction dataframe length is equal to the number of steps h
	"""
	model = pf.GAS(data=data, ar=1, sc=1, family=pf.GASSkewt())
	x = model.fit()
	x.summary()
	assert(model.predict(h=5).shape[0] == 5)
def test_skewt_predict_nans():
	"""
	Tests that the predictions are not nans
	model = pf.GASLLT(data=data, family=pf.GASSkewt())
	"""
	model = pf.GASLLT(data=data, family=pf.GASSkewt())
	x = model.fit()
	x.summary()
	assert(len(model.predict(h=5).values[np.isnan(model.predict(h=5).values)]) == 0)
def test_skewt_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.GASLLT(data=data, family=pf.GASSkewt())
	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)
def test_skewt_mh():
	"""
	Tests an GAS 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.GASLLT(data=data, family=pf.GASSkewt())
	x = model.fit('M-H',nsims=300)
	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)
def test_skewt_bbvi():
	"""
	Tests an GAS 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.GASLLT(data=data, family=pf.GASSkewt())
	x = model.fit('BBVI',iterations=100)
	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)
def test_skewt_couple_terms_integ():
	"""
	Tests latent variable list length is correct, and that the estimated
	latent variables are not nan
	"""
	model = pf.GASLLT(data=data, integ=1, family=pf.GASSkewt())
	x = model.fit()
	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)
Beispiel #11
0
def test_skewt_pml():
	"""
	Tests an GASX model estimated with PML, 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.GASSkewt())
	x = model.fit('PML')
	assert(len(model.latent_variables.z_list) == 7)
	lvs = np.array([i.value for i in model.latent_variables.z_list])
	assert(len(lvs[np.isnan(lvs)]) == 0)
Beispiel #12
0
def test_skewt_no_terms():
	"""
	Tests the length of the latent variable vector for an GASX model
	with no AR or MA terms, and tests that the values are not nan
	"""
	model = pf.GASX(formula="y ~ x1", data=data, ar=0, sc=0, family=pf.GASSkewt())
	x = model.fit()
	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)
Beispiel #13
0
def test2_skewt_mh():
	"""
	Tests an GASX model estimated with MEtropolis-Hastings, 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.GASSkewt())
	x = model.fit('M-H',nsims=300)
	assert(len(model.latent_variables.z_list) == 8)
	lvs = np.array([i.value for i in model.latent_variables.z_list])
	assert(len(lvs[np.isnan(lvs)]) == 0)
Beispiel #14
0
def test2_skewt_bbvi():
	"""
	Tests an GASX model estimated with BBVI, 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.GASSkewt())
	x = model.fit('BBVI',iterations=100)
	assert(len(model.latent_variables.z_list) == 8)
	lvs = np.array([i.value for i in model.latent_variables.z_list])
	assert(len(lvs[np.isnan(lvs)]) == 0)
Beispiel #15
0
def test_skewt_couple_terms_integ():
	"""
	Tests an GAS model with 1 AR and 1 MA term, integrated once, and that
	the latent variable list length is correct, and that the estimated
	latent variables are not nan
	"""
	model = pf.GAS(data=data, ar=1, sc=1, integ=1, family=pf.GASSkewt())
	x = model.fit()
	assert(len(model.latent_variables.z_list) == 6)
	lvs = np.array([i.value for i in model.latent_variables.z_list])
	assert(len(lvs[np.isnan(lvs)]) == 0)
Beispiel #16
0
def test_skewt_couple_terms_integ():
	"""
	Tests the length of the latent variable vector for an GASX model
	with 1 AR and 1 MA term and integrated once, and tests that the 
	values are not nan
	"""
	model = pf.GASX(formula="y ~ x1", data=data, ar=1, sc=1, integ=1, family=pf.GASSkewt())
	x = model.fit()
	assert(len(model.latent_variables.z_list) == 7)
	lvs = np.array([i.value for i in model.latent_variables.z_list])
	assert(len(lvs[np.isnan(lvs)]) == 0)
Beispiel #17
0
def test_skewt_no_terms():
	"""
	Tests an GAS model with no AR or MA terms, and that
	the latent variable list length is correct, and that the estimated
	latent variables are not nan
	"""
	model = pf.GAS(data=data, ar=0, sc=0, family=pf.GASSkewt())
	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)
Beispiel #18
0
def test2_skewt_couple_terms():
	"""
	Tests the length of the latent variable vector for an GASX model
	with 1 AR and 1 SC term, and two predictors, and tests that the values 
	are not nan
	"""
	model = pf.GASX(formula="y ~ x1 + x2", data=data, ar=1, sc=1, family=pf.GASSkewt())
	x = model.fit()
	assert(len(model.latent_variables.z_list) == 8)
	lvs = np.array([i.value for i in model.latent_variables.z_list])
	assert(len(lvs[np.isnan(lvs)]) == 0)
Beispiel #19
0
def test_skew_t_model_fit():
	model = pf.GASX(formula="y ~ x1", data=data, ar=1, sc=1, family=pf.GASSkewt())
	x = model.fit()
Beispiel #20
0
x2 = np.random.normal(0,1,400)

for i in range(1,len(y)):
	y[i] = 0.9*y[i-1] + noise[i] + 0.1*x1[i] - 0.3*x2[i]

data = pd.DataFrame([y,x1,x2]).T
data.columns = ['y', 'x1', 'x2']

y_oos = np.random.normal(0,1,30)
x1_oos = np.random.normal(0,1,30)
x2_oos = np.random.normal(0,1,30)

data_oos = pd.DataFrame([y_oos,x1_oos,x2_oos]).T
data_oos.columns = ['y', 'x1', 'x2']

example_model = pf.GASX(formula="y ~ x1", data=data, ar=1, sc=1, family=pf.GASSkewt())
x = example_model.fit()


def test_skewt_no_terms():
	"""
	Tests the length of the latent variable vector for an GASX model
	with no AR or MA terms, and tests that the values are not nan
	"""
	model = pf.GASX(formula="y ~ x1", data=data, ar=0, sc=0, family=pf.GASSkewt())
	x = model.fit()
	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)

def test_skew_t_model_fit():