Page 1 of 1
Markov Switching Model not outputting consistent results across datasets
Posted: Sun Jun 25, 2017 7:41 pm
by vonkraush
Hello all,
I am working on a project that basically involves running the same regression on a large number of data sets, where each set is really the same data set taken at a different date. (So it's just a matrix of real-time data for the same set). The real-time data set I'm using in for the Leading Economic Index, and I'm trying to use it to predict the probability of recession. The data is ordered from LEI1 to LEI575 where LEI1 is the first version of the series available to me and LEI575 is the most recent version available.
One of the regression models I am attempting to make work is a very simple Markov-Chain switching regression, where I am trying to endogenously estimate the probability of the series being in state 1 or state 2, using the probability of state 2 as a stand-in for the probability of recession.
Code: Select all
group RTD LEI*
for !i=1 to RTD.count
equation eq{!i}.switchreg(type="markov", heterr) LEI{!i} c @prv c
eq{!i}.makergmprobs(type="filt", view="sheet") fin{!i}a fin{!i}b
next
group prob1 fin*a
group prob2 fin*b
When I generate one or two series from the data the results are very reasonable and seem to match up well with the actual historic occurrence of recession. However when I use this code to generate regression data for all series at once the results vary wildly. For any given date the probability of there being a recession swings wildly from unlikely to highly likely between series, even for two dates next to each other, where you wouldn't expect substantial changes in the series.
This is very disconcerting. Am I doing something wrong with my code? This should be very doable but I can't figure it out.
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Sun Jun 25, 2017 9:00 pm
by startz
Nonlinear methods require starting values. In this case they are stored in the c vector. Since running a regression changes the values in c, the order of running the estimates can matter.
Try inserting
before switchreg and see what happens.
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Mon Jun 26, 2017 9:27 am
by vonkraush
Thanks for the reply! To be clear where should I put the c=0, before the loop or in the loop between 'equation' and the switchreg specification?
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Mon Jun 26, 2017 9:53 am
by startz
The second spot you mention.
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Mon Jun 26, 2017 10:29 am
by vonkraush
I updated the settings as suggested, but the problem does not appear to be going away. Is there anything else I might be able to do to try to make it work?
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Mon Jun 26, 2017 2:04 pm
by startz
'Fraid I'm out of ideas. Perhaps the EViews folks can chime in.
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Mon Jun 26, 2017 2:22 pm
by EViews Glenn
Not sure how much I can add since this really seems like a data issue. One note that we do point out in the manual - the regime identities are not identified. That is, regime 1 and regime 2 can be swapped in any estimation with no change to the estimates. So if all you are doing is checking the first regime for results, that may not be what you want for all models.
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Mon Jun 26, 2017 2:39 pm
by startz
OP:
Maybe I didn't understand the situation. I thought the problem was that you get different estimates for a regression with given data depending on what other switching regressions have been run first. Did I understand that correctly?
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Mon Jun 26, 2017 3:49 pm
by vonkraush
Not sure how much I can add since this really seems like a data issue. One note that we do point out in the manual - the regime identities are not identified. That is, regime 1 and regime 2 can be swapped in any estimation with not change to the estimates. So if all you are doing is checking the first regime for results, that may not be what you want for all models.
So wait, if i understand you correctly you are saying that it is possible that what considered regime 1 and what is considered regime 2 may effectively be swapped from regression to regression? Is there any way at all to avert this or at least some way to code around it (to rematch the regimes properly after the fact)? This would perfectly explain the issues I'm having.
OP:
Maybe I didn't understand the situation. I thought the problem was that you get different estimates for a regression with given data depending on what other switching regressions have been run first. Did I understand that correctly?
I thought that this was the case, but based on what I've just been told it seems like my real problem is that what is considered regime 1 vs 2 is often swapped from regression to regression.
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Mon Jun 26, 2017 4:02 pm
by startz
So wait, if i understand you correctly you are saying that it is possible that what considered regime 1 and what is considered regime 2 may effectively be swapped from regression to regression? Is there any way at all to avert this or at least some way to code around it (to rematch the regimes properly after the fact)? This would perfectly explain the issues I'm having.
This is just how Markov-switching works, so there really isn't anything you can do to prevent it.
Once the estimates are run, you can do something like compare a coefficient across regimes and then always act as if the regime with the smaller coefficient (or whatever) is "regime 1."
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Mon Jun 26, 2017 4:45 pm
by vonkraush
So wait, if i understand you correctly you are saying that it is possible that what considered regime 1 and what is considered regime 2 may effectively be swapped from regression to regression? Is there any way at all to avert this or at least some way to code around it (to rematch the regimes properly after the fact)? This would perfectly explain the issues I'm having.
This is just how Markov-switching works, so there really isn't anything you can do to prevent it.
Once the estimates are run, you can do something like compare a coefficient across regimes and then always act as if the regime with the smaller coefficient (or whatever) is "regime 1."
Understood.
As the regression results tend to be consistently high in one state and low in the other, I believe it would be possible to filter thembased on the average value of each series. Above .5 would imply one state, below .5 would imply the other etc. If all the results are listed as fin*a and fin*b is there any sort of code I could run to delete all series with the name fin* WHERE the average of a given series is above or below a certain point?
Re: Markov Switching Model not outputting consistent results across datasets
Posted: Mon Jun 26, 2017 4:52 pm
by startz
I haven't tested this, but something like
Code: Select all
if @mean(fina)>.5
fin = finb
else
fin = fina
end
d fina finb