Beispiel #1
0
    def test_aicc_methods(self):
        np.random.seed(12345)
        simulated_arma = simulate_arma(phi=[0.2, 0.5], theta=[0.2], simulations=50)
        arma = ARMA(simulated_arma)
        arma_model = PureARMA(phi=[0.2, 0.5], theta=[0.2], sigma_sq=0.25)

        aicc_kalman = arma.get_aicc(model=arma_model, method="kalman")
        aicc_innovations = arma.get_aicc(model=arma_model, method="innovations_algo")

        # test <0.5% difference between methods
        self.assertTrue(abs(aicc_innovations - aicc_kalman) / aicc_innovations < 0.005)
Beispiel #2
0
    def test_aicc_innovation(self):
        model_arma11 = PureARMA([0.2], [0.4], sigma_sq=1)
        zeros = np.zeros(6)
        non_zeros = [0, 0, 0, 0, 0, 1]
        zero_ts = ARMA(zeros)
        non_zero_ts = ARMA(non_zeros, subtract_mean=False)

        loglikelihood_zeros = np.log((2 * np.pi) ** -3 * (1.375 * 1.0436 * 1.0067 * 1.0011 * 1.0002) ** -0.5)
        loglikelihood_non_zeros = np.log(np.exp(-0.5 * (1 / 1.0002))) + loglikelihood_zeros

        aicc_zeros = -2 * loglikelihood_zeros + 18
        aicc_nonzeros = -2 * loglikelihood_non_zeros + 18

        self.assertAlmostEqual(zero_ts.get_aicc(model_arma11, method="innovations_algo"), aicc_zeros, 4)
        self.assertAlmostEqual(non_zero_ts.get_aicc(model_arma11, method="innovations_algo"), aicc_nonzeros, 3)