This time I would like to do a simulation of Autoregressive model in Natural Gas Price using Python.
- Import the dataset and convert into panda dataframe
- Replace the missing values with mean values
- import Autoregressive library, we provide train model and fit the model
- Considering how many lag variables in our model
-
Getting coefficient for lag values. By getting the values of the coefficient, we could predict the future values.
-
Otherwise we could use predict functions. It will later show you the last 7 of predicted values. Later we could also directly called the predicted values, in this case we called the first predicted values.
- We run the mse function, the result is bigger than the mse value we got from naive model (0.013473258789010692 > 0.004342142857142858). It indicates that the time series model has random walk problem.
- Next, we would like to run walk forward validation. First, define df and how many values we would like to set as train test
- Run the syntax to obtain the predicted values
- Obtain the mse values and plot the graphs. As we can see the mse values decreased rather than mse values that has been run in AR model (0.005255871278210083 < 0.013473258789010692). However it still bigger than mse in naive model (0.005255871278210083 > 0.004342142857142858).