Skip to content

FastForecast is an R package that aims to provide a fast and accurate forecasting method for time series data.

License

Notifications You must be signed in to change notification settings

NoaLRX/FastForecast

Repository files navigation

FastForecast

The goal of FastForecast is to provide a fast and accurate forecasting method for time series data. This package takes a dataframe of several time series as input, and can correct for atypical points, seasonality and stationarity. It then generates forecasting models using 6 econometric models and 6 Machine-Learning models. It also allows you to display series graphically, calculate forecast quality indicators and display them in table form as well as graphically.

1 Installation

You can install the development version of FastForecast from GitHub with:

# install.packages("devtools")
devtools::install_github("NoaLRX/FastForecast")

1.1 Help & Documentation

help(package="FastForecast")

# Get the list of functions available from the package
ls("package:FastForecast")

2 Functions

Here are the different functions that you can use in this package.

2.1 Time-Series transformation

library(FastForecast)
ts_transfo <- function(DATAFRAME, YEAR, MONTH, FREQUENCY)

This function transforms the $n$ columns of a dataframe into $n$ individuals Time Series.

Each time series will take the name "ts_" followed by the name of the column in the dataframe.

To use this function you need to pass a dataframe as the first argument, a year, month and frequency as the last argument.

For example:

ts_transfo(land_w, 2013, 01, 4) # Start the 1st January 2013, with quarterly data
ts_transfo(land_w, 1996, 05, 12) # Start the 5 May 1996, with monthly data

2.2 Atypical Points Correction

This function takes no argument, and will correct your previously created time-series and correct any atypical points. This function use the tso() function from the package tsoutliers.

library(tsoutliers)
atypical_tso()

2.3 Seasonality Detection

This function takes no argument, and will detect any seasonality on your previously created time-series. This function use the combined_test() and seasdum() functions from the package seastests.

library(seastests)
seaso_detect()

2.4 Seasonality Correction

This function takes no argument, and will correct any seasonality on your previously created time-series. This function use the stl() function from the package stats.

library(stats)
seaso_correct()

2.5 Seasonality Verification

This function takes no argument, and will detect any seasonality on your previously created and corrected time-series. This function use the combined_test() and seasdum() functions from the package seastests.

The main purpose of this function is to ensure that there is no seasonality in the corrected series.

library(seastests)
seaso_verif()

2.6 Stationarity Treatment

This function takes no argument, and will detect and correct, if necessary, the time series that are not stationary. The function detect stationarity with the adf.test() function from the package tseries.

library(tseries)
statio()

If after a first differentiation, the time-serie is still not stationary, the function will differentiate a second time. If after that, the time serie is still not stationary, the function will print a message and stop any treatment.

2.7 Aligning Time-Series length

This function takes no argument, and will align your corrected time series that may have different length, because of differentiations.

allign_ts()

2.8 Creating a dataframe with each time-series

This function takes one argument, the $Y_t$ variable, the one that you’re trying to predict.

This function will create a single data frame results_df with each time series as columns, with the $Y_t$ as the first variable.

create_df("my_Y_variable")

2.9 Variables Selection

This function uses two methods of variables selections. The first is the “BestSubSet” method from the leaps package. The second is the “Gets” method from the gets package.

This function takes one argument, the $Y_t$ variable, the one that you’re trying to predict.

vselec("my_Y_variable")

After using the function, you should modify your results_df dataframe and remove the variables not retained by the two methods.

2.10 Econometrics Forecasting Models

This function takes three arguments:

  • DATAFRAME: Your dataframes with $n$ rows and $p$ columns (with $n &gt; p$)

  • Y_VARIABLE: Your $Y_t$ variable, meaning the variable you’re trying to predict.

  • PERIOD: The frequency of your time-series (12 for monthly, 4 for quarterly…)

eco_models(df, "My_Y_Variable", 12)
eco_models(dataframe, "Gas_Price", 4)

This function uses the following models and packages:

2.11 Machine-Learning Forecasting Models

This function takes three arguments:

  • DATAFRAME: Your dataframes with $n$ rows and $p$ columns (with $n &gt; p$)

  • Y_VARIABLE: Your $Y_t$ variable, meaning the variable you’re trying to predict.

ml_models(df, "My_Y_Variable")

This function uses the following models and packages:

About

FastForecast is an R package that aims to provide a fast and accurate forecasting method for time series data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages