how to explain the theta of SWARCH.rpf
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
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
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.
Re: how to explain the theta of SWARCH.rpf
Thanks.
The code between User's guaid and Procedures is different.
The code between User's guaid and Procedures is different.
-
flopez2011
- Posts: 9
- Joined: Sat Apr 23, 2011 2:27 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
Re: how to explain the theta of SWARCH.rpf
As mentioned above, it estimates the probabilities in logistic index form. To transform those to probabilities addflopez2011 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
disp %mslogisticp(theta)
-
flopez2011
- Posts: 9
- Joined: Sat Apr 23, 2011 2:27 pm
Re: how to explain the theta of SWARCH.rpf
TomDoan wrote:As mentioned above, it estimates the probabilities in logistic index form. To transform those to probabilities addflopez2011 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
disp %mslogisticp(theta)
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
Re: how to explain the theta of SWARCH.rpf
You would have to post your program and data.
-
flopez2011
- Posts: 9
- Joined: Sat Apr 23, 2011 2:27 pm
Re: how to explain the theta of SWARCH.rpf
That is the program, as you can see, it is modified only to deal with my dataTomDoan wrote:You would have to post your program and 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) mu
nonlin(parmset=archparms) a0 a hv
nonlin(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 e
type vector ARCHStateF
type real e
type integer time
*
local integer i j
local 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 i
end
*
* 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 x
compute 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.00
maximize(start=%(p=%mslogisticp(theta),pstar=%msinit()),$
parmset=meanparms+archparms+msparms+pegs,$
method=bhhh,iters=400,pmethod=simplex,piters=5) logl 3 *
*
@MSSmoothed %regstart() %regend() psmooth
set 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 500
graph(picture="##.##",header="Data")
# x 400 500
spgraph(done)In advancement, thanks a lot
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.
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?
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?
Re: how to explain the theta of SWARCH.rpf
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: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.
Do you have a reference? There's no particular reason it couldn't, but there is no obvious generalization from univariate to bivariate.zy761 wrote: 2. Can RATS run a bivariate SWARCH model?
Re: how to explain the theta of SWARCH.rpf
Dear Tom,
Thanks for your kind reply.
Thanks for your kind reply.
But what the about the probability of moving from i to i, say, the persistence of state i?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.
Attached is the paper that does the bivariate SWARCH model, in section 4.TomDoan wrote:Do you have a reference? There's no particular reason it couldn't, but there is no obvious generalization from univariate to bivariate.zy761 wrote: 2. Can RATS run a bivariate SWARCH model?
- Attachments
-
- Edwards, 2001.pdf
- (400.16 KiB) Downloaded 1152 times
-
flopez2011
- Posts: 9
- Joined: Sat Apr 23, 2011 2:27 pm
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
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.
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.zy761 wrote: But what the about the probability of moving from i to i, say, the persistence of state i?
Re: how to explain the theta of SWARCH.rpf
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.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