Python 与 MATLAB:具有已知参数值的 ARIMA 模型
Python vs MATLAB: ARIMA Model with Known Parameter Values
在 MATLAB 中,我们可以使用以下函数指定具有已知参数值的 ARIMA(p, D, q) 模型
tdist = struct('Name','t','DoF',10);
model = arima('Constant',0.4,'AR',{0.8,-0.3},'MA',0.5,...
'D',1,'Distribution',tdist,'Variance',0.15)
在 Python 或 R 中,我可以这样做来构建自己的模型吗?
之后,我需要使用这个模型来预测我的数据集
在 Python 或 R 中,我可以这样做吗?
Python 下面是 StatsModels 示例。
在.
test_model = sm.tsa.ARIMA(test_data['log_PI'], [1, 1, 0]).fit()
test_model.params
出来了。
const 0.001166
ar.L1.D.log_PI 0.593834
dtype: float64
在.
_ = test_model.plot_predict(end="2016-12")
出来了。
在.
# Constant param change
test_model.params.const = 0.02
# test_model.params[0] = 0.02
# AR params change
# test_model.params[1] = 0.9
# test_model.arparams[0] = 0.9
_ = test_model.plot_predict(end="2016-12")
出来了。
在 MATLAB 中,我们可以使用以下函数指定具有已知参数值的 ARIMA(p, D, q) 模型
tdist = struct('Name','t','DoF',10);
model = arima('Constant',0.4,'AR',{0.8,-0.3},'MA',0.5,...
'D',1,'Distribution',tdist,'Variance',0.15)
在 Python 或 R 中,我可以这样做来构建自己的模型吗?
之后,我需要使用这个模型来预测我的数据集
在 Python 或 R 中,我可以这样做吗?
Python 下面是 StatsModels 示例。
在.
test_model = sm.tsa.ARIMA(test_data['log_PI'], [1, 1, 0]).fit()
test_model.params
出来了。
const 0.001166
ar.L1.D.log_PI 0.593834
dtype: float64
在.
_ = test_model.plot_predict(end="2016-12")
出来了。
在.
# Constant param change
test_model.params.const = 0.02
# test_model.params[0] = 0.02
# AR params change
# test_model.params[1] = 0.9
# test_model.arparams[0] = 0.9
_ = test_model.plot_predict(end="2016-12")
出来了。