Plots for Long Memory
Functions to plot the autocorrelation function, log-variance and log-periodogram. The plots help to visualize the presence of long memory in the data. The LMplot
function plots the time serries, autocorrelation function, log-variance, and log-periodogram in a single figure.
LongMemory.ClassicEstimators.autocorrelation_plot
— Functionautocorrelation_plot(x::Array, k::Int)
Computes the autocorrelation function of a time series.
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
— Functionlog_variance_plot(x::Array; m::Int=100, slope::Bool=false, slope2::Bool=false)
Produces the log-variance plot of a time series.
Arguments
x::Array
: The time series.
Output
d_var::Real
: The estimated long memory parameter computed as (beta+1)/2, where beta is the slope of the linear regression of the log of the variance plot.
Optional arguments
m::Int
: The number of partitions of the time series. Default is 20. 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
— Functionperiodogram_plot(x::Array; slope::Bool=true)
Plots the log-periodogram of a time series x
.
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.
Examples
julia> periodogram_plot(randn(100,1))
LongMemory.ClassicEstimators.rescaled_range_plot
— Functionrescaled_range_plot(x::Array; k::Int = 100, slope::Bool = false, slope2::Bool = false)
Produces the rescaled range plot of a time series.
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.DataExamples.LMPlot
— FunctionLMPlot(x::Array;lags::Int=50,name::String="Time series")
Returns a plot of the time series x
.
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
x
using theautocorrelation_plot
function. - The third plot is the periodogram of
x
using theperiodogram_plot
function. - The fourth plot is the variance plot of
x
using thevariance_plot
function.
- The first plot is the time series of
Examples
julia> LMPlot(randn(100))
Documentation for LongMemory.jl.