local real peak0 trough0
sstats(min) startl endl %if(peak,t,%na)>>peak0 %if(trough,t,%na)>>trough0
if %defined(up)
set(first=peak0<trough0) up startl endl = up{1}-peak{1}+trough{1}
if %defined(down)
set(first=peak0>trough0) down startl endl = down{1}-trough{1}+peak{1}
The SSTATS is used to determine which phase the process is in at the start by determining which turning point is hit first. If it's a peak, then the process is starting in an up phase and if it's a trough, it's starting in a down phase.Generating phase dummies for turning points
Generating phase dummies for turning points
If you have two series of dummy variable "turning points", you can generate dummies for the phases using a calculation like the following: