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.greatestConvexMinorantFunction
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)

source
TrendDecomposition.leastConcaveMajorantMethod
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)

source

Autoregression AR(p) Estimation

TrendDecomposition.arBurgFunction
arBurg(y :: Vector, p :: Int; intercept::Bool = false)

Fits an autoregressive model of order p to time series y using Burg's method.

Returns the tulpe (Φ, σ²), where Φ is the vector of estimated coefficients and σ² is the variance of the error terms.

source
TrendDecomposition.arOLSFunction
arOLS(y :: Vector, p :: Int; intercept::Bool = false)

Fits an autoregressive model of order p to time series y using ordinary least square (OLS).

Returns the tulpe (Φ, σ²), where Φ is the vector of estimated coefficients and σ² is the variance of the error terms.

source
TrendDecomposition.arYuleWalkerFunction
arYuleWalker(y :: Vector, p :: Int)

Fits an autoregressive model of order p to time series y using the Yule-Walker estimators.

Returns the tulpe (Φ, σ²), where Φ is the vector of estimated coefficients and σ² is the variance of the error terms.

source
TrendDecomposition.arDurbinLevinsonFunction
arDurbinLevinson(y :: Vector, p :: Int;
                      intercept::Bool = false, pacf::Bool = false)

Fits an autoregressive model of order p to time series y using the Durbin-Levinson recursion.

Returns the tulpe (Φ, σ²), where Φ is the vector of estimated coefficients and σ² is the variance of the error terms.

source
TrendDecomposition.autoCovarianceFunction
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 sclar and autocovariance vector is returned.

source

Experimental

Here are functions that are only experimental in use but could be useful for some specific purposes.

TrendDecomposition.trendL1FilterFunction
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

source