Tùng Kiều Vũ Thanh Tùng Kiều Vũ Thanh - 1 month ago 22
Python Question

Python vs MATLAB: ARIMA Model with Known Parameter Values

In MATLAB, we can specify an ARIMA(p, D, q) model with known parameter values by using the following function

enter image description here

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)


In Python or R, Can I do this to build my own model?

After that, I need use this model to predict my dataset

enter image description here

In Python or R, Can I do this?

Answer

Python StatsModels example below.

In.

test_model = sm.tsa.ARIMA(test_data['log_PI'], [1, 1, 0]).fit()
test_model.params

Out.

const             0.001166
ar.L1.D.log_PI    0.593834
dtype: float64

In.

_ = test_model.plot_predict(end="2016-12")

Out.

enter image description here

In.

# 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")

Out.

enter image description here