예제 #1
0
    def test_summary(self):
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            summary = self.results.summary()
        tables = [str(table) for table in summary.tables]
        params = self.true['params']

        # Make sure we have the right number of tables
        assert_equal(len(tables), 2 + self.model.k_endog + self.model.k_factors + 1)

        # Check the model overview table
        assert_equal(re.search(r'Model:.*DynamicFactor\(factors=2, order=1\)', tables[0]) is None, False)

        # For each endogenous variable, check the output
        for i in range(self.model.k_endog):
            offset_loading = self.model.k_factors * i
            offset_var = self.model.k_factors * self.model.k_endog
            table = tables[i + 2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert_equal(re.search('Results for equation %s' % name, table) is None, False)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 7)

            # -> Check that we have the right coefficients
            assert_equal(re.search('loading.f1 +' + forg(params[offset_loading + 0], prec=4), table) is None, False)
            assert_equal(re.search('loading.f2 +' + forg(params[offset_loading + 1], prec=4), table) is None, False)

        # For each factor, check the output
        for i in range(self.model.k_factors):
            offset = self.model.k_endog * (self.model.k_factors + 1) + i * self.model.k_factors
            table = tables[self.model.k_endog + i + 2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert_equal(re.search('Results for factor equation f%d' % (i+1), table) is None, False)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 7)

            # -> Check that we have the right coefficients
            assert_equal(re.search('L1.f1 +' + forg(params[offset + 0], prec=4), table) is None, False)
            assert_equal(re.search('L1.f2 +' + forg(params[offset + 1], prec=4), table) is None, False)

        # Check the Error covariance matrix output
        table = tables[2 + self.model.k_endog + self.model.k_factors]

        # -> Make sure we have the right table / table name
        name = self.model.endog_names[i]
        assert_equal(re.search('Error covariance matrix', table) is None, False)

        # -> Make sure it's the right size
        assert_equal(len(table.split('\n')), 8)

        # -> Check that we have the right coefficients
        offset = self.model.k_endog * self.model.k_factors
        for i in range(self.model.k_endog):
            assert_equal(re.search('sigma2.%s +%s' % (self.model.endog_names[i], forg(params[offset + i], prec=4)), table) is None, False)
예제 #2
0
    def test_summary(self):
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            summary = self.results.summary()
        tables = [str(table) for table in summary.tables]
        params = self.true['params']

        # Make sure we have the right number of tables
        assert_equal(len(tables), 2 + self.model.k_endog + self.model.k_factors + 1)

        # Check the model overview table
        assert_equal(re.search(r'Model:.*DynamicFactor\(factors=2, order=1\)', tables[0]) is None, False)

        # For each endogenous variable, check the output
        for i in range(self.model.k_endog):
            offset_loading = self.model.k_factors * i
            offset_var = self.model.k_factors * self.model.k_endog
            table = tables[i + 2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert_equal(re.search('Results for equation %s' % name, table) is None, False)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 7)

            # -> Check that we have the right coefficients
            assert_equal(re.search('loading.f1 +' + forg(params[offset_loading + 0], prec=4), table) is None, False)
            assert_equal(re.search('loading.f2 +' + forg(params[offset_loading + 1], prec=4), table) is None, False)

        # For each factor, check the output
        for i in range(self.model.k_factors):
            offset = self.model.k_endog * (self.model.k_factors + 1) + i * self.model.k_factors
            table = tables[self.model.k_endog + i + 2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert_equal(re.search('Results for factor equation f%d' % (i+1), table) is None, False)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 7)

            # -> Check that we have the right coefficients
            assert_equal(re.search('L1.f1 +' + forg(params[offset + 0], prec=4), table) is None, False)
            assert_equal(re.search('L1.f2 +' + forg(params[offset + 1], prec=4), table) is None, False)

        # Check the Error covariance matrix output
        table = tables[2 + self.model.k_endog + self.model.k_factors]

        # -> Make sure we have the right table / table name
        name = self.model.endog_names[i]
        assert_equal(re.search('Error covariance matrix', table) is None, False)

        # -> Make sure it's the right size
        assert_equal(len(table.split('\n')), 8)

        # -> Check that we have the right coefficients
        offset = self.model.k_endog * self.model.k_factors
        for i in range(self.model.k_endog):
            assert_equal(re.search('sigma2.%s +%s' % (self.model.endog_names[i], forg(params[offset + i], prec=4)), table) is None, False)
예제 #3
0
    def test_summary(self):
        summary = self.results.summary()
        tables = [str(table) for table in summary.tables]
        params = self.true['params']

        # Check the model overview table
        assert_equal(
            re.search(r'Model:.*VARMA\(1,1\)', tables[0]) is None, False)

        # For each endogenous variable, check the output
        for i in range(self.model.k_endog):
            offset_ar = i * self.model.k_endog
            offset_ma = self.model.k_endog**2 * self.model.k_ar + i * self.model.k_endog
            table = tables[i + 2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert_equal(
                re.search('Results for equation %s' % name, table) is None,
                False)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 9)

            # -> Check that we have the right coefficients
            assert_equal(
                re.search(
                    'L1.dlncaputil +' + forg(params[offset_ar + 0], prec=4),
                    table) is None, False)
            assert_equal(
                re.search(
                    'L1.dlnhours +' + forg(params[offset_ar + 1], prec=4),
                    table) is None, False)
            assert_equal(
                re.search(
                    r'L1.e\(dlncaputil\) +' +
                    forg(params[offset_ma + 0], prec=4), table) is None, False)
            assert_equal(
                re.search(
                    r'L1.e\(dlnhours\) +' +
                    forg(params[offset_ma + 1], prec=4), table) is None, False)

        # Test the error covariance matrix table
        table = tables[-1]
        assert_equal(
            re.search('Error covariance matrix', table) is None, False)
        assert_equal(len(table.split('\n')), 7)

        params = params[self.model._params_state_cov]
        names = self.model.param_names[self.model._params_state_cov]
        for i in range(len(names)):
            assert_equal(
                re.search('%s +%s' %
                          (names[i], forg(params[i], prec=4)), table) is None,
                False)
예제 #4
0
    def test_summary(self):
        summary = self.results.summary()
        tables = [str(table) for table in summary.tables]
        params = self.true['params']

        # Check the model overview table
        assert_equal(re.search(r'Model:.*VARX\(1\)', tables[0]) is None, False)

        # For each endogenous variable, check the output
        for i in range(self.model.k_endog):
            offset = i * self.model.k_endog
            table = tables[i+2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert_equal(re.search('Results for equation %s' % name, table) is None, False)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 9)

            # -> Check that we have the right coefficients
            assert_equal(re.search('L1.dln_inv +%.4f' % params[offset + 0], table) is None, False)
            assert_equal(re.search('L1.dln_inc +%.4f' % params[offset + 1], table) is None, False)
            assert_equal(re.search('L1.dln_consump +%.4f' % params[offset + 2], table) is None, False)
            assert_equal(re.search('beta.x1 +' + forg(params[self.model._params_regression][i], prec=4), table) is None, False)

        # Test the error covariance matrix table
        table = tables[-1]
        assert_equal(re.search('Error covariance matrix', table) is None, False)
        assert_equal(len(table.split('\n')), 11)

        params = params[self.model._params_state_cov]
        names = self.model.param_names[self.model._params_state_cov]
        for i in range(len(names)):
            assert_equal(re.search('%s +%.4f' % (names[i], params[i]), table) is None, False)
예제 #5
0
    def test_summary(self):
        summary = self.results.summary()
        tables = [str(table) for table in summary.tables]
        params = self.true['params']

        # Check the model overview table
        assert_equal(re.search(r'Model:.*VARX\(1\)', tables[0]) is None, False)

        # For each endogenous variable, check the output
        for i in range(self.model.k_endog):
            offset = i * self.model.k_endog
            table = tables[i+2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert_equal(re.search('Results for equation %s' % name, table) is None, False)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 9)

            # -> Check that we have the right coefficients
            assert_equal(re.search('L1.dln_inv +%.4f' % params[offset + 0], table) is None, False)
            assert_equal(re.search('L1.dln_inc +%.4f' % params[offset + 1], table) is None, False)
            assert_equal(re.search('L1.dln_consump +%.4f' % params[offset + 2], table) is None, False)
            assert_equal(re.search('beta.x1 +' + forg(params[self.model._params_regression][i], prec=4), table) is None, False)

        # Test the error covariance matrix table
        table = tables[-1]
        assert_equal(re.search('Error covariance matrix', table) is None, False)
        assert_equal(len(table.split('\n')), 11)

        params = params[self.model._params_state_cov]
        names = self.model.param_names[self.model._params_state_cov]
        for i in range(len(names)):
            assert_equal(re.search('%s +%.4f' % (names[i], params[i]), table) is None, False)
예제 #6
0
    def test_summary(self):
        summary = self.results.summary()
        tables = [str(table) for table in summary.tables]
        params = self.true['params']

        # Check the model overview table
        assert re.search(r'Model:.*VARMA\(1,1\)', tables[0])

        # For each endogenous variable, check the output
        for i in range(self.model.k_endog):
            offset_ar = i * self.model.k_endog
            offset_ma = (self.model.k_endog**2 * self.model.k_ar +
                         i * self.model.k_endog)
            table = tables[i+2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert re.search('Results for equation %s' % name, table)

            # -> Make sure it's the right size
            assert len(table.split('\n')) == 9

            # -> Check that we have the right coefficients
            assert re.search(
                'L1.dlncaputil +' + forg(params[offset_ar + 0], prec=4),
                table)
            assert re.search(
                'L1.dlnhours +' + forg(params[offset_ar + 1], prec=4),
                table)
            assert re.search(
                r'L1.e\(dlncaputil\) +' + forg(params[offset_ma + 0], prec=4),
                table)
            assert re.search(
                r'L1.e\(dlnhours\) +' + forg(params[offset_ma + 1], prec=4),
                table)

        # Test the error covariance matrix table
        table = tables[-1]
        assert re.search('Error covariance matrix', table)
        assert len(table.split('\n')) == 7

        params = params[self.model._params_state_cov]
        names = self.model.param_names[self.model._params_state_cov]
        for i in range(len(names)):
            assert re.search('%s +%s' % (names[i], forg(params[i], prec=4)),
                             table)
예제 #7
0
    def test_summary(self):
        summary = self.results.summary()
        tables = [str(table) for table in summary.tables]
        params = self.true["params"]

        # Check the model overview table
        assert_equal(re.search(r"Model:.*VARMA\(1,1\)", tables[0]) is None, False)

        # For each endogenous variable, check the output
        for i in range(self.model.k_endog):
            offset_ar = i * self.model.k_endog
            offset_ma = self.model.k_endog ** 2 * self.model.k_ar + i * self.model.k_endog
            table = tables[i + 2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert_equal(re.search("Results for equation %s" % name, table) is None, False)

            # -> Make sure it's the right size
            assert_equal(len(table.split("\n")), 9)

            # -> Check that we have the right coefficients
            assert_equal(re.search("L1.dlncaputil +" + forg(params[offset_ar + 0], prec=4), table) is None, False)
            assert_equal(re.search("L1.dlnhours +" + forg(params[offset_ar + 1], prec=4), table) is None, False)
            assert_equal(re.search(r"L1.e\(dlncaputil\) +" + forg(params[offset_ma + 0], prec=4), table) is None, False)
            assert_equal(re.search(r"L1.e\(dlnhours\) +" + forg(params[offset_ma + 1], prec=4), table) is None, False)

        # Test the error covariance matrix table
        table = tables[-1]
        assert_equal(re.search("Error covariance matrix", table) is None, False)
        assert_equal(len(table.split("\n")), 7)

        params = params[self.model._params_state_cov]
        names = self.model.param_names[self.model._params_state_cov]
        for i in range(len(names)):
            assert_equal(re.search("%s +%s" % (names[i], forg(params[i], prec=4)), table) is None, False)
    def summary(self, alpha=.05, start=None):
        specification = ['A']
        if self.model.trend and self.model.damped_trend:
            specification.append('Ad')
        elif self.model.trend:
            specification.append('A')
        else:
            specification.append('N')
        if self.model.seasonal:
            specification.append('A')
        else:
            specification.append('N')

        model_name = 'ETS(' + ', '.join(specification) + ')'

        summary = super(ExponentialSmoothingResults,
                        self).summary(alpha=alpha,
                                      start=start,
                                      title='Exponential Smoothing Results',
                                      model_name=model_name)

        if self.model.initialization_method != 'estimated':
            params = np.array(self.initial_state)
            if params.ndim > 1:
                params = params[0]
            names = self.model.state_names
            param_header = [
                'initialization method: %s' % self.model.initialization_method
            ]
            params_stubs = names
            params_data = [[forg(params[i], prec=4)]
                           for i in range(len(params))]

            initial_state_table = SimpleTable(params_data,
                                              param_header,
                                              params_stubs,
                                              txt_fmt=fmt_params)
            summary.tables.insert(-1, initial_state_table)

        return summary
    def test_summary(self):
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            summary = self.results.summary()
        tables = [str(table) for table in summary.tables]
        params = self.true['params']

        # Make sure we have the right number of tables
        assert_equal(
            len(tables), 2 + self.model.k_endog + self.model.k_factors +
            self.model.k_endog + 1)

        # Check the model overview table
        assert re.search(r'Model:.*DynamicFactor\(factors=1, order=1\)',
                         tables[0])
        assert re.search(r'.*VAR\(1\) errors', tables[0])

        # For each endogenous variable, check the output
        for i in range(self.model.k_endog):
            offset_loading = self.model.k_factors * i
            table = tables[i + 2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert re.search('Results for equation %s' % name, table)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 6)

            # -> Check that we have the right coefficients
            pattern = 'loading.f1 +' + forg(params[offset_loading + 0], prec=4)
            assert re.search(pattern, table)

        # For each factor, check the output
        for i in range(self.model.k_factors):
            offset = (self.model.k_endog * self.model.k_factors + 6 +
                      i * self.model.k_factors)
            table = tables[2 + self.model.k_endog + i]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert re.search('Results for factor equation f%d' % (i + 1),
                             table)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 6)

            # -> Check that we have the right coefficients
            assert re.search('L1.f1 +' + forg(params[offset + 0], prec=4),
                             table)

        # For each error equation, check the output
        for i in range(self.model.k_endog):
            offset = (self.model.k_endog * (self.model.k_factors + i) + 6 +
                      self.model.k_factors)
            table = tables[2 + self.model.k_endog + self.model.k_factors + i]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert re.search(r'Results for error equation e\(%s\)' % name,
                             table)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 8)

            # -> Check that we have the right coefficients
            for j in range(self.model.k_endog):
                name = self.model.endog_names[j]
                pattern = r'L1.e\(%s\) +%s' % (
                    name, forg(params[offset + j], prec=4))
                assert re.search(pattern, table)

        # Check the Error covariance matrix output
        table = tables[2 + self.model.k_endog + self.model.k_factors +
                       self.model.k_endog]

        # -> Make sure we have the right table / table name
        name = self.model.endog_names[i]
        assert re.search('Error covariance matrix', table)

        # -> Make sure it's the right size
        assert_equal(len(table.split('\n')), 11)

        # -> Check that we have the right coefficients
        offset = self.model.k_endog * self.model.k_factors
        assert re.search(
            'sqrt.var.dln_inv +' + forg(params[offset + 0], prec=4), table)
        assert re.search(
            'sqrt.cov.dln_inv.dln_inc +' + forg(params[offset + 1], prec=4),
            table)
        assert re.search(
            'sqrt.var.dln_inc +' + forg(params[offset + 2], prec=4), table)
        assert re.search(
            'sqrt.cov.dln_inv.dln_consump +' +
            forg(params[offset + 3], prec=4), table)
        assert re.search(
            'sqrt.cov.dln_inc.dln_consump +' +
            forg(params[offset + 4], prec=4), table)
        assert re.search(
            'sqrt.var.dln_consump +' + forg(params[offset + 5], prec=4), table)
예제 #10
0
    def test_summary(self):
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            summary = self.results.summary()
        tables = [str(table) for table in summary.tables]
        params = self.true['params']

        # Make sure we have the right number of tables
        assert_equal(
            len(tables),
            2 + self.model.k_endog + self.model.k_factors +
            self.model.k_endog + 1)

        # Check the model overview table
        assert re.search(r'Model:.*DynamicFactor\(factors=1, order=1\)',
                         tables[0])
        assert re.search(r'.*VAR\(1\) errors', tables[0])

        # For each endogenous variable, check the output
        for i in range(self.model.k_endog):
            offset_loading = self.model.k_factors * i
            table = tables[i + 2]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert re.search('Results for equation %s' % name, table)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 6)

            # -> Check that we have the right coefficients
            pattern = 'loading.f1 +' + forg(params[offset_loading + 0], prec=4)
            assert re.search(pattern, table)

        # For each factor, check the output
        for i in range(self.model.k_factors):
            offset = (self.model.k_endog * self.model.k_factors +
                      6 + i * self.model.k_factors)
            table = tables[2 + self.model.k_endog + i]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert re.search('Results for factor equation f%d' % (i+1), table)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 6)

            # -> Check that we have the right coefficients
            assert re.search('L1.f1 +' + forg(params[offset + 0], prec=4),
                             table)

        # For each error equation, check the output
        for i in range(self.model.k_endog):
            offset = (self.model.k_endog * (self.model.k_factors + i) +
                      6 + self.model.k_factors)
            table = tables[2 + self.model.k_endog + self.model.k_factors + i]

            # -> Make sure we have the right table / table name
            name = self.model.endog_names[i]
            assert re.search(r'Results for error equation e\(%s\)' % name,
                             table)

            # -> Make sure it's the right size
            assert_equal(len(table.split('\n')), 8)

            # -> Check that we have the right coefficients
            for j in range(self.model.k_endog):
                name = self.model.endog_names[j]
                pattern = r'L1.e\(%s\) +%s' % (name, forg(params[offset + j],
                                                          prec=4))
                assert re.search(pattern, table)

        # Check the Error covariance matrix output
        table = tables[2 + self.model.k_endog +
                       self.model.k_factors + self.model.k_endog]

        # -> Make sure we have the right table / table name
        name = self.model.endog_names[i]
        assert re.search('Error covariance matrix', table)

        # -> Make sure it's the right size
        assert_equal(len(table.split('\n')), 11)

        # -> Check that we have the right coefficients
        offset = self.model.k_endog * self.model.k_factors
        assert re.search(
            'sqrt.var.dln_inv +' + forg(params[offset + 0], prec=4),
            table)
        assert re.search(
            'sqrt.cov.dln_inv.dln_inc +' + forg(params[offset + 1], prec=4),
            table)
        assert re.search(
            'sqrt.var.dln_inc +' + forg(params[offset + 2], prec=4),
            table)
        assert re.search(
            'sqrt.cov.dln_inv.dln_consump +' + forg(params[offset+3], prec=4),
            table)
        assert re.search(
            'sqrt.cov.dln_inc.dln_consump +' + forg(params[offset+4], prec=4),
            table)
        assert re.search(
            'sqrt.var.dln_consump +' + forg(params[offset + 5], prec=4),
            table)