Additional Functions
Useful or Helper Functions
Here are functions that have a usecase in other areas that fall not strictlly into any offical categories for trend estimation.
TrendDecomposition.greatestConvexMinorant — Function
greatestConvexMinorant(y :: Vector)Computes greatest convex minorant of series y using the pool-adjecent-violators algorithm
Returns the coordinates of the knots as a tuple (x, y)
TrendDecomposition.leastConcaveMajorant — Method
leastConcaveMajorant(y :: Vector)Computes least concave majorant (lcm) of series y using the pool-adjecent-violators algorithm
Returns the coordinates of the knots as a tuple (x, y)
Autocovariance & PACF
TrendDecomposition.autoCovariance — Function
autoCovariance(X :: Vector, T::Int;
maxLag::Int=T-1, method::Symbol=:classic, covar::Bool=false, demean::Bool=false)Calculates the autocovariance of time series X with length T, by default it is assumed that the data is already centered (demean=false). For large series the method :fourier can be choosen, which uses the fast fourier transform.
Returns a (maxLag x 1) vector of the autocovariance. For the method :fourier with covar=true a tulpe containing the covariance scalar and autocovariance vector is returned.
TrendDecomposition.PACF — Function
function PACF(y :: Vector, p :: Int)Computes the partial autocorrelation function (PACF) up to lag p.
Returns (px1) vector containing the first p values of the PACF.
Forecasting
TrendDecomposition.maForecast — Function
maForecast(y :: Vector, θ :: Vector; h::Int = 1)Forecast time series y (with length T) as an MA(q) process with parameter vector θ. The forecast horizon is given by h.
Returns (max(h, q)x1) vector of forecast values for time points T+1, ..., T+max(h, q).
TrendDecomposition.armaForecast — Function
armaForecast(y :: Vector, ϕ :: Vector, θ :: Vector; h::Int = 1)Forecast time series y (with length T) as an ARMA(p, q) process with parameter vectors ϕ and θ. The forecast horizon is given by h.
Returns (hx1) vector of forecast values for time points T+1, ..., T+h.
Experimental
Here are functions that are only experimental in use but could be useful for some specific purposes.
TrendDecomposition.trendL1Filter — Function
trendL1Filter(y :: Vector, λ :: Real; m = 2, max_iter=20, method = :ADMM)Placeholder for trendL1Filter extension, when using TrendDecomposition together with other Julia packages like Convex.jl and SCS.jl.
This function provides the generic use of serveral optimization methods to compute a numerical solution. Following methods are implmented: :ADMM -> alternating direction method of multipliers :ConvexSCS -> SCS solver with Convex.jl. Prerequisite! Import necessary modules with: using Convex, SCS
The function returns the estimated trend component