MS-ARIMA
Re: MS-ARIMA
compute x0=||5.224,2.699||
*********************************************************************
gset xstates = %zeros(ndlm,1)
compute DLMStart()
@MSFilterInit
1. x0 is the wrong dimension. I'm not sure where you're getting the two values you have, but it's supposed to be length 5 since it's the pre-sample state vector.
2. Add the compute DLMStart() line to transfer initial information before doing the @MSFilterInit.
*********************************************************************
gset xstates = %zeros(ndlm,1)
compute DLMStart()
@MSFilterInit
1. x0 is the wrong dimension. I'm not sure where you're getting the two values you have, but it's supposed to be length 5 since it's the pre-sample state vector.
2. Add the compute DLMStart() line to transfer initial information before doing the @MSFilterInit.
Re: MS-ARIMA
Hi Tom, Thank you very much for the reply. Could you please let me know where I should modify the above code to allow for time varying probabilities?TomDoan wrote:compute x0=||5.224,2.699||
*********************************************************************
gset xstates = %zeros(ndlm,1)
compute DLMStart()
@MSFilterInit
1. x0 is the wrong dimension. I'm not sure where you're getting the two values you have, but it's supposed to be length 5 since it's the pre-sample state vector.
2. Add the compute DLMStart() line to transfer initial information before doing the @MSFilterInit.
Re: MS-ARIMA
This treats P as a fixed matrix. You would have to compute P as a function of the function argument <<time>> instead.
compute likely=0.0
do i=1,nstates
do j=1,nstates
compute phat(i,j)=p(i,j)*pstar(j)*fwork(i,j)
compute likely=likely+phat(i,j)
end do j
end do i
compute likely=0.0
do i=1,nstates
do j=1,nstates
compute phat(i,j)=p(i,j)*pstar(j)*fwork(i,j)
compute likely=likely+phat(i,j)
end do j
end do i
Re: MS-ARIMA
hi Tom, thank you for the quick reply. i tried to modify the codes to allow P as a function of the function argument <<time>>. unfortunately, the modification did not work. Error messages appear likeTomDoan wrote:This treats P as a fixed matrix. You would have to compute P as a function of the function argument <<time>> instead.
compute likely=0.0
do i=1,nstates
do j=1,nstates
compute phat(i,j)=p(i,j)*pstar(j)*fwork(i,j)
compute likely=likely+phat(i,j)
end do j
end do i
Can't Find Match for %MSPROB(INTEGER). Closest Match is %MSPROB(INTEGER,VECTOR[REAL])
## SX27. Illegal Combination of Data Types for Operation
>>>>t(t),log(%MSProb(t)<<<<
i am not sure the cause of the errors. Could you please kindly take a look my attached code and help me find out the errors? Many Thanks
- Attachments
-
- arma-tvp.RPF
- (5.94 KiB) Downloaded 1224 times
Re: MS-ARIMA
%MSPROB isn't computing the likelihood---KimFilter is---so get rid of that FRML instruction that's causing the error. You also have to compute the P matrix inside KimFilter with
compute p=%MSPMat(time)
before you reach the loop that uses it.
compute p=%MSPMat(time)
before you reach the loop that uses it.
Re: MS-ARIMA
Hi Tom. thank you for the quick reply. Following your advise,I took off the FRML instruction for %MSPROB and add compute p=%MSPMat(time) before running the Hamilton filter. However, I am still having following error messagesTomDoan wrote:%MSPROB isn't computing the likelihood---KimFilter is---so get rid of that FRML instruction that's causing the error. You also have to compute the P matrix inside KimFilter with
compute p=%MSPMat(time)
before you reach the loop that uses it.
The Error Occurred At Location 170, Line 13 of %MSINIT
Called From Location 127, Line 13 of MSFILTERINIT
## MAT14. Non-invertible Matrix. Using Generalized Inverse for SYMMETRIC.
## MAT2. Matrices with Dimensions 2 x 1 and 2 x 2 Involved in * Operation
The Error Occurred At Location 268, Line 16 of %MSPMAT
Called From Location 552, Line 39 of KIMFILTER
I see that i need to replace the original code
Code: Select all
compute p=%msexpand(p), compute pstar=%mcergodicCode: Select all
p=%mspmat(time), compute pstar=||%logistic(v1(1),1.0),1-%logistic(v2(1),1.0)|| - Attachments
-
- arma-tvp.RPF
- (5.84 KiB) Downloaded 1182 times
Re: MS-ARIMA
Your P matrix is a global that's dimensioned 2 x 2, but in %MSPMAT you only use it as a 1 x 2. Use a local RECT in that function rather than P.
Re: MS-ARIMA
Hi Tom, I am sorry to ask question again. I made relevant changes to the code following your suggestions. However, new error messages say “## MAT13. Store into Out-of-Range Matrix or Series Element; The Error Occurred At Location 9, Line 10 of %MSPMAT; Called From Location 99, Line 19 of DLMSTART”. I do not quite understand the messages. Could you please help me understand where the errors occurred in my code?TomDoan wrote:Your P matrix is a global that's dimensioned 2 x 2, but in %MSPMAT you only use it as a 1 x 2. Use a local RECT in that function rather than P.
- Attachments
-
- arma-tvp(new).RPF
- (5.84 KiB) Downloaded 1177 times
Re: MS-ARIMA
It's pointing you to line 10 (the compute below) and telling you that you're storing into an out-of-range element. That's P. Where is P dimensioned? Now that it's local, nowhere. You need
local rect p(1,2)
local rect p(1,2)
Code: Select all
local rect p
*
compute p(1,1)=%(z=exp(%dot(%eqnxvector(p1eq,time),v1)),z/(1+z))
compute p(1,2)=%(z=exp(%dot(%eqnxvector(p2eq,time),v2)),1/(1+z))
Re: MS-ARIMA
Thank you, Tom. finally, it worked.TomDoan wrote:It's pointing you to line 10 (the compute below) and telling you that you're storing into an out-of-range element. That's P. Where is P dimensioned? Now that it's local, nowhere. You need
local rect p(1,2)
Code: Select all
local rect p * compute p(1,1)=%(z=exp(%dot(%eqnxvector(p1eq,time),v1)),z/(1+z)) compute p(1,2)=%(z=exp(%dot(%eqnxvector(p2eq,time),v2)),1/(1+z))
Re: MS-ARIMA
Dear Tom, sorry for posting questions here again. I am interested in examining the transition probabilities of US economy during different political regimes (democratic vs. republican) and first and second half of a presidency(yr12 vs. yr34). However, there is a convergence issue in my estimation process. I tried what suggested by the program, such as giving different initial values, increasing number of iterations, but nothing worked for me. Could you please kindly help me with the issue?TomDoan wrote:It's pointing you to line 10 (the compute below) and telling you that you're storing into an out-of-range element. That's P. Where is P dimensioned? Now that it's local, nowhere. You need
local rect p(1,2)
Code: Select all
local rect p * compute p(1,1)=%(z=exp(%dot(%eqnxvector(p1eq,time),v1)),z/(1+z)) compute p(1,2)=%(z=exp(%dot(%eqnxvector(p2eq,time),v2)),1/(1+z))
- Attachments
-
- ARMA34(BW-Indsg)tvp.RPF
- (6.09 KiB) Downloaded 1101 times
-
- quarterlydata.xlsx
- (136.81 KiB) Downloaded 1097 times
Re: MS-ARIMA
Given that it's hard to fit even a non-switching ARMA(3,4) model to the data, the fact that you can't fit a switching model isn't a shock. I told you months ago that a 2,4 model was too much. Now it's a 3,4? Cut that down substantially (you can just peg some of the phi's and tau's to zero) and you'll have a better chance.
Re: MS-ARIMA
Thank you for your quick reply. Is there any general method available that can help people to choose the model to describe the macroeconomic time series if she/he would like to apply MS model to. I picked up 3,4 based on the information contrition. Authors of the papers I read do not rarely mention the reason why them picked up models for their studies, such as AR(4) is commonly used by researchers to model aggregate output since Hamilton.TomDoan wrote:Given that it's hard to fit even a non-switching ARMA(3,4) model to the data, the fact that you can't fit a switching model isn't a shock. I told you months ago that a 2,4 model was too much. Now it's a 3,4? Cut that down substantially (you can just peg some of the phi's and tau's to zero) and you'll have a better chance.
Re: MS-ARIMA
No. However, you can probably bet that less complicated will work better than more complicated. The whole idea (if the idea is correct) is that the dynamics are driven more by the MS model than the static time series representation.
Re: MS-ARIMA
Thank you for the adviceTomDoan wrote:No. However, you can probably bet that less complicated will work better than more complicated. The whole idea (if the idea is correct) is that the dynamics are driven more by the MS model than the static time series representation.