Markov Switching Model not outputting consistent results across datasets

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

vonkraush
Posts: 5
Joined: Sun Jun 25, 2017 11:40 am

Markov Switching Model not outputting consistent results across datasets

Postby vonkraush » Sun Jun 25, 2017 7:41 pm

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.

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Markov Switching Model not outputting consistent results across datasets

Postby startz » Sun Jun 25, 2017 9:00 pm

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

Code: Select all

c=0
before switchreg and see what happens.

vonkraush
Posts: 5
Joined: Sun Jun 25, 2017 11:40 am

Re: Markov Switching Model not outputting consistent results across datasets

Postby vonkraush » Mon Jun 26, 2017 9:27 am

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?

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Markov Switching Model not outputting consistent results across datasets

Postby startz » Mon Jun 26, 2017 9:53 am

The second spot you mention.

vonkraush
Posts: 5
Joined: Sun Jun 25, 2017 11:40 am

Re: Markov Switching Model not outputting consistent results across datasets

Postby vonkraush » Mon Jun 26, 2017 10:29 am

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?

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Markov Switching Model not outputting consistent results across datasets

Postby startz » Mon Jun 26, 2017 2:04 pm

'Fraid I'm out of ideas. Perhaps the EViews folks can chime in.

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: Markov Switching Model not outputting consistent results across datasets

Postby EViews Glenn » Mon Jun 26, 2017 2:22 pm

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.
Last edited by EViews Glenn on Fri Jun 30, 2017 11:59 am, edited 1 time in total.

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Markov Switching Model not outputting consistent results across datasets

Postby startz » Mon Jun 26, 2017 2:39 pm

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?

vonkraush
Posts: 5
Joined: Sun Jun 25, 2017 11:40 am

Re: Markov Switching Model not outputting consistent results across datasets

Postby vonkraush » Mon Jun 26, 2017 3:49 pm

EViews Glenn wrote: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.

startz wrote: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.

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Markov Switching Model not outputting consistent results across datasets

Postby startz » Mon Jun 26, 2017 4:02 pm

vonkraush wrote:
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."

vonkraush
Posts: 5
Joined: Sun Jun 25, 2017 11:40 am

Re: Markov Switching Model not outputting consistent results across datasets

Postby vonkraush » Mon Jun 26, 2017 4:45 pm

startz wrote:
vonkraush wrote:
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?

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Markov Switching Model not outputting consistent results across datasets

Postby startz » Mon Jun 26, 2017 4:52 pm

I haven't tested this, but something like

Code: Select all

if @mean(fina)>.5
fin = finb
else
fin = fina
end
d fina finb


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 30 guests