def test_cochrane_orcutt_stock_data(self):
     """
     ref : http://www.ats.ucla.edu/stat/stata/examples/chp/chpstata8.htm
     data : http://www.ats.ucla.edu/stat/examples/chp/p203.txt
     """
     expenditure = [
         214.6, 217.7, 219.6, 227.2, 230.9, 233.3, 234.1, 232.3, 233.7, 236.5,
         238.7, 243.2, 249.4, 254.3, 260.9, 263.3, 265.6, 268.2, 270.4, 275.6
     ]
     
     stock = [
         159.3, 161.2, 162.8, 164.6, 165.9, 167.9, 168.3, 169.7, 170.5, 171.6,
         173.9, 176.1, 178.0, 179.1, 180.2, 181.2, 181.6, 182.5, 183.3, 184.3
     ]
     
     Y = np.array(expenditure)
     regressors = np.array(stock).reshape(len(stock), 1)
     
     regARIMA = RegressionARIMA.fit_cochrane_orcutt(Y, regressors, 11, sc=self.sc)
     beta = regARIMA.regressionCoeff
     rho = regARIMA.arimaCoeff[0]
     
     self.assertAlmostEqual(rho, 0.8241, delta=0.001)
     self.assertAlmostEqual(beta[0], -235.4889, delta=0.1)
     self.assertAlmostEqual(beta[1], 2.75306, delta=0.001)
Exemplo n.º 2
0
    def test_cochrane_orcutt_stock_data(self):
        """
        ref : http://www.ats.ucla.edu/stat/stata/examples/chp/chpstata8.htm
        data : http://www.ats.ucla.edu/stat/examples/chp/p203.txt
        """
        expenditure = [
            214.6, 217.7, 219.6, 227.2, 230.9, 233.3, 234.1, 232.3, 233.7,
            236.5, 238.7, 243.2, 249.4, 254.3, 260.9, 263.3, 265.6, 268.2,
            270.4, 275.6
        ]

        stock = [
            159.3, 161.2, 162.8, 164.6, 165.9, 167.9, 168.3, 169.7, 170.5,
            171.6, 173.9, 176.1, 178.0, 179.1, 180.2, 181.2, 181.6, 182.5,
            183.3, 184.3
        ]

        Y = np.array(expenditure)
        regressors = np.array(stock).reshape(len(stock), 1)

        regARIMA = RegressionARIMA.fit_cochrane_orcutt(Y,
                                                       regressors,
                                                       11,
                                                       sc=self.sc)
        beta = regARIMA.regressionCoeff
        rho = regARIMA.arimaCoeff[0]

        self.assertAlmostEqual(rho, 0.8241, delta=0.001)
        self.assertAlmostEqual(beta[0], -235.4889, delta=0.1)
        self.assertAlmostEqual(beta[1], 2.75306, delta=0.001)