状態空間法による時系列解析 statespace¶
statsmodels.tsa.statespace 状態空間メソッドを使用した時系列分析に役立つクラスと関数が含まれています。
一般的な状態空間モデルは次の形式になります
ここで \(y_t\) は時刻 \(t\) の観測ベクトル、 \(\alpha_t\) は 時刻 \(t\) の(観測されていない)状態ベクトルで、不規則成分は以下のように定義されます
方程式の残りの変数 (\(Z_t, d_t, H_t, T_t, c_t, R_t, Q_t\)) はプロセスを記述する行列です。それらの変数名と次元は次のとおりです
Z : design \((k\_endog \times k\_states \times nobs)\)
d : obs_intercept \((k\_endog \times nobs)\)
H : obs_cov \((k\_endog \times k\_endog \times nobs)\)
T : transition \((k\_states \times k\_states \times nobs)\)
c : state_intercept \((k\_states \times nobs)\)
R : selection \((k\_states \times k\_posdef \times nobs)\)
Q : state_cov \((k\_posdef \times k\_posdef \times nobs)\)
行列の1つが時不変である場合(例えば \(Z_t=Z_{t+1}~\forall~t\)) 、その最後の次元はサイズ nobs ではなくサイズ \(1\) である可能性があります。
この一般的な形式は、最も一般的な線形時系列モデル(下記参照)の多くをカプセル化したものであり、非常に柔軟であり、欠落した観測、予測、インパルス応答関数などによる推定を可能にします。
例: AR(2) model
自己回帰モデルは、モデルを状態空間の形にするための良い入門的な例です。AR(2)モデルはしばしば次のように書かれることを思い出してください:
これは、次の方法で状態空間形式に入れることができます:
ここで
そして
このモデルには3つの未知のパラメータがあります: \(\phi_1, \phi_2, \sigma^2\)。
モデルと推定¶
以下は主な推定クラスで、 statsmodels.tsa.statespace.api とその結果クラスからアクセスできます。
外生回帰変数を用いた季節的自己回帰統合移動平均(SARIMAX)¶
SARIMAX クラスは、推定のために状態空間バックエンドを使用して作成された本格的なモデルの例です。 SARIMAX は tsa モデルと非常によく似ていますが、任意のトレンド多項式だけでなく、加法的および乗法的な季節効果の推定を追加することによって、より広い範囲のモデルで機能します。
|
季節的自動回帰統合移動平均と外因性回帰モデル |
|
SARIMAX モデルのフィッティング結果を保持するクラス。 |
このモデルの使用例については、 SARIMAX example notebook または以下の非常に簡単なコードスニペットを参照してください:
# Load the statsmodels api
import statsmodels.api as sm
# Load your dataset
endog = pd.read_csv('your/dataset/here.csv')
# We could fit an AR(2) model, described above
mod_ar2 = sm.tsa.SARIMAX(endog, order=(2,0,0))
# Note that mod_ar2 is an instance of the SARIMAX class
# Fit the model via maximum likelihood
res_ar2 = mod_ar2.fit()
# Note that res_ar2 is an instance of the SARIMAXResults class
# Show the summary of results
print(res_ar2.summary())
# We could also fit a more complicated model with seasonal components.
# As an example, here is an SARIMA(1,1,1) x (0,1,1,4):
mod_sarimax = sm.tsa.SARIMAX(endog, order=(1,1,1),
seasonal_order=(0,1,1,4))
res_sarimax = mod_sarimax.fit()
# Show the summary of results
print(res_sarimax.summary())
結果オブジェクトには、標準誤差、z統計、予測/予測など、他のstatsmodels結果オブジェクトに期待される多くの属性とメソッドがあります。
SARIMAX モデルは舞台裏で、モデル仕様に基づいてデザイン行列と遷移行列 (場合によっては他の行列の一部) を作成します。
未観測成分¶
UnobservedComponents クラスは、状態空間モデルのもう1つの例です。
|
単変量未観測成分時系列モデル |
未観測成分モデルをフィッティングした結果を保持するクラス。 |
このモデルの使用例については、 example notebook や、観測されないコンポーネントモデルを使用して decompose a time series into a trend and cycle や、以下の非常に簡単なコードスニペットを参照してください:
# Load the statsmodels api
import statsmodels.api as sm
# Load your dataset
endog = pd.read_csv('your/dataset/here.csv')
# Fit a local level model
mod_ll = sm.tsa.UnobservedComponents(endog, 'local level')
# Note that mod_ll is an instance of the UnobservedComponents class
# Fit the model via maximum likelihood
res_ll = mod_ll.fit()
# Note that res_ll is an instance of the UnobservedComponentsResults class
# Show the summary of results
print(res_ll.summary())
# Show a plot of the estimated level and trend component series
fig_ll = res_ll.plot_components()
# We could further add a damped stochastic cycle as follows
mod_cycle = sm.tsa.UnobservedComponents(endog, 'local level', cycle=True,
damped_cycle=True,
stochastic_cycle=True)
res_cycle = mod_cycle.fit()
# Show the summary of results
print(res_cycle.summary())
# Show a plot of the estimated level, trend, and cycle component series
fig_cycle = res_cycle.plot_components()
外生回帰変数を用いたベクトル自己回帰移動平均(VARMAX)¶
VARMAX クラスは、多変数状態空間モデルの一例です。
|
外因性回帰モデルを用いたベクトル自己回帰移動平均 |
|
VARMAXモデルのフィッティングの結果を保持するクラス。 |
このモデルの使用例については、 VARMAX example notebook または以下の非常に簡単なコード断片を参照してください:
# Load the statsmodels api
import statsmodels.api as sm
# Load your (multivariate) dataset
endog = pd.read_csv('your/dataset/here.csv')
# Fit a local level model
mod_var1 = sm.tsa.VARMAX(endog, order=(1,0))
# Note that mod_var1 is an instance of the VARMAX class
# Fit the model via maximum likelihood
res_var1 = mod_var1.fit()
# Note that res_var1 is an instance of the VARMAXResults class
# Show the summary of results
print(res_var1.summary())
# Construct impulse responses
irfs = res_ll.impulse_responses(steps=10)
動的因子モデル¶
Statsmodelsには、動的要素モデルをサポートする DynamicFactorMQ と DynamicFactor の2つのクラスがあります。これらのモデルにはそれぞれ長所がありますが、一般的には DynamicFactorMQ クラスが推奨されます。これは、より堅牢で数百の観測された系列を含めることができるExpectation-Maximization(EM)アルゴリズムを使用してパラメータを適合させるためです。さらに、どの変数がどの要素にロードされるかをカスタマイズできます。しかし、 DynamicFactor はその機能をサポートしていますが、外因性変数を含めることはまだサポートしていません。
|
EMアルゴリズムを使用した動的因子モデル。月次/四半期データのオプション。 |
動的因子モデルのフィッティングの結果 |
DynamicFactorMQ クラスの例については、以下の非常に簡単なコードを参照してください:
# Load the statsmodels api
import statsmodels.api as sm
# Load your dataset
endog = pd.read_csv('your/dataset/here.csv')
# Create a dynamic factor model
mod_dfm = sm.tsa.DynamicFactorMQ(endog, k_factors=1, factor_order=2)
# Note that mod_dfm is an instance of the DynamicFactorMQ class
# Fit the model via maximum likelihood, using the EM algorithm
res_dfm = mod_dfm.fit()
# Note that res_dfm is an instance of the DynamicFactorMQResults class
# Show the summary of results
print(res_ll.summary())
# Show a plot of the r^2 values from regressions of
# individual estimated factors on endogenous variables.
fig_dfm = res_ll.plot_coefficients_of_determination()
DynamicFactor クラスは、観測された変数の数が少ないモデルに適している
|
動的因子モデル |
|
DynamicFactorモデルのフィッティングの結果を保持するクラス。 |
DynamicFactor モデルの使用例については、 Dynamic Factor example notebook を参照してください
線形指数平滑化モデル¶
ExponentialSmoothing クラスは、状態空間アプローチを使用した線形指数平滑化モデルの実装である。
注意 :このモデルは sm.tsa.statespace.ExponentialSmoothing で入手できます; sm.tsa.ExponentialSmoothing で入手できるモデルと同じではありません。これらのクラスの違いの詳細については、以下を参照してください。
線形指数平滑法モデル |
|
線形指数平滑化モデルをフィッティングした結果 |
非常に短いコード スニペットは次のとおりです:
# Load the statsmodels api
import statsmodels.api as sm
# Load your dataset
endog = pd.read_csv('your/dataset/here.csv')
# Simple exponential smoothing, denoted (A,N,N)
mod_ses = sm.tsa.statespace.ExponentialSmoothing(endog)
res_ses = mod_ses.fit()
# Holt's linear method, denoted (A,A,N)
mod_h = sm.tsa.statespace.ExponentialSmoothing(endog, trend=True)
res_h = mod_h.fit()
# Damped trend model, denoted (A,Ad,N)
mod_dt = sm.tsa.statespace.ExponentialSmoothing(endog, trend=True,
damped_trend=True)
res_dt = mod_dt.fit()
# Holt-Winters' trend and seasonality method, denoted (A,A,A)
# (assuming that `endog` has a seasonal periodicity of 4, for example if it
# is quarterly data).
mod_hw = sm.tsa.statespace.ExponentialSmoothing(endog, trend=True,
seasonal=4)
res_hw = mod_hw.fit()
Statsmodels の指数平滑化モデル クラス間の違い
sm.tsa.statespace.ExponentialSmoothing で利用できるこのモデルクラスと sm.tsa.ExponentialSmoothing で利用できるモデルクラスにはいくつかの違いがあります。
このモデルクラスは 線形 指数平滑化モデルのみをサポートしますが、 sm.tsa.ExponentialSmoothing は乗法モデルもサポートします。
このモデルクラスは、指数平滑化モデルを状態空間形式に配置し、カルマンフィルタを適用して状態を推定します。一方、 sm.tsa.ExponentialSmoothing は指数平滑化再帰に基づいています。場合によっては、このモデルクラスを使用したパラメータの推定が sm.tsa.ExponentialSmoothing を使用した場合よりも多少遅くなることを意味します。
このモデルクラスは、ガウス誤差の仮定に基づいて予測の信頼区間を生成することができますが、 sm.tsa.ExponentialSmoothing は信頼区間をサポートしていません。
このモデル クラスは、目的関数からの初期値の集中をサポートします。これにより、推定する初期状態が多数ある場合 (季節周期性が大きい場合など) のパフォーマンスが向上します。
このモデル クラスは、診断や固定パラメーターなど、状態空間モデルで利用できる多くの高度な機能をサポートします。
注 : このクラスは、 "単一エラー源" (SSOE) の定式化ではなく、 "複数のエラー源" (MSOE) の状態空間定式化に基づいています。
カスタム状態空間モデル¶
状態空間モデルの真の力は、カスタムモデルの作成と推定を可能にすることにあります。通常、これは、状態空間表現、カルマンフィルタリング、および推定と結果出力のための最尤フィッティング機能のすべてをバンドルする次の2つのクラスを拡張することによって行われます。
|
最尤推定のための状態空間モデル |
|
状態空間モデルのフィッティング結果を保持するクラス。 |
|
MLEモデルによる予測結果 |
カスタム状態空間モデルの作成と推定を示す基本的な例については、 Local Linear Trend example notebook を参照してください。より洗練された例については、 MLEModel と MLEResults を拡張して構築された SARIMAX と SARIMAXResults クラスのソースコードを参照してください。
単純なケースでは、モデルはMLEModelクラスを使用して完全に構築できます。たとえば、上記のAR(2)モデルは、次のコードのみを使用して構築および推定できます:
import numpy as np
from scipy.signal import lfilter
import statsmodels.api as sm
# True model parameters
nobs = int(1e3)
true_phi = np.r_[0.5, -0.2]
true_sigma = 1**0.5
# Simulate a time series
np.random.seed(1234)
disturbances = np.random.normal(0, true_sigma, size=(nobs,))
endog = lfilter([1], np.r_[1, -true_phi], disturbances)
# Construct the model
class AR2(sm.tsa.statespace.MLEModel):
def __init__(self, endog):
# Initialize the state space model
super(AR2, self).__init__(endog, k_states=2, k_posdef=1,
initialization='stationary')
# Setup the fixed components of the state space representation
self['design'] = [1, 0]
self['transition'] = [[0, 0],
[1, 0]]
self['selection', 0, 0] = 1
# Describe how parameters enter the model
def update(self, params, transformed=True, **kwargs):
params = super(AR2, self).update(params, transformed, **kwargs)
self['transition', 0, :] = params[:2]
self['state_cov', 0, 0] = params[2]
# Specify start parameters and parameter names
@property
def start_params(self):
return [0,0,1] # these are very simple
# Create and fit the model
mod = AR2(endog)
res = mod.fit()
print(res.summary())
これにより、次の概要表が作成されます:
Statespace Model Results
==============================================================================
Dep. Variable: y No. Observations: 1000
Model: AR2 Log Likelihood -1389.437
Date: Wed, 26 Oct 2016 AIC 2784.874
Time: 00:42:03 BIC 2799.598
Sample: 0 HQIC 2790.470
- 1000
Covariance Type: opg
==============================================================================
coef std err z P>|z| [0.025 0.975]
------------------------------------------------------------------------------
param.0 0.4395 0.030 14.730 0.000 0.381 0.498
param.1 -0.2055 0.032 -6.523 0.000 -0.267 -0.144
param.2 0.9425 0.042 22.413 0.000 0.860 1.025
===================================================================================
Ljung-Box (Q): 24.25 Jarque-Bera (JB): 0.22
Prob(Q): 0.98 Prob(JB): 0.90
Heteroskedasticity (H): 1.05 Skew: -0.04
Prob(H) (two-sided): 0.66 Kurtosis: 3.02
===================================================================================
Warnings:
[1] Covariance matrix calculated using the outer product of gradients (complex-step).
結果オブジェクトには、標準誤差、z統計、予測/予測など、他のstatsmodels結果オブジェクトに期待される多くの属性とメソッドがあります。
結果オブジェクトには、標準誤差、Z 統計、予測/予測など、他の statsmodels 結果オブジェクトに期待される属性とメソッドの多くが含まれています。
使用方法の概要¶
すべての状態空間モデルは、典型的な Statsmodels パターンに従います:
入力データセットを使用して モデルインスタンス を構築します
パラメータをモデルに適用して (たとえば、 fit を使用して) 結果インスタンス を構築します
結果インスタンスを操作して、推定パラメータを調べ、残差診断を調査し、予測、シミュレーション、またはインパルス応答を生成します。
このパターンの例は次のとおりです:
# Load in the example macroeconomic dataset
dta = sm.datasets.macrodata.load_pandas().data
# Make sure we have an index with an associated frequency, so that
# we can refer to time periods with date strings or timestamps
dta.index = pd.date_range('1959Q1', '2009Q3', freq='QS')
# Step 1: construct an SARIMAX model for US inflation data
model = sm.tsa.SARIMAX(dta.infl, order=(4, 0, 0), trend='c')
# Step 2: fit the model's parameters by maximum likelihood
results = model.fit()
# Step 3: explore / use results
# - Print a table summarizing estimation results
print(results.summary())
# - Print only the estimated parameters
print(results.params)
# - Create diagnostic figures based on standardized residuals:
# (1) time series graph
# (2) histogram
# (3) Q-Q plot
# (4) correlogram
results.plot_diagnostics()
# - Examine diagnostic hypothesis tests
# Jarque-Bera: [test_statistic, pvalue, skewness, kurtosis]
print(results.test_normality(method='jarquebera'))
# Goldfeld-Quandt type test: [test_statistic, pvalue]
print(results.test_heteroskedasticity(method='breakvar'))
# Ljung-Box test: [test_statistic, pvalue] for each lag
print(results.test_serial_correlation(method='ljungbox'))
# - Forecast the next 4 values
print(results.forecast(4))
# - Forecast until 2020Q4
print(results.forecast('2020Q4'))
# - Plot in-sample dynamic prediction starting in 2005Q1
# and out-of-sample forecasts until 2010Q4 along with
# 90% confidence intervals
predict_results = results.get_prediction(start='2005Q1', end='2010Q4', dynamic=True)
predict_df = predict_results.summary_frame(alpha=0.10)
fig, ax = plt.subplots()
predict_df['mean'].plot(ax=ax)
ax.fill_between(predict_df.index, predict_df['mean_ci_lower'],
predict_df['mean_ci_upper'], alpha=0.2)
# - Simulate two years of new data after the end of the sample
print(results.simulate(8, anchor='end'))
# - Impulse responses for two years
print(results.impulse_responses(8))
推定/フィルタリング/平滑化のための基本的な方法と属性¶
状態空間モデルで最もよく使用されるメソッドは次のとおりです:
fit-最尤法によってパラメータを推定し、結果オブジェクトを返します(このオブジェクトは推定されたパラメータでカルマンフィルタと平滑化も行います)。これは最も一般的に使用される方法です。smooth-カルマンフィルタと平滑化を実行した後、与えられたパラメータのベクトルに関連付けられた結果オブジェクトを返しますloglike-与えられたパラメータのベクトルを使って、データの対数尤度を計算する
状態空間モデルの有用な属性には次のようなものがあります:
param_names-モデルが使用するパラメータの名前state_names-(観測されていない)状態ベクトルの要素の名前start_params-初期パラメータ推定値は、数値的最尤最適化のための開始値を使用しました
あまり使用されないその他の方法は、次のとおりです:
filter-(平滑化ではなく)カルマンフィルタを実行した後に、与えられたパラメータのベクトルに関連付けられた結果オブジェクトを返しますsimulation_smoother-シミュレーションの平滑化を実行できるオブジェクトを返します
出力および事後推定の方法と属¶
一般的に使用される方法は次のとおりです:
summary-モデル適合統計、推定パラメータ、その他の要約出力を表示するテーブルを作成しますpredict-標本内予測と標本外予測を計算します(点推定のみ)get_prediction-標本内予測と標本外予測を、信頼区間を含めて計算しますforecast-サンプル外予測を計算します(点推定のみ)(これは`predict`の便利なラッパーです)get_forecast-標本外の予測を信頼区間を含めて計算します(これは get_prediction の便利なラッパです)。simulate-状態空間モデルに従って新しいデータをシミュレートしますimpulse_responses-状態空間モデルからインパルス応答を計算します
一般的に使用される属性は次のとおりです:
params- 推定パラメータbse- 推定パラメータに関連付けられた p 値pvalues- 推定パラメータでのデータの対数尤度llf- 推定パラメータでのデータの対数尤度fittedvalues- モデルからの適合値 (これらは一歩先の予測であることに注意してください)resid- モデルからの残差 (これらは 1 ステップ先の予測誤差であることに注意してください)
未観測状態の推定と共分散¶
観測されたデータを条件として、未観測状態ベクトルの推定値を計算すると便利です。これらは、次の要素を含む結果オブジェクト states で使用できます:
states.filtered - 状態ベクトルのフィルタリングされた (片側) 推定値。時刻tにおける状態ベクトルの推定は、時刻tまでの観測データに基づいています。
states.smoothed - 状態ベクトルの平滑化された (両側) 推定値。時間tにおける状態ベクトルの推定は、サンプル内のすべての観測データに基づいています。
states.filtered_cov - 状態ベクトルのフィルター処理された(片側)共分散
states.smoothed_cov - 状態ベクトルの平滑化された(両側)共分散
これらの各要素は Pandas DataFrameオブジェクトです。
例として、 UnobservedComponents コンポーネント クラスを介して推定された "ローカル レベル + 季節" モデルでは、 時間の経過に伴う系列の基礎となるレベルと季節変動の推定値を取得できます。
fig, axes = plt.subplots(3, 1, figsize=(8, 8))
# Retrieve monthly retail sales for clothing
from pandas_datareader.data import DataReader
clothing = DataReader('MRTSSM4481USN', 'fred', start='1992').asfreq('MS')['MRTSSM4481USN']
# Construct a local level + seasonal model
model = sm.tsa.UnobservedComponents(clothing, 'llevel', seasonal=12)
results = model.fit()
# Plot the data, the level, and seasonal
clothing.plot(ax=axes[0])
results.states.smoothed['level'].plot(ax=axes[1])
results.states.smoothed['seasonal'].plot(ax=axes[2])
残差診断¶
組み込みかカスタムかにかかわらず、状態空間モデルの推定後に 3 つの診断テストを使用して、モデルが基礎となる統計的仮定に準拠しているかどうかを評価できます。これらのテストは次のとおりです:
同じ目的のために、回帰残差の標準プロットがいくつか利用できます。これらは plot_diagnostics コマンドを使って作成できます。
推定されたパラメータを更新されたデータセットまたは異なるデータセットに適用する¶
結果オブジェクトの推定パラメータを更新されたデータセットまたは別のデータセットに適用するために使用できる方法は 3 つあります:
append- 現在のサンプルの終了後に追加の観測が追加された新しい結果オブジェクトを取得します (つまり、新しい結果オブジェクトには現在のサンプルと追加の観測の両方が含まれます)extend- 現在のサンプルの終了後に続く追加の観測値の新しい結果オブジェクトを取得します (つまり、新しい結果オブジェクトには新しい観測値のみが含まれますが、現在のサンプルは含まれません)apply- まったく異なるデータセットの新しい結果オブジェクトを取得します
時系列データに対する相互検証の演習の 1 つは、トレーニング サンプル (時間 t による観測) に基づいてモデルのパラメーターを近似し、次にテスト サンプル (観測 t+1, t+2 ,…)を使用してモデルの近似を評価することです。これは、 apply または extend を使用すると便利です。以下の例では、 extend メソッドを使用します。
# Load in the example macroeconomic dataset
dta = sm.datasets.macrodata.load_pandas().data
# Make sure we have an index with an associated frequency, so that
# we can refer to time periods with date strings or timestamps
dta.index = pd.date_range('1959Q1', '2009Q3', freq='QS')
# Separate inflation data into a training and test dataset
training_endog = dta['infl'].iloc[:-1]
test_endog = dta['infl'].iloc[-1:]
# Fit an SARIMAX model for inflation
training_model = sm.tsa.SARIMAX(training_endog, order=(4, 0, 0))
training_results = training_model.fit()
# Extend the results to the test observations
test_results = training_results.extend(test_endog)
# Print the sum of squared errors in the test sample,
# based on parameters computed using only the training sample
print(test_results.sse)
データ改訂の影響を理解する¶
状態空間モデルの結果は、モデルパラメータに対するデータリビジョン -- news -- の影響を理解するために使用できる news ニュース`メソッドを公開する。
|
データの改訂やニュースが関心のある変数の推定値に及ぼす影響 |
追加のオプションとツール¶
すべての状態空間モデルには、次のオプションとツールがあります:
いくつかのパラメータを固定し、残りを推定する¶
fit_constrained メソッドでは、いくつかのパラメータを既知の値に固定し、残りを最尤法で推定することができます。この例を以下に示します:
# Construct a model
model = sm.tsa.SARIMAX(endog, order=(1, 0, 0))
# To find out the parameter names, use:
print(model.param_names)
# Fit the model with a fixed value for the AR(1) coefficient:
results = model.fit_constrained({'ar.L1': 0.5})
あるいは、 fix_params コンテキスト マネージャーを使用することもできます:
# Construct a model
model = sm.tsa.SARIMAX(endog, order=(1, 0, 0))
# Fit the model with a fixed value for the AR(1) coefficient using the
# context manager
with model.fix_params({'ar.L1': 0.5}):
results = model.fit()
低メモリオプション¶
観測されたデータセットが非常に大きい場合、および/またはモデルの状態ベクトルが高次元である場合(例えば、長い季節的影響を考慮する場合)、デフォルトのメモリ要件が大きすぎる可能性があります。この理由から、fit、filter、smooth メソッドはオプションの low_memory=True 引数を受け入れます。これにより、メモリ要件が大幅に削減され、モデルのフィッティングが高速化されます。
low_memory=True , を使用する場合、すべての結果オブジェクトが使用できるわけではないことに注意してください。ただし、残差診断、サンプル内 (非動的) 予測、サンプル外予測はすべて引き続き利用できます。
低レベル状態空間表現とカルマン フィルタリング¶
カスタムモデルの作成は、ほとんどの場合 MLEModel と MLEResults を拡張することによって行われますが、これらのクラスの背後にある上部構造を理解すると役立つ場合があります。
最尤推定にはモデルの尤度関数を評価する必要があり、状態空間形式のモデルの場合、尤度関数はカルマン フィルターの実行の副産物として評価されます。
状態空間モデルとカルマンフィルタリングの指定を容易にする MLEModel によって使用される2つのクラス、 Representation と KalmanFilter があります。
Representation クラスは、状態空間モデル表現が定義される部分です。簡単に言えば、状態空間行列( design 、 obs_intercept など、上記の状態空間モデルの紹介を参照)を保持し、それらの操作を可能にします。
FrozenRepresentation は最も基本的な結果タイプのクラスであり、任意の時点での状態空間表現の "スナップショット" を取得します。使用可能な属性の完全なリストについては、クラスのドキュメントを参照してください。
|
時系列プロセスの状態空間表現 |
フリーズ状態空間モデル |
KalmanFilter クラスは、フィルタリング機能を提供する Representation のサブクラスです。状態空間表現行列が構築されると、 filter メソッドを呼び出すことができ、 FilterResults インスタンスが生成されます。 FilterResults は FrozenRepresentation のサブクラスです。
FilterResults クラスは、状態空間モデル(デザイン、遷移などの行列、モデルの次元など)の凍結された表現を保持するだけでなく、 filtered state や 対数尤度(利用可能な結果の完全なリストについてはクラスのドキュメントを参照)を含むフィルタリング出力も保持します。また、 predict メソッドも提供しており、これはサンプル内予測またはサンプル外予測を可能にします。同様のメソッドである predict は、信頼区間を含む追加の予測または予測結果を提供します。
|
カルマン フィルターを使用した時系列プロセスの状態空間表現 |
|
カルマン フィルターを状態空間モデルに適用した結果。 |
|
一般的な状態空間モデルのサンプル内予測とサンプル外予測の結果 |
KalmanSmoother クラスは、平滑化機能を提供する KalmanFilter のサブクラスです。状態空間表現行列が構築されると、 filter メソッドを呼び出して SmootherResults インスタンスを生成できます。 SmootherResults は FilterResults のサブクラスです。
SmootherResults クラスは FilterResults からのすべての出力を保持しますが、 smoothed state や 対数尤度などの平滑化出力も含みます(利用可能な結果の完全なリストについてはクラスのドキュメントを参照してください)。時間 t での「フィルタされた」出力は、時間 t までの観測値を条件とした推定値を指し、 "平滑化された" 出力は、データセット内の観測値のセット全体を条件とした推定値を指します。
|
カルマン フィルターとスムージングを使用した、時系列プロセスの状態空間表現。 |
カルマンスムーザおよび/またはフィルタを状態空間モデルに適用した結果。 |
SimulationSmoother クラスは KalmanSmoother のサブクラスで、さらにシミュレーションとシミュレーションの平滑化機能を提供します。 simulation_smoother メソッドを呼び出すことができ、 SimulationSmoothResults インスタンスを生成します。
SimulationSmoothResults クラスには simulate メソッドがあり、状態ベクトルの結合後方から引き出すためのシミュレーション平滑化を実行することができます。これは、ギブスサンプリングによる状態空間モデルのベイズ推定に役立ちます。
カルマン フィルターとスムーザー、およびシミュレーション スムースを使用した時系列プロセスの状態空間表現。 |
|
カルマンスムーザおよび/またはフィルタを状態空間モデルに適用した結果。 |
|
"Cholesky Factor Algorithm"(CFA)シミュレーションスムーザ |
"Cholesky Factor Algorithm"(CFA)シミュレーションスムーザ¶
"Cholesky Factor Algorithm"(CFA)シミュレーションスムーザ:
|
"Cholesky Factor Algorithm"(CFA)シミュレーションスムーザ |
|
系列の単純差分をとる、あるいさらには 0 番目の軸に沿った季節差分をとります。 |
|
多項式が可逆かどうかを判断します。 |
オプティマイザによって使用される制約のないパラメータを、尤度評価で使用される制約付きパラメータに変換します |
|
尤度評価で使用される制約付きパラメータを、オプティマイザで使用される制約なしパラメータに変換します |
|
オプティマイザーによって使用される制約のないパラメーターを、ベクトル自己回帰の尤度評価で使用される制約付きパラメーターに変換します。 |
|
尤度評価で使用される制約付きパラメータを、オプティマイザで使用される制約なしパラメータに変換します |
|
|
時間変化する可能性のある行列の形状を検証するか、例外を発生させます |
|
時間変化する可能性のあるベクトルの形状を検証するか、例外を発生させます |