Calculating Average Duration in a MS Model

For questions and discussion related to graphs, reports, and other output, including issues related to presenting or publishing results.
alexecon
Posts: 72
Joined: Fri Oct 30, 2015 12:16 pm

Calculating Average Duration in a MS Model

Unread post by alexecon »

I would like to calculate the average duration of a particular regime in a two-state Markov-switching model. Presumably, this can work as follows:
1) Set all 'smoothed' regime probabilities under 0.5 equal to 0 and all probabilities of 0.5 or above equal to 1
2) Count the number of times a 1 (or, more often, a group of 1s) is preceded and followed by 0
3) Name this number "x"
4) Count the total number of 1s
5) Name this number "y"
5) Compute average duration as y/x
Is this the way to go about it? If yes, how does one implement 2) in the list?
Thank you.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Calculating Average Duration in a MS Model

Unread post by TomDoan »

sstats mystart+1 myend myregime==1.and.myregime{1}==0>>x myregime==1>>y
disp "Average duration" y/x

where mystart, myend and myregime are all whatever's appropriate to your model. The count for x might differ by 1 from the strict definition in step 2 if the sample ends with a 1 since it only counts the number of times a 1 is preceded by a 0. Of necessity, all strings of 1's have to end with a 0 except at the end of the sample.
Post Reply