Markov Switching store regime probabilities

For questions regarding programming in the EViews programming language.

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

walmir.silva
Posts: 2
Joined: Tue Jun 13, 2017 11:07 am

Markov Switching store regime probabilities

Postby walmir.silva » Sat Jun 17, 2017 10:35 am

I would like to model a regime switching with a rolling window of 1000 days, my problem is how to store the regime probabilities for each one of the iterations in the loop.

I know that with
eq01.makergmprobs(type=smooth) rprob1 rprob2
I can store but only for the last iteration.

I'm adapting a code posted in this forum Multi-step ahead forecast by EViews Gareth on Jan 29, 2014.

'rolling Markov Switching regression
group y variable

' set window size
!window = 1000

' declare equation for estimation
equation eq01

' get size of workfile
!length = @obsrange

'calculate number of rolls
!nrolls = @floor(!length-!window)

'matrix to store coefficient estimates
matrix(5,!nrolls) coefmat

'matrix to store regime probabilities
matrix(1000,!nrolls) regime_probabilities

' loop
for !i = 1 to !nrolls

' dynamic sample
smpl @first+!i @first+!i+!window

equation eq01.switchreg(type=markov) y c
eq01.rgmprobs(type=smooth) 1 2
' estimate equation -

colplace(coefmat,eq01.@coefs,!j) 'store coefficients

eq01.makergmprobs(type=smooth) rprob1 rprob2

colplace(regime_probabilities,eq01@..... ????? ‘ how to store the regime probabilities rprob1 e rprob2????
'in this point, I would like to store rprob1 e rprob2 in matrix regime_probabilities for each loop

next

Thanks for any help.

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

Re: Markov Switching store regime probabilities

Postby EViews Glenn » Thu Jun 22, 2017 9:51 am

The regime probs are series with values for each observation in the estimation sample. What exactly do you wish to save?

Conch
Posts: 1
Joined: Mon Jul 16, 2018 8:56 am

Re: Markov Switching store regime probabilities

Postby Conch » Tue Jul 17, 2018 1:43 am

Hi,

I am trying to do the same (and also storing transition probabilities)

This is the best I´ve been able to do:

for !horizon=140 to 240

smpl 1955q1 1955q1+!horizon
equation eq{!horizon}.switchreg(your specification)

eq{!horizon}.makergmprobs(type=smooth, n=smoothed!horizon) s1!horizon s2!horizon
wfsave(type=excelxml, mode=update) smoothed!horizon.xlsx range="Sheet!a1" @keep s1!horizon s2!horizon

eq{!horizon}.maketransprobs(out=mat) BB!horizon
BB!horizon.write(t=xls) BB!horizon.xls

Next

Unfortunately, this stores smoothed probs in one group within the work file and exports it to an excel file for each iteration.
Could somebody tell me how to store them in a single item?

Thank you in advance guys!!!!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 25 guests