Long Memory Generation

Functions to generate time series long memory models. Methods include fractional differencing, error duration model, and à la cross-sectional aggregation.

LongMemory.GeneratingFunctions.arfi_genMethod
arfi_gen(T::Int, μ::Real, AR::Array, d::Real; σ=1)

Generate a time series with long memory parameter d and length T using the ARFIMA(p,d,0) model.

Arguments

  • T::Int: length of the time series
  • μ::Float64: mean of the time series
  • AR::Array: AR coefficients
  • d::Float64: fractional difference parameter

Optional arguments

  • σ::Float64: standard deviation of the time series

Output

  • x::Vector: time series with long memory

Notes

The code is inspired by the function dgp_arfima.m by Carlos Vladimir Rodríguez Caballero (2023)

Examples

julia> arfi_gen(100, 0, [0.2; -0.5], 0.4])
source
LongMemory.GeneratingFunctions.arfima_genMethod
arfima_gen(T::Int, μ::Real, AR::Array, d::Real, MA::Array; σ=1)

Generate a time series with long memory parameter d and length T using the ARFIMA(p,d,q) model.

Arguments

  • T::Int: length of the time series
  • μ::Float64: mean of the time series
  • AR::Array: AR coefficients
  • d::Float64: fractional difference parameter
  • MA::Array: MA coefficients

Optional arguments

  • σ::Float64: standard deviation of the time series

Output

  • x::Vector: time series with long memory

Notes

The code is inspired by the function dgp_arfima.m by Carlos Vladimir Rodríguez Caballero (2023)

Examples

julia> arfima_gen(100, 0, [0.2; -0.5], 0.4, [-0.3; 0.1]])
source
LongMemory.GeneratingFunctions.csa_genMethod
csa_gen(T::Int,p,q;μ=0,σ=1)

Generate a time series with long memory parameter q and length T using the cross-sectional aggregated process. See Vera-Valdes(2021) for details.

Arguments

  • T::Int: length of the time series
  • p::Float64: first parameter of the cross-sectional aggregated process
  • q::Float64: second parameter of the cross-sectional aggregated process, which is related to the fractional difference parameter d by q = 2(1-d)

Optional arguments

  • μ::Float64: mean of the time series
  • σ::Float64: standard deviation of the time series

Output

  • x::Vector: time series with long memory

Examples

julia> csa_gen(100,1.2,1.4)
source
LongMemory.GeneratingFunctions.csa_genMethod
csa_gen(T::Int,N::Int,p,q;t=0.01;μ=0,σ=1)

Generate a time series with long memory parameter q and length T using the cross-sectional aggregation of 'N' AR(1) processes à la Granger (1980).

Arguments

  • T::Int: length of the time series
  • N::Int: number of AR(1) processes
  • p::Float64: first parameter of the cross-sectional aggregated process
  • q::Float64: second parameter of the cross-sectional aggregated process, which is related to the fractional difference parameter d by q = 2(1-d)

Optional arguments

  • t::Float64: taper length
  • μ::Float64: mean of the time series
  • σ::Float64: standard deviation of the time series

Notes

Multiple dispatch is used to generate the finite sample process if 'N' is included in the arguments.

Output

  • x::Vector: time series with long memory

Examples

julia> csa_gen(100,100,1.2,1.4)
source
LongMemory.GeneratingFunctions.csadiffMethod
csadiff(x,p,q)

Generate long memory by using the moving average representation of the cross-sectional aggregated process using the fast Fourier algorithm. See Vera-Valdes(2021) for details.

Arguments

  • x::Vector: time series
  • p::Float64: first parameter of the cross-sectional aggregated process
  • q::Float64: second parameter of the cross-sectional aggregated process, which is related to the fractional difference parameter d by q = 2(1-d)

Output

  • dx::Vector: time series with long memory

Notes

q determines the long memory parameter of the cross-sectional aggregated process. The relation q = 2(1-d) holds, where d is the fractional difference parameter. We use autoregressive formulas to efficiently compute the coefficients of the moving average representation of the cross-sectional aggregated process.

Examples

julia> csadiff(randn(100,1),1.2,1.4)
source
LongMemory.GeneratingFunctions.edm_genMethod
edm_gen(T::Int,d; t=0.5, μ=0, σ=1)

Generate a time series with long memory parameter d and length T using the error duration model à la Parke (1999).

Arguments

  • T::Int: length of the time series
  • d::Float64: long memory parameter

Optional arguments

  • t::Float64: taper length
  • μ::Float64: mean of the time series
  • σ::Float64: standard deviation of the time series

Output

  • x::Vector: time series with long memory

Notes

The taper length t is the proportion of the time series that is pre-sampled to avoid the initial bias of the error duration model.

Examples

julia> edm_gen(100,0.4)
source
LongMemory.GeneratingFunctions.fiMethod
fi(T,d;μ=0,σ=1)

Generate a time series with long memory parameter d and length T using the fractional difference filter.

Arguments

  • T::Int: length of the time series
  • d::Float64: fractional difference parameter

Optional arguments

  • μ::Float64: mean of the time series
  • σ::Float64: standard deviation of the time series

Output

  • x::Vector: time series with long memory

Notes

Multiple dispatch is used for generation: If d is an integer, the function returns a time series with first or null difference. See fracdiff for details.

Examples

julia> fi(100,0.4)
source
LongMemory.GeneratingFunctions.fi_genMethod
fi_gen(T,d;μ=0,σ=1)

Generate a time series with long memory parameter d and length T using the fractional difference filter.

Arguments

  • T::Int: length of the time series
  • d::Float64: fractional difference parameter

Optional arguments

  • μ::Float64: mean of the time series
  • σ::Float64: standard deviation of the time series

Output

  • x::Vector: time series with long memory

Notes

Multiple dispatch is used for generation: If d is an integer, the function returns a time series with first or null difference. See fracdiff for details.

Examples

julia> fi_gen(100,0.4)
source
LongMemory.GeneratingFunctions.fi_survival_probsMethod

" fisurvivalprobs(N::Int,d)

Generate the survival probabilities of the error duration model à la Parke (1999).

Arguments

  • N::Int: length of the time series
  • d::Float64: fractional difference parameter

Output

  • p::Vector: survival probabilities

Notes

The survival probabilities are computed using the recursive formula p_{t+1} = p_t * (t + d - 1) / (t + 1 - d) to avoid numerical overflow.

Examples

julia> fi_survival_probs(100,0.4)
source
LongMemory.GeneratingFunctions.fracdiffMethod
fracdiff(x,d)

Compute the fractional difference of a time series x with fractional order d∈(-1/2,1/2).

Arguments

  • x::Vector: time series
  • d::Float64: fractional difference parameter

Output

  • dx::Vector: fractional difference of x

Notes

The function uses the fast Fourier transform to compute the convolution of the time series with the fractional difference filter. See Jensen and Nielsen (2014) for details. We use autoregressive formulas to efficiently compute the coefficients of the fractional difference filter.

Examples

julia> fracdiff(randn(100,1),0.4)
source
LongMemory.GeneratingFunctions.fracdiffMethod
fracdiff(x,d::Int)

Compute the first or null difference of a time series x. Multiple dispatch is used to return the same input or call the function diff from the Julia standard library if d=1 or d=0, respectively.

Arguments

  • x::Vector: time series
  • d::Int64: difference parameter

Output

  • dx::Vector: first or null difference of x

Examples

julia> fracdiff(randn(100,1),1)
source
LongMemory.GeneratingFunctions.hwfilterMethod
hwfilter(x::Array)

Filter a time series x using the harmonically weighted filter.

Arguments

  • x::Vector: time series

Output

  • hwx::Vector: filtered time series

Notes

The harmonically weighted filter is computed using the fast Fourier transform.

Examples

julia> hwfilter(randn(100,1))
source
LongMemory.GeneratingFunctions.hwp_genMethod
hwp_gen(T;μ=0,σ=1)

Generate a time series with long memory using the harmonically weighted process à la Hassler and Hosseinkouchack (2020).

Arguments

  • T::Int: length of the time series
  • μ::Float64: mean of the time series
  • σ::Float64: standard deviation of the time series

Output

  • x::Vector: time series with long memory

Examples

julia> hwp_gen(100)
source
LongMemory.GeneratingFunctions.sds_genMethod
sds_gen(T::Int,d; t=0.5, μ=0, σ=1)

Generate a time series with long memory parameter d and length T using the stochastic duration shocks model.

Arguments

  • T::Int: length of the time series
  • d::Float64: long memory parameter

Optional arguments

  • t::Float64: taper length
  • μ::Float64: mean of the time series
  • σ::Float64: standard deviation of the time series

Output

  • x::Vector: time series with long memory

Notes

The taper length t is the proportion of the time series that is pre-sampled to avoid the initial bias of the model. Reference: Parke (1999)

Examples

julia> sds_gen(100,0.4)
source

Documentation for LongMemory.jl.