Create Threshold Transitions
This example shows how to create a threshold transition object and access its properties.
Threshold-switching models (
tsVAR) switch among states, and corresponding submodels, when the value of a univariate threshold variable changes relative to a set of threshold levels. Threshold transitions can be discrete (TAR models), resulting in abrupt changes of state, or smooth (STAR models), resulting in a continuous mixing of states. The switching mechanism is encapsulated in a threshold transition object of type
threshold. Each object describes the levels and rates of the transitions it contains.
Discrete Threshold Transitions
Create a threshold transition object with discrete transitions at levels 2 and 8.
ttD = threshold([2 8])
ttD = threshold with properties: Type: 'discrete' Levels: [2 8] Rates:  StateNames: ["1" "2" "3"] NumStates: 3
ttD is a
threshold object representing threshold transitions of an arbitrary threshold variable. The command line lists its properties; you can access the value of a property by using dot notation, for example, access the number of states using
The two levels divide the threshold variable range into three distinct states labeled "1", "2" and "3" by default. The states correspond to values of a threshold variable in the intervals , , and , respectively.
Smooth Threshold Transitions
Transition functions describe each transition. Their range includes values between 0 and 1. Smooth transitions require a rate that indicates how quickly the mixing of states occurs in the neighborhood of a threshold level. Three common types of smooth transition functions are : asymmetric transitions associated with normal and logistic cumulative distribution functions, and symmetric transitions associated with exponential functions.
Create threshold transitions with logistic transitions among all states, and assign names
"Hi" to the states. Specify that the transition rate from
"Med" is 3.5, and the rate from
"Hi" is 1.5.
ttL = threshold([2 8],Type="logistic",Rates=[3.5 1.5], ... StateNames=["Low" "Med" "High"])
ttL = threshold with properties: Type: 'logistic' Levels: [2 8] Rates: [3.5000 1.5000] StateNames: ["Low" "Med" "High"] NumStates: 3
Custom Transition Function
threshold function supports custom transition functions, specified as a function handle using the name-value argument TransitionFunction.
Create a function that models the extreme-value cumulative distribution. The inputs to the transition function are the transition variable data
z, threshold levels
t, and rates
tfun = @(z,t,r)evcdf(z,t,1/r);
Create threshold transition with extreme-value cumulative distribution transitions.
ttEV = threshold([2 8],Type="custom",TransitionFunction=tfun, ... Rates=[3.5 1.5])
ttEV = threshold with properties: Type: 'custom' Levels: [2 8] Rates: [3.5000 1.5000] StateNames: ["1" "2" "3"] NumStates: 3
The transition function is hidden in the display, but accessible, like any other property, by using dot notation.
F = ttEV.TransitionFunction
F = function_handle with value: @(z,t,r)evcdf(z,t,1/r)