def test_standardize_and_filter(self):
     model = ARGARCHModel(40.0, 0.4, 0.2, 0.3, 0.4, sc=self.sc)
     n = 10000
     ts = np.array(model.sample(n))
     
     # de-heteroskedasticize
     standardized = model.remove_time_dependent_effects(ts)
     filtered = model.add_time_dependent_effects(standardized)
     for i in range(len(filtered)):
         self.assertAlmostEquals(filtered[i], ts[i], msg="%f != %f at index %d" % (filtered[i], ts[i], i))
    def test_standardize_and_filter(self):
        model = ARGARCHModel(40.0, 0.4, 0.2, 0.3, 0.4, sc=self.sc)
        n = 10000
        ts = np.array(model.sample(n))

        # de-heteroskedasticize
        standardized = model.remove_time_dependent_effects(ts)
        filtered = model.add_time_dependent_effects(standardized)
        for i in range(len(filtered)):
            self.assertAlmostEquals(filtered[i],
                                    ts[i],
                                    msg="%f != %f at index %d" %
                                    (filtered[i], ts[i], i))
    def test_fit_model(self):
        omega = 0.2
        alpha = 0.3
        beta = 0.5
        genModel = ARGARCHModel(0.0, 0.0, alpha, beta, omega, sc=self.sc)

        n = 10000
        ts = np.array(genModel.sample(n))

        model = GARCH.fit_model(ts, sc=self.sc)
        # tolerances are a little bit larger than Scala; not certain why... -pame
        self.assertAlmostEqual(model.omega, omega, delta=0.1)
        self.assertAlmostEqual(model.alpha, alpha, delta=0.1)
        self.assertAlmostEqual(model.beta, beta, delta=0.2)
 def test_fit_model(self):
     omega = 0.2
     alpha = 0.3
     beta = 0.5
     genModel = ARGARCHModel(0.0, 0.0, alpha, beta, omega, sc=self.sc)
     
     n = 10000
     ts = np.array(genModel.sample(n))
     
     model = GARCH.fit_model(ts, sc=self.sc)
     # tolerances are a little bit larger than Scala; not certain why... -pame
     self.assertAlmostEqual(model.omega, omega, delta=0.1)
     self.assertAlmostEqual(model.alpha, alpha, delta=0.1)
     self.assertAlmostEqual(model.beta, beta, delta=0.2)