Forecasting Long Memory Processes
Functions to forecast long memory processes using the fractional differencing operator and the cross-sectional aggregation method. Forecasting using the HAR model is also available.
LongMemory.Forecasters
— ModuleForecasters
This module contains functions to forecast a long memory time series using the fractional differencing method and the CSA method.
Author
LongMemory.Forecasters.csa_forecast
— Methodcsa_forecast(x::Array, h::Int, p::Real, q::Real, σ::Real)
Computes the forecast of a long memory time series using the CSA method.
Arguments
x::Array
: The time series.h::Int
: The number of periods to forecast.p::Real
: The parameter p of the CSA process.q::Real
: The parameter q of the CSA process.σ::Real
: The standard deviation of the forecast errors.
Output
xfor::Array
: The forecast of the time series as a matrix where the first column is the forecast, the second column is the lower confidence band, and the third column is the upper confidence band. The first T elements are the original time series.
Notes
Multiple dispatch is used to compute the forecast of a time series with or without confidence bands.
Examples
julia> csa_forecast(csa_gen(100,1.4,1.4), 10, 1.4, 1.4, 1.0)
LongMemory.Forecasters.csa_forecast
— Methodcsa_forecast(x::Array, h::Int, p::Real, q::Real)
Computes the forecast of a long memory time series using the CSA method.
Arguments
x::Array
: The time series.h::Int
: The number of periods to forecast.p::Real
: The parameter p of the CSA process.q::Real
: The parameter q of the CSA process.
Output
xfor::Array
: The forecast of the time series as a column vector. The first T elements are the original time series.
Notes
Multiple dispatch is used to compute the forecast of a time series with or without confidence bands.
Examples
julia> csa_forecast(csa_gen(100,1.4,1.4), 10, 1.4, 1.4)
LongMemory.Forecasters.csa_forecast_plot
— Methodcsa_forecast_plot(x::Array, h::Int, p::Real, q::Real, σ::Real)
Plots the forecast of a long memory time series using the CSA method.
Arguments
x::Array
: The time series.h::Int
: The number of periods to forecast.p::Real
: The parameter p of the CSA process.q::Real
: The parameter q of the CSA process.σ::Real
: The standard deviation of the forecast errors.
Output
p1::Plot
: The plot of the original time series and the forecast with confidence bands.
Notes
Multiple dispatch is used to plot the forecast of a time series with or without confidence bands. Plotting is done by calling the csa_forecast
function.
Examples
julia> csa_forecast_plot(csa_gen(100,1.4,1.4), 10, 1.4, 1.4, 1.0)
LongMemory.Forecasters.csa_forecast_plot
— Methodcsa_forecast_plot(x::Array, h::Int, p::Real, q::Real)
Plots the forecast of a long memory time series using the CSA method.
Arguments
x::Array
: The time series.h::Int
: The number of periods to forecast.p::Real
: The parameter p of the CSA process.q::Real
: The parameter q of the CSA process.
Output
p1::Plot
: The plot of the original time series and the forecast.
Notes
Multiple dispatch is used to plot the forecast of a time series with or without confidence bands. Plotting is done by calling the csa_forecast
function.
Examples
julia> csa_forecast_plot(csa_gen(100,1.4,1.4), 10, 1.4, 1.4)
LongMemory.Forecasters.csa_ma_coefs
— Methodcsa_ma_coefs(p::Real, q::Real, maxlags::Int)
Computes the MA coefficients of the CSA process with parameters p
and q
at lags 0, ..., maxlags-1
.
Arguments
p::Real
: The parameter p of the CSA process.q::Real
: The parameter q of the CSA process.maxlags::Int
: The number of lags to compute.
Output
ma_coefs::Array
: The MA coefficients of the CSA process with parametersp
andq
at lags 0, ...,maxlags-1
.
Notes
The MA coefficients are computed using the recursive formula for speed. The zero lag coefficient is included, it is theoretically 1.
Examples
julia> csa_ma_coefs(1.4, 1.4, 5)
LongMemory.Forecasters.fi_ar_coefs
— Methodfi_ar_coefs(d::Real, maxlags::Int)
Computes the AR coefficients of the fractional differenced process with parameter d
at lags 1, ..., maxlags
.
Arguments
d::Real
: The fractional differencing parameter.maxlags::Int
: The number of lags to compute.
Output
ar_coefs::Array
: The AR coefficients of the fractional differenced process with parameterd
at lags 1, ...,maxlags
.
Notes
The AR coefficients are computed using the recursive formula for speed. The zero lag coefficient is not computed, it is theoretically 1.
Examples
julia> fi_ar_coefs(0.2, 5)
LongMemory.Forecasters.fi_forecast
— Methodfi_forecast(x::Array, h::Int, d::Real, σ::Real)
Computes the forecast of a long memory time series using the fractional differencing method.
Arguments
x::Array
: The time series.h::Int
: The number of periods to forecast.d::Real
: The fractional differencing parameter.σ::Real
: The standard deviation of the forecast errors.
Output
xfor::Array
: The forecast of the time series as a matrix where the first column is the forecast, the second column is the lower confidence band, and the third column is the upper confidence band. The first T elements are the original time series.
Notes
Multiple dispatch is used to compute the forecast of a time series with or without confidence bands.
Examples
julia> fi_forecast(fi_gen(100,0.2), 10, 0.2)
LongMemory.Forecasters.fi_forecast
— Methodfi_forecast(x::Array, h::Int, d::Real)
Computes the forecast of a long memory time series using the fractional differencing method.
Arguments
x::Array
: The time series.h::Int
: The number of periods to forecast.d::Real
: The fractional differencing parameter.
Output
xfor::Array
: The forecast of the time series as a column vector. The first T elements are the original time series.
Notes
Multiple dispatch is used to compute the forecast of a time series with or without confidence bands.
Examples
julia> fi_forecast(fi_gen(100,0.2), 10, 0.2)
LongMemory.Forecasters.fi_forecast_plot
— Methodfi_forecast_plot(x::Array, h::Int, d::Real, σ::Real)
Plots the forecast of a long memory time series using the fractional differencing method.
Arguments
x::Array
: The time series.h::Int
: The number of periods to forecast.d::Real
: The fractional differencing parameter.σ::Real
: The standard deviation of the forecast errors.
p1::Plot
: The plot of the original time series and the forecast with confidence bands.
Notes
Multiple dispatch is used to plot the forecast of a time series with or without confidence bands. Plotting is done by calling the fi_forecast
function.
Examples
julia> fi_forecast_plot(fi_gen(100,0.2), 10, 0.2, 1.0)
LongMemory.Forecasters.fi_forecast_plot
— Methodfi_forecast_plot(x::Array, h::Int, d::Real)
Plots the forecast of a long memory time series using the fractional differencing method.
Arguments
x::Array
: The time series.h::Int
: The number of periods to forecast.d::Real
: The fractional differencing parameter.
Output
p1::Plot
: The plot of the original time series and the forecast.
Notes
Multiple dispatch is used to plot the forecast of a time series with or without confidence bands. Plotting is done by calling the fi_forecast
function.
Examples
julia> fi_forecast_plot(fi_gen(100,0.2), 10, 0.2)
LongMemory.Forecasters.gregory_coeffs
— Methodgregory_coeffs(N::Int)
Computes the Gregory coefficients for the harmonic inverse transformation.
Arguments
N::Int
: The number of coefficients to compute.
Output
coefs::Array
: The Gregory coefficients.
Notes
The first coefficient is 1/2 and the rest are computed using the recursive formula. The zero lag coefficient is not computed, it is theoretically 1.
Examples
julia> gregory_coeffs(5)
LongMemory.Forecasters.har_forecast
— Methodhar_forecast(x::Array, h::Int; flag::Bool = false, m::Array=[1,5,22])
Computes the forecast of a time series by fitting and recursevely forecasting the HAR model.
Arguments
x::Array
: The time series.h::Int
: The number of periods to forecast.
Output
xfor::Array
: The forecast of the time series. The first T-max(m) elements are the original time series.
Optional Arguments
flag::Bool
: If true, the output is a matrix where the first column is the forecast, the second column is the lower confidence band, and the third column is the upper confidence band. The default is false.m::Array
: The lags to include in the HAR model. The default is [1,5,22].
Examples
julia> har_forecast(fi_gen(100,0.2), 10)
LongMemory.Forecasters.har_forecast_plot
— Methodhar_forecast_plot(x::Array, h::Int; flag::Bool = true, m::Array=[1,5,22])
Plots the forecast of a time series by fitting and recursevely forecasting the HAR model.
Arguments
x::Array
: The time series.h::Int
: The number of periods to forecast.
Output
p1::Plot
: The plot of the original time series and the forecast.
Optional Arguments
flag::Bool
: If true, the output is a matrix where the first column is the forecast, the second column is the lower confidence band, and the third column is the upper confidence band. The default is true.m::Array
: The lags to include in the HAR model. The default is [1,5,22].
Notes
Multiple dispatch is used to plot the forecast of a time series with or without confidence bands. Plotting is done by calling the har_forecast
function.
Examples
julia> har_forecast_plot(figen(100,0.2), 10)
LongMemory.Forecasters.hitransform
— Methodhitransform(x::Array)
Computes the harmonic inverse transformation of a time series. For more details see Hassler and Hosseinkouchack (2020).
Arguments
x::Array
: The time series.
Output
x::Array
: The time series after the harmonic inverse transformation.
Notes
The harmonic inverse transformation is computed using the FFT.
Examples
julia> hitransform(fi_gen(100,0.2))
LongMemory.Forecasters.my_half_toeplitz
— Methodmy_half_toeplitz(coefs::Array)
Constructs a bottom Toeplitz matrix from the given coefficients.
Arguments
coefs::Array
: An array of coefficients.
Output
Toep::Array
: The bottom Toeplitz matrix constructed from the given coefficients.
Examples
julia> my_half_toeplitz([1, 2, 3])
Documentation for LongMemory.jl.