altheanabila / Autoregressive-Model-in-Natural-Gas-Price

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autoregressive-Model-in-Natural-Gas-Price

This time I would like to do a simulation of Autoregressive model in Natural Gas Price using Python.

  1. Import the dataset and convert into panda dataframe

pic1

  1. Replace the missing values with mean values

pic2

  1. import Autoregressive library, we provide train model and fit the model

pic3

  1. Considering how many lag variables in our model

pic4

  1. Getting coefficient for lag values. By getting the values of the coefficient, we could predict the future values. pic5

  2. 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.

pic6

  1. 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.

pic7

  1. Next, we would like to run walk forward validation. First, define df and how many values we would like to set as train test

pic8

  1. Run the syntax to obtain the predicted values

pic9

  1. 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).

pic 10

About


Languages

Language:Jupyter Notebook 100.0%