Git Product home page Git Product logo

btcforecast's Introduction

BTCForecast

Bitcoin Forecasting Using SARIMA By Hansaka Wijaya (1706985962), Muhammad Adisatriyo (1706986031) & Hilman Maulana (1706985975)

Description

This is a sample project for Bitcoin Price Forecasting using SARIMA method. Source code and data can be downloaded through this github repo above.

Seasonal ARIMA is an ARIMA model that contains seasonal factors. Season means that the data has a tendency to repeat the pattern of behavior in the season period. Usually it can be weekly, monthly, quarterly, semester. For example, seasonal one year for monthly data. Therefore, the seasonal time series has characteristics that are indicated by the strong continuous correlation in the seasonal distance (season period), that is, the time associated with many observations on the season period.

There are three trend elements that require configuration.

They are the same as the ARIMA model,specifically:

p - the number of lag observations to include in the model, or lag order. (AR) d - the number of times that the raw observations are differenced, or the degree of differencing. (I) q - the size of the moving average window, also called the order of moving average.(MA)

The Seasonal Autoregressive Integrated Moving Average (SARIMA) model is a development of the ARIMA model. The following are the seasonal steps for SARIMA:

  1. Identify seasonal data using ACF / PACF in seasonal lags.
  2. Perform differencing of data in accordance with the season taken differencing on season is used to eliminate seasonality because there is a possibility that the data used requires differencing.

Overview

Stationarity check and Seasonal decomposition

If a timeseries is stationary, it implies the lack of broad trends (changes in mean and variance over time) in the data. This is important as a consideration in time series forecasting.

The statsmodels library provides a seasonal_decompose method, an implementation of the naive decomposition method, which we will use to examine our timeseries. 1st

The p-value indicates that series is not stationary.

Most interesting is the seasonal component which was extracted, which looks like it repeats itself on a yearly basis.

We can also see that the residuals are fairly constant until around the start of 2017.

Box-Cox Transformation

We use the Box-Cox transformation to suppress some of the variance.

The Box-Cox transformation is a family of power transformations indexed by a parameter lambda. Whenever you use it the parameter needs to be estimated from the data. In time series the process could have a non-constant variance. if the variance changes with time the process is nonstationary. It is often desirable to transform a time series to make it stationary. Sometimes after applying Box-Cox with a particular value of lambda the process may look stationary. It is sometimes possible that even if after applying the Box-Cox transformation the series does not appear to be stationary, diagnostics from ARIMA modeling can then be used to decide if differencing or seasonal differencing might be useful to to remove polynomial trends or seasonal trends respectively. After that the result might be an ARMA model that is stationary. If diagnostics confirm the orders p an q for the ARMA model, the AR and MA parameters can then be estimated. 2nd The p-value indicates that series is still not stationary.

Differencing

When building models to forecast time series data (like ARIMA), another pre-processing step is differencing the data until we get to a point where the series is stationary. Models account for oscillations but not for trends, and therefore, accounting for trends by differencing allows us to use the models that account for oscillations.

One method of differencing data is seasonal differencing, which involves computing the difference between an observation and the corresponding observation in the previous year. 3rd The p-value indicates that series is still not stationary.

Regular differentiation

Sometimes it may be necessary to difference the data a second time to obtain a stationary time series, which is referred to as second order differencing. 4th The p-value indicates that series is stationary as the computed p-value is lower than the significance level alpha = 0.05.

Autocorrelation

Autocorrelation is the correlation of a time series with the same time series lagged. It summarizes the strength of a relationship with an observation in a time series with observations at prior time steps.

We create autocorrelation factor (ACF) and partial autocorrelation factor (PACF) plots to identify patterns in the above data which is stationary on both mean and variance. The idea is to identify presence of AR and MA components in the residuals.

5th

6th

ARIMA Model

We will iteratively explore different combinations of parameters. For each combination we fit a new ARIMA model with SARIMAX() and assess its overall quality.

We will use the AIC (Akaike Information Criterion) value, returned with ARIMA models fitted using statsmodels. The AIC measures how well a model fits the data while taking into account the overall complexity of the model. A model that fits the data very well while using lots of features will be assigned a larger AIC score than a model that uses fewer features to achieve the same goodness-of-fit. Therefore, we are interested in finding the model that yields the lowest AIC value.

7th

Analysis of Results

The coef column shows the weight (i.e. importance) of each feature and how each one impacts the time series. The P>|z| column informs us of the significance of each feature weight. Here, each weight has a p-value lower or close to 0.05, so it is reasonable to retain all of them in our model.

8th

Monthly Prediction

The prediction starts from 31/10/2015 to 31/7/2020. As we can see, in 2020 the price of the bitcoin is forecasted to be raising. 8th

License

MIT License

Copyright (c) 2019 MWLKR

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The software is provided "as is", without warranty of any kind, express or Implied, including but not limited to the warranties of merchantability, Fitness for a particular purpose and noninfringement. In no event shall the Authors or copyright holders be liable for any claim, damages or other Liability, whether in an action of contract, tort or otherwise, arising from, Out of or in connection with the software or the use or other dealings in the Software.

btcforecast's People

Contributors

mwlkr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.