CKSVAR models

ThresholdStability.jl includes tools to convert censored and kinked structural vector autoregressive (CKSVAR) models into TVAR models. Information on CKSVAR models is available in Mavroeidis (2021).

Ox code to estimate CKSVAR models is available here.

ThresholdStability.CKSVAR_to_TARFunction
CKSVAR_to_TAR(C, Cstar, βtilde, nlags)

Returns pair (Σ, X) where Σ is a set of matrices corresponding to the CKSVAR model (with censored variable in levels) in TVAR form, and X is a set encoding state-space constraints.

source
ThresholdStability.CKSVAR_to_companionFDFunction
CKSVAR_to_companionFD(F, Fstar, βtilde, nlags; diff=true)

Converts CKSVAR model estimated with the censored variable entering in first differences into companion form. The default setting diff=true returns the companion form with the censored variable entering in first differences. To retrieve the companion form with censored variable entering in levels, set diff=false.

source

Construction of automata

CKSVAR_to_TAR outputs a set of matrices generated in an order generated by the perms function (as well as a set encoding state space constraints.)

automaton_constructor provides a method to construct an automaton suitable for use with a CKSVAR model converted using CKSVAR_to_TAR, assuming this order. It is also suitable for any other set of matrices that is ordered in a similar way (see examples/AR2.jl).

ThresholdStability.automaton_constructorFunction
automaton_constructor(Σ::AbstractVector{<:AbstractMatrix})

Generates an automaton tracking admissible transitions between states. Σ is a vector of matrices corresponding to a TAR model, assuming a default order generated by perms.

automaton_constructor(Σ::AbstractVector{<:AbstractMatrix}, seqlist)

Generates an automaton tracking admissible transitions between states given a custom list of regime sequences.

source

Automata can also be constructed manually using HybridSystems.jl, which ThresholdStability re-exports.

For example, the following code constructs an automaton with three states, loops at states 1 and 3, and edges from states 1 to 2, 2 to 3, and 3 to 1, with the tail node indices as labels.

using ThresholdStability

G = GraphAutomaton(3)  # initializes automaton with 3 states as an edgeless graph
add_transition!(G, 1, 1, 1)
add_transition!(G, 1, 2, 1)  # adds edge from state 1 to 2, with label 1
add_transition!(G, 2, 3, 2)
add_transition!(G, 3, 3, 3)
add_transition!(G, 3, 1, 3)
G

# output

GraphAutomaton{Graphs.SimpleGraphs.SimpleDiGraph{Int64}, Graphs.SimpleGraphs.SimpleEdge{Int64}}(Graphs.SimpleGraphs.SimpleDiGraph{Int64}(5, [[1, 2], [3], [1, 3]], [[1, 3], [1], [2, 3]]), Dict{Graphs.SimpleGraphs.SimpleEdge{Int64}, Dict{Int64, Int64}}(Edge 1 => 2 => Dict(2 => 1), Edge 3 => 1 => Dict(5 => 3), Edge 1 => 1 => Dict(1 => 1), Edge 3 => 3 => Dict(4 => 3), Edge 2 => 3 => Dict(3 => 2)), 5, 5)

Indicator

indicator can be used in building functions to convert models to TVAR form. Examples: CKAR(2).

ThresholdStability.indicatorFunction
indicator(y, b; indregion=:above, ineq=:nonstrict)

Indicator variable of default form $\mathbf{1}\{y ≥ b\}$. The inequality can be made strict and the direction of inequality can be reversed.

Arguments

  • ineq=:nonstrict (default): calculates $\mathbf{1}\{y ≥ b\}$ or

$\mathbf{1}\{y ≤ b\}$.

  • ineq=:strict: calculates $\mathbf{1}\{y > b\}$ or $\mathbf{1}\{y < b\}$.
  • indregion=:above (default): calculates $\mathbf{1}\{y ≥ b\}$ or

$\mathbf{1}\{y > b\}$.

  • indregion=:below: calculates $\mathbf{1}\{y ≤ b\}$ or $\mathbf{1}\{y < b\}$.
source