how to explain the theta of SWARCH.rpf

Discussion of models with structural breaks or endogenous switching.

how to explain the theta of SWARCH.rpf

Dear Tom:

On the swarch.rpf, the theta is a vector of MSparms which should between 0 and 1. However the result are more than 1 or less than -50. Is theta transition probability? how can explain the theta?

Best Regard.
Hardmann
hardmann

Posts: 48
Joined: Sat Feb 26, 2011 10:49 pm

Re: how to explain the theta of SWARCH.rpf

The theta's are the logistic indexes, not the probabilities. The %MSLOGISTICP(theta) converts theta into the standard transition probabilities.
TomDoan

Posts: 2727
Joined: Wed Nov 01, 2006 5:36 pm

Re: how to explain the theta of SWARCH.rpf

Thanks.
The code between User's guaid and Procedures is different.
hardmann

Posts: 48
Joined: Sat Feb 26, 2011 10:49 pm

Re: how to explain the theta of SWARCH.rpf

Dear Tom, when I run the SWARCH.rpf all is ok, but when I run with my own data I can not get values for p's...What can be wrong?...Regards
flopez2011

Posts: 8
Joined: Sat Apr 23, 2011 2:27 pm

Re: how to explain the theta of SWARCH.rpf

flopez2011 wrote:Dear Tom, when I run the SWARCH.rpf all is ok, but when I run with my own data I can not get values for p's...What can be wrong?...Regards

As mentioned above, it estimates the probabilities in logistic index form. To transform those to probabilities add

disp %mslogisticp(theta)
TomDoan

Posts: 2727
Joined: Wed Nov 01, 2006 5:36 pm

Re: how to explain the theta of SWARCH.rpf

TomDoan wrote:
flopez2011 wrote:Dear Tom, when I run the SWARCH.rpf all is ok, but when I run with my own data I can not get values for p's...What can be wrong?...Regards

As mentioned above, it estimates the probabilities in logistic index form. To transform those to probabilities add
disp %mslogisticp(theta)

Using disp %mslogisticp(theta) I get:

NA 0.01856 1.86383e-022
NA 0.96835 0.03366

in the output window, that I assume are elements of the transition probabilities matrix, but I cannot see how they must be read
At the other hand, in the List of Series P1, P2 and P3 continue having zero observations, so I cannot get a similar graph ot the last one of the SWARCH.rpf programm, What I must do to get P1, P2 and P3 series...Best regards
flopez2011

Posts: 8
Joined: Sat Apr 23, 2011 2:27 pm

Re: how to explain the theta of SWARCH.rpf

You would have to post your program and data.
TomDoan

Posts: 2727
Joined: Wed Nov 01, 2006 5:36 pm

Re: how to explain the theta of SWARCH.rpf

TomDoan wrote:You would have to post your program and data.

That is the program, as you can see, it is modified only to deal with my data

Code: Select all
`OPEN DATA "C:\Users\Usuario\Documents\WinRATS Standard 8.1\TLCAN.xls"DATA(FORMAT=XLS,ORG=COLUMNS) 1 1305 MEX* Convert to percent daily returns*set x = 100.0*log(MEX/MEX{1})@MSSetup(states=3)compute q=2** HV will be the relative variances in the states. This will be* normalized to a relative variance of 1 in the first state, so it's* dimensioned N-1.*dec vect hv(nstates-1)** This will be the vector of ARCH parameters*dec vect a(q)** We have three parts of the parameter set: the mean equation parameters* (here, just an intercept), the ARCH model parameters, and the Markov* switching parameters, for which we'll use the logistic indexes.*nonlin(parmset=meanparms) munonlin(parmset=archparms) a0 a hvnonlin(parmset=msparms)   theta** uu and u are used for the series of squared residuals and the series of* residuals needed to compute the ARCH variances.*clear uu u** ARCHStateF returns a vector of likelihoods for the various states at* time given residual e. The likelihoods differ in the states based upon* the values of hv, where the intercept in the ARCH equation is scaled* up by hv. Again, the elements of hv are offset by 1 since they're* normalized with the first state at 1.*function ARCHStateF time etype vector     ARCHStateFtype real        etype integer    time*local integer    i jlocal real       vi*dim ARCHStateF(nstates)do i=1,nstates   compute vi=a0*%if(i>1,hv(i-1),1)   do j=1,q      compute vi=vi+a(j)*uu(time-j)   end do i   compute ARCHStateF(i)=%if(vi>0,%density(e/sqrt(vi))/sqrt(vi),0.0)end do iend** As is typically the case with Markov switching models, there is no* global identification of the states. By defining a fairly wide spread* for hv, we'll hope that we'll stay in the zone of the likelihood where* state 1 is low variance, state 2 is medium and state 3 is high.*compute hv=||10,100||** These are our guess values for the P matrix. We have to invert that to* get the guess values for the logistic indexes.*compute p=||.8,.2,.05|.2,.6,.4||compute theta=%msplogistic(p)*stats xcompute mu=%mean,a0=%variance,a=%const(0.05)set uu = %variance** We need to keep series of the residual (u) and squared residual (uu).* Because the mean function is the same across states, we can just* compute the residual and send it to ARCHStateF, which computes the* likelihoods for the different ARCH variances.** Because we need 2 lags of uu, the estimation starts at 3.*frml logl = u(t)=(x-mu),uu(t)=u(t)^2,\$   f=ARCHStateF(t,u(t)),fpt=%MSProb(t,f),log(fpt)*@MSFilterInit** The 1-->3 probability is effectively zero, which causes problems with* the estimation. This pegs the theta(1,3) element to prevent that.*nonlin(parmset=pegs) theta(1,3)=-50.00maximize(start=%(p=%mslogisticp(theta),pstar=%msinit()),\$ parmset=meanparms+archparms+msparms+pegs,\$ method=bhhh,iters=400,pmethod=simplex,piters=5) logl 3 **@MSSmoothed %regstart() %regend() psmoothset p1 = psmooth(t)(1)set p2 = psmooth(t)(2)set p3 = psmooth(t)(3)disp %mslogisticp(theta)spgraph(vfields=2,samesize)graph(style=stacked,maximum=1.0,picture="##.##",\$  header="Smoothed Probabilities of Variance States",\$  key=none,klabels=||"Low Variance","Medium Variance","High Variance"||) 3# p1 400 500# p2 400 500# p3 400 500graph(picture="##.##",header="Data")# x 400 500spgraph(done)`

And the data are in th attached xls file

TLCAN.xls
It is the Data file

flopez2011

Posts: 8
Joined: Sat Apr 23, 2011 2:27 pm

Re: how to explain the theta of SWARCH.rpf

First, the pegging of the (1,3) element is specific to the example we gave. You don't want to start with that imposed. You might end up needing it, but takes the PEGS off the PARMSET option to start. Your model isn't converging with the options that we used. It looks like switching to METHOD=BFGS from METHOD=BHHH will help. Note also that those final graphs over the range from 400 to 500 are also specific to our example.
TomDoan

Posts: 2727
Joined: Wed Nov 01, 2006 5:36 pm

Re: how to explain the theta of SWARCH.rpf

Dear Tom:
I'm now running the SWARCH(3,2) model and I have two questions:
1. I get the trasition probability matrix using disp %mslogisticp(theta). It is a 2*3 matrix. But what does each element in the matrix mean? I thought it should be a 3*3 matrix.
2. Can RATS run a bivariate SWARCH model?
zy761

Posts: 7
Joined: Mon Mar 19, 2012 1:01 am

Re: how to explain the theta of SWARCH.rpf

zy761 wrote:Dear Tom:
I'm now running the SWARCH(3,2) model and I have two questions:
1. I get the trasition probability matrix using disp %mslogisticp(theta). It is a 2*3 matrix. But what does each element in the matrix mean? I thought it should be a 3*3 matrix.

The bottom rows just make the columns add up to 1. P(i,j) is the probability of moving from j to i.

zy761 wrote: 2. Can RATS run a bivariate SWARCH model?

Do you have a reference? There's no particular reason it couldn't, but there is no obvious generalization from univariate to bivariate.
TomDoan

Posts: 2727
Joined: Wed Nov 01, 2006 5:36 pm

Re: how to explain the theta of SWARCH.rpf

Dear Tom,

TomDoan wrote:
zy761 wrote:Dear Tom:
I'm now running the SWARCH(3,2) model and I have two questions:
1. I get the trasition probability matrix using disp %mslogisticp(theta). It is a 2*3 matrix. But what does each element in the matrix mean? I thought it should be a 3*3 matrix.

The bottom rows just make the columns add up to 1. P(i,j) is the probability of moving from j to i.

But what the about the probability of moving from i to i, say, the persistence of state i?

TomDoan wrote:
zy761 wrote: 2. Can RATS run a bivariate SWARCH model?

Do you have a reference? There's no particular reason it couldn't, but there is no obvious generalization from univariate to bivariate.

Attached is the paper that does the bivariate SWARCH model, in section 4.
Attachments
Edwards, 2001.pdf
zy761

Posts: 7
Joined: Mon Mar 19, 2012 1:01 am

Re: how to explain the theta of SWARCH.rpf

After reading the Edwards&Susmel paper I think very desirable to get a routine to estimate bivariate swarch(K,q) models, but not assuming a constant correlation matrix but time variyng so as empirical evidence suggests
flopez2011

Posts: 8
Joined: Sat Apr 23, 2011 2:27 pm

Re: how to explain the theta of SWARCH.rpf

TomDoan wrote:The bottom rows just make the columns add up to 1. P(i,j) is the probability of moving from j to i.

zy761 wrote:But what the about the probability of moving from i to i, say, the persistence of state i?

That's p(i,i). You need to read the RATS User's Guide. We explain why we don't parameterize in terms of persistence measures. They are still estimated directly or indirectly, but aren't the basic parameters.
TomDoan

Posts: 2727
Joined: Wed Nov 01, 2006 5:36 pm

Re: how to explain the theta of SWARCH.rpf

flopez2011 wrote:After reading the Edwards&Susmel paper I think very desirable to get a routine to estimate bivariate swarch(K,q) models, but not assuming a constant correlation matrix but time variyng so as empirical evidence suggests

The problem is that even if you figure out how to define a DCC model in the switching case, the likelihood at t will be dependent upon the full path from 1 to t-1 which is what the use of ARCH (rather than GARCH) is trying to avoid.
TomDoan

Posts: 2727
Joined: Wed Nov 01, 2006 5:36 pm