Python 時系列分析 1,000本ノック
– ノック68: 状態空間モデルの推定 –

Python 時系列分析 1,000本ノック– ノック68: 状態空間モデルの推定 –
次の Python コードで推定しているのは何ですか?

Python コード:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt
np.random.seed(42)
data = pd.Series(np.random.randn(100).cumsum())
data += np.random.randn(100)*5
model = sm.tsa.UnobservedComponents(
data, level='local linear trend')
results = model.fit()
trend_component = results.level.smoothed
data.plot(label='Observed')
plt.plot(trend_component, label='Estimated')
plt.legend()
plt.show()
import numpy as np import pandas as pd import statsmodels.api as sm import matplotlib.pyplot as plt np.random.seed(42) data = pd.Series(np.random.randn(100).cumsum()) data += np.random.randn(100)*5 model = sm.tsa.UnobservedComponents( data, level='local linear trend') results = model.fit() trend_component = results.level.smoothed data.plot(label='Observed') plt.plot(trend_component, label='Estimated') plt.legend() plt.show()
import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt

np.random.seed(42)
data = pd.Series(np.random.randn(100).cumsum())
data += np.random.randn(100)*5

model = sm.tsa.UnobservedComponents(
    data, level='local linear trend')
results = model.fit()
trend_component = results.level.smoothed

data.plot(label='Observed')
plt.plot(trend_component, label='Estimated')
plt.legend()
plt.show()

 

回答の選択肢:

(A) ノイズ成分
(B) 長期的な変動
(C) 短期的な変動
(D) 季節成分

Python 時系列分析 1,000本ノック– ノック69: 状態空間モデルによるフィルタリング –