Plots for Long Memory
Functions to plot the autocorrelation function, log-variance, log-periodogram, rescaled range, and detrended fluctuation analysis. The plots help to visualize the presence of long memory in the data. The LMPlot function plots the time series, autocorrelation function, log-periodogram, and log-variance in a single figure.
Since version 2.0, the plotting functions are provided through a package extension: they are available once Plots.jl is loaded. Install Plots once with import Pkg; Pkg.add("Plots") and then use
using LongMemory, Plots
LMPlot(fi_gen(1000, 0.3))The forecasting plots, such as fi_forecast_plot, work in the same way.
LongMemory.ClassicEstimators.autocorrelation_plot — Function
autocorrelation_plot(x::AbstractArray, k::Int)Computes the autocorrelation function of a time series.
Requires Plots.jl to be loaded, e.g. with using LongMemory, Plots.
Arguments
x::Array: The time series.k::Int: The lag of the autocorrelation.
Output
p1::Plots.Plot: The autocorrelation function.
Examples
julia> autocorrelation_plot(randn(100), 10)LongMemory.ClassicEstimators.log_variance_plot — Function
log_variance_plot(x::AbstractArray; m::Int=100, slope::Bool=false, slope2::Bool=false)Produces the log-variance plot of a time series.
Requires Plots.jl to be loaded, e.g. with using LongMemory, Plots.
Arguments
x::Array: The time series.
Output
p1::Plots.Plot: The log-variance plot.
Optional arguments
m::Int: The number of partitions of the time series. Default is 100. A value of m ≈ length(x)/2 is recommended.slope::Bool: If true, the slope of the linear regression is displayed.slope2::Bool: If true, the theoretical slope for a short memory process is displayed.
Notes
This function uses the linear regression method on the log of the variance plot to estimate the long memory parameter.
Examples
julia> log_variance_plot(randn(100,1); m = 40)LongMemory.LogPeriodEstimators.periodogram_plot — Function
periodogram_plot(x::AbstractArray; slope::Bool=false)Plots the log-periodogram of a time series x.
Requires Plots.jl to be loaded, e.g. with using LongMemory, Plots.
Arguments
x::Vector: time series
Output
p1::Plots.Plot: log-periodogram
Optional arguments
slope::Bool: If true, the slope of the linear regression is displayed. Default is false.
Examples
julia> periodogram_plot(randn(100,1))LongMemory.ClassicEstimators.rescaled_range_plot — Function
rescaled_range_plot(x::AbstractArray; k::Int = 100, slope::Bool = false, slope2::Bool = false)Produces the rescaled range plot of a time series.
Requires Plots.jl to be loaded, e.g. with using LongMemory, Plots.
Arguments
x::Array: The time series.
Output
p1::Plots.Plot: The rescaled range plot.
Optional arguments
k::Int: The number of partitions of the time series. Default is 100.slope::Bool: If true, the slope of the linear regression is displayed.slope2::Bool: If true, the theoretical slope for a short memory process is displayed.
Notes
This function uses the linear regression method on the log of the rescaled range to estimate the long memory parameter. The Hurst coefficient is related to the long memory parameter d by the formula H = d + 1/2.
Examples
julia> rescaled_range_plot(randn(300,1))LongMemory.ClassicEstimators.dfa_plot — Function
dfa_plot(x::AbstractArray; k::Int = 20, slope::Bool = false, slope2::Bool = false)Produces the detrended fluctuation analysis (DFA) plot of a time series.
Requires Plots.jl to be loaded, e.g. with using LongMemory, Plots.
Arguments
x::Array: The time series.
Output
p1::Plots.Plot: The DFA plot.
Optional arguments
k::Int: The number of box sizes. Default is 20.slope::Bool: If true, the slope of the linear regression is displayed.slope2::Bool: If true, the theoretical slope for a short memory process is displayed.
Notes
The slope of the regression estimates the Hurst coefficient H = d + 1/2. See dfa_est.
Examples
julia> dfa_plot(randn(500))LongMemory.DataExamples.LMPlot — Function
LMPlot(x::AbstractArray;lags::Int=50,name::String="Time series")Returns a plot of the time series x.
Requires Plots.jl to be loaded, e.g. with using LongMemory, Plots.
Arguments
x::Array: The time series.
Optional arguments
lags::Int: The number of lags to use in the autocorrelation function.name::String: The name of the time series to use in the plot.
Output
pp::Plot: Four plots are returned in a 2x2 grid:- The first plot is the time series of
x. - The second plot is the autocorrelation function of
xusing theautocorrelation_plotfunction. - The third plot is the periodogram of
xusing theperiodogram_plotfunction. - The fourth plot is the variance plot of
xusing thevariance_plotfunction.
- The first plot is the time series of
Examples
julia> LMPlot(randn(100))Documentation for LongMemory.jl.