#!/usr/bin/env python # coding: utf-8 # In[58]: get_ipython().run_line_magic('matplotlib', 'inline') import numpy as np import pandas as pd import statsmodels.api as sm from statsmodels.tsa.statespace import mlemodel from statsmodels.tsa.statespace.tests import test_representation as t import matplotlib.pyplot as plt np.set_printoptions(precision=4, suppress=True, linewidth=120) # In[95]: # Get the multiple endog test case # Note: it directly uses a KalmanFilter instance... test = t.Clark1989() test.run_filter() # ...so wrap it into an MLEModel instance # Note: zero parameters here x = mlemodel.MLEModel(endog=test.model.endog.T, k_states=test.model.k_states) x.ssm = test.model res = x.filter([]) # Summary: note that the diagnostics table shows two # numbers for each test corresponding to the two endog print res.summary() # Diagnostics for the first endog fig1 = res.plot_diagnostics(0, figsize=(10,6)) fig1.suptitle('Diagnostics for y1', fontsize='xx-large') fig1.subplots_adjust(top=0.87) # Diagnostics for the second endog fig2 = res.plot_diagnostics(1, figsize=(10,6)) fig2.suptitle('Diagnostics for y2', fontsize='xx-large') fig2.subplots_adjust(top=0.87);