Page 1 of 2

Obtain residuals and IRF

Posted: Sat Jul 06, 2013 9:03 am
by arezitis
Dear all,
I am a new user of RATS. I would like to obtain (save or print) the residual series from the MS system regression program I am attaching (ML estimation). Furthrmore, I need some help of obtaining the impulse response functions.
Thanks in advance
Anthony

Re: Obtain residuals and IRF

Posted: Sat Jul 06, 2013 12:15 pm
by TomDoan
arezitis wrote:Dear all,
I am a new user of RATS. I would like to obtain (save or print) the residual series from the MS system regression program I am attaching (ML estimation). Furthrmore, I need some help of obtaining the impulse response functions.
Thanks in advance
Anthony
Regime-dependent IRF's are demonstrated in Ehrmann, Ellison and Valla.

What do you mean by "residuals"? The MS model is a probabilistic combination of two separate models.

Re: Obtain residuals and IRF

Posted: Sat Jul 06, 2013 1:49 pm
by arezitis
I mean 'regime dependent residuals'.
I need them in orfer to test the goodness of fit of the MS model.
I cannot find, in RATS, any procedure (for MS models) of providing
tests for autocorrelation, normality, heteroskedasticity etc.
Do you have any suggestion.
Thanks

Re: Obtain residuals and IRF

Posted: Sat Jul 06, 2013 2:30 pm
by TomDoan
arezitis wrote:I mean 'regime dependent residuals'.
I need them in orfer to test the goodness of fit of the MS model.
I cannot find, in RATS, any procedure (for MS models) of providing
tests for autocorrelation, normality, heteroskedasticity etc.
Do you have any suggestion.
Thanks
The regime-dependent residuals would be worthless for diagnostics. Think about a simple model like Hamilton's. The "expansion" branch residuals will be strongly negative during recessions and the "recession" branch residuals will be strongly positive during expansions. Neither will be mean zero, neither will be serially uncorrelated. If you've run across a paper which looks at issues of diagnostic testing in MS models (other than for number of regimes), let us know and we'll look at it.

Re: Obtain residuals and IRF

Posted: Mon Jul 08, 2013 6:15 am
by arezitis
Thanks for the information that the Regime-dependent IRF's are demonstrated in Ehrmann, Ellison and Valla. However, Ehrmann, Ellison and Valla use MCMC Estimation but I would like to use either ML Estimation or EM Estimation. Is there any suggestion. Thanks in advance.
Anthony

Re: Obtain residuals and IRF

Posted: Mon Jul 08, 2013 8:04 am
by TomDoan
The forum post only includes the MCMC estimation since the main interest regarding the paper is in the regime-dependent IRF's with error bands, which requires MCMC estimation. The paper replication provided with your RATS software includes ML and EM estimation as well.

Re: Obtain residuals and IRF

Posted: Wed Jul 10, 2013 3:34 pm
by arezitis
Dear Tom,

Further in our discussion, I used the code of Impulse Response Functions of eev_mcmc for retrieving the IRF from Maximum Likelihood and Expectations Maximization procedures. However, the program does not give the graphs. I just get the IRF tables by selecting print in the command impulse(print,model=MSSysRegModel,results=impulses1,steps=steps,factor=factor). Can you help me by suggesting an alteration to the code that shows the graphs so that I can acquire them without the error bands of course? The error message is ## SR6. Missing a Necessary Parameter. Check Instruction Syntax The Error Occurred At Location 253, Line 5 of loop/block. I also submit the codes that I am trying to run for ML and EM. Thanks in advance. Anthony

Re: Obtain residuals and IRF

Posted: Wed Jul 10, 2013 4:32 pm
by TomDoan
arezitis wrote:Dear Tom,

Further in our discussion, I used the code of Impulse Response Functions of eev_mcmc for retrieving the IRF from Maximum Likelihood and Expectations Maximization procedures. However, the program does not give the graphs. I just get the IRF tables by selecting print in the command impulse(print,model=MSSysRegModel,results=impulses1,steps=steps,factor=factor). Can you help me by suggesting an alteration to the code that shows the graphs so that I can acquire them without the error bands of course? The error message is ## SR6. Missing a Necessary Parameter. Check Instruction Syntax The Error Occurred At Location 253, Line 5 of loop/block. I also submit the codes that I am trying to run for ML and EM. Thanks in advance. Anthony
This is all you need to compute the impulse responses at the last set of estimates. The regime 1 responses will be in <<impulses1>> and the regime 2 responses will be in <<impulses2>>.

@MSSysRegSetModel(regime=1)
compute factor=%decomp(sigmav(1)),factor=factor*inv(%diag(%xdiag(factor)))
impulse(noprint,model=MSSysRegModel,results=impulses1,steps=steps,factor=factor)
*
* Save IRF's for regime 2
*
@MSSysRegSetModel(regime=2)
compute factor=%decomp(sigmav(2)),factor=factor*inv(%diag(%xdiag(factor)))
impulse(noprint,model=MSSysRegModel,results=impulses2,steps=steps,factor=factor)

Re: Obtain residuals and IRF

Posted: Tue Sep 17, 2013 4:27 am
by arezitis
Dear Tom,

I would like to thank you for your help so far. However, I would like to come back to my two original questions about residuals and impulse responses.
Regarding impulse responses, after I followed your last post, I managed to run them for the models that I attached you, by using impulse command. However, I also tried to use the same command to acquire the impulse responses for an asymmetric Markov Switching Vector Error Correction model but the results didn’t seem to be correct. Therefore, I would like to ask you if you have any suggestions about how to do this. The manual refers to an alternate command, simulate. Do you think that I should try with this one? I attach you the relevant files.
Regarding residuals, my question is: Is it possible by using multivariate procedures that are incorporated already in rats like mvarchtest, mvjb, mvqstat, westchotest to test the residuals of my four equations as a whole system. I have seen this to MSVARlib 2.0 program which uses a multivariate Jarque-Bera test to check the normality of the Markov model. I attach you the file where I tried to use these procedures along with the procedure for information criteria. I would like your opinion about the code if is it correct and any suggestions on how to do this.
I am sorry about the large inquiry. I am looking forward to your response.

Best Regards,
A. Rezitis

Re: Obtain residuals and IRF

Posted: Tue Sep 17, 2013 11:19 am
by TomDoan
arezitis wrote:Regarding residuals, my question is: Is it possible by using multivariate procedures that are incorporated already in rats like mvarchtest, mvjb, mvqstat, westchotest to test the residuals of my four equations as a whole system. I have seen this to MSVARlib 2.0 program which uses a multivariate Jarque-Bera test to check the normality of the Markov model. I attach you the file where I tried to use these procedures along with the procedure for information criteria. I would like your opinion about
the code if is it correct and any suggestions on how to do this.
If MSVARlib does a test like that, what is it using as the input? That's the key question.

Re: Obtain residuals and IRF

Posted: Tue Sep 17, 2013 11:57 am
by arezitis
From what I understand it uses the residulas from all equations from all states to calculate the multivariate Jarcque-Bera statistic. I attach you the code to have a look.

Re: Obtain residuals and IRF

Posted: Tue Sep 17, 2013 12:32 pm
by TomDoan
I don't see anything about that that has anything to do with MS models. That's just a standard MVJB test using a Cholesky factor. (The test depends upon the factor matrix used, and, for a Cholesky factor, the order for the variables in the model). If this is somehow being applied to the output of a MS estimation, it's in the level above that that the real work is being done.

Re: Obtain residuals and IRF

Posted: Wed Sep 18, 2013 6:44 am
by arezitis
The only direct reference of the main program to the MVJB test, that I can find, is this. I attach you the file.

Re: Obtain residuals and IRF

Posted: Wed Sep 18, 2013 10:16 am
by TomDoan
If you walk back one more call, you will find that the residuals are computed as:

Code: Select all

	      y_hat[temps,.]= PR_STT[temps,.]*(Reshape(mu[temps,.],_M,_K)); /* Simulated series */
    
        temps = temps + 1;
      	  
    endo;
    
 resid = y_mat - y_hat;     /* Residual */
So they're the probability weighted residuals using the filtered probabilities of the regimes. There are several problems with this:

1. Even if the two branches were both Normal, the probability weighted sum of Normals isn't.
2. The two branches aren't Normal. The model says that one (the correct one) is Normal---it says nothing about the other one. It could be serially correlated; it could have almost any behavior.
3. If the probabilities are (effectively) either zero or one so that there is no smearing of the two branches, this still does not deal properly with different variances in difference regimes. The residuals would be in one or the other variance regime, but this does nothing to correct for that.

You might want to check with Bellone to see if he has any paper which describes the theory that gives those diagnostics any meaning. I'm not seeing one based upon what's being computed.

Re: Obtain residuals and IRF

Posted: Wed Oct 16, 2013 4:35 pm
by TomDoan
In a newer version of @MSVARSETUP, I've included a procedure to compute the standardized predictive residuals (see the discussion of @MSVARStdResiduals). These can be used to do serial correlation tests. These are not what are being described above (from MSVARLib)---I have no idea what value those have for diagnostics. What @MSVARStdResiduals is computing has the property that they are uncorrelated, with identity covariance matrix, under the assumption that the model is correct. Note, however, that although you were asking for a J-B test, that's just bad econometrics---there's no theory that says these should be Normal even if each regime is.