Stability tests with kalman filter

Discussion of State Space and Dynamic Stochastic General Equilibrium Models
Aktar
Posts: 35
Joined: Thu Apr 16, 2009 8:12 am

Stability tests with kalman filter

Unread post by Aktar »

Hi

i have make my kalman filter estimate with eviews, and i want make cusum and chow test. How i can perfom these without make estimate with rats ?

And if i want make test over residuals which programms i must take ?

thank you
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Stability tests with kalman filter

Unread post by TomDoan »

Once you have the recursive residuals, you can do the CUSUM and Chow tests using anything that can do squares and sums. If you don't have the recursive residuals, you can't get them without redoing the model in RATS. So I'm rather puzzled about why you want to do this by moving the easy part to a different program.
Aktar
Posts: 35
Joined: Thu Apr 16, 2009 8:12 am

Re: Stability tests with kalman filter

Unread post by Aktar »

I don't know if i can have recursive residuals but i think have find

im not sure between all these choice :

smoothed state disturbance estimates
the standardized smoothed state disturbances


i have ask in the forums of eviews but don't have a response


and after which programms i must run ?

thank you very much
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Stability tests with kalman filter

Unread post by TomDoan »

The recursive residuals are the "one-step ahead standardized residuals."
Aktar
Posts: 35
Joined: Thu Apr 16, 2009 8:12 am

Re: Stability tests with kalman filter

Unread post by Aktar »

ok thanks so it is std. residual of signal series ?

after i take the prog constant.prg ?

thank you very much
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Stability tests with kalman filter

Unread post by TomDoan »

You can't use CONSTANT.PRG directly, since it uses RLS, which generates some additional statistics (like the CUSUM). You also can't use the "STABTEST" procedure, since that is specific to an OLS regression.

If you're just starting with the recursive residuals (recresids below, defined over rstart to rend), the CUSUM test would be:

Code: Select all

compute %ndf=(rend-rstart+1)
acc recresids rstart rend cusum
set upper5 rstart rend = .948*sqrt(%ndf)*(1+2.0*(t-rstart+1)/%ndf)
set lower5 rstart rend = -upper5
graph(header="CUSUM test") 3
# cusum
# lower5 / 2
# upper5 / 2
You can generate the CUSUMSQ with this:

Code: Select all

set recresidsqr = recresids^2
acc recresidsqr rstart rend cusumsq
That can be used to form various stability tests like Chow-predictive tests. For instance, a test for the last eight periods can be done with

Code: Select all

compute f=((cusumsq(rend)-cusumsq(rend-8))/8)/(cusumsq(rend-8)/(%ndf-8))
cdf(title="Post-Sample Predictive Test") ftest f 8 %ndf-8
Aktar
Posts: 35
Joined: Thu Apr 16, 2009 8:12 am

Re: Stability tests with kalman filter

Unread post by Aktar »

thank you very much you are magic !

but i don't know how i must set rend and rstart. I have this

Code: Select all

calendar 2002 1 1
allocate 85
open data Classeur1.xls
data(for=xls, org=obs) / recresids
table

set rend =
set rsart = 

compute %ndf=(rend-rstart+1)
acc recresids rstart rend cusum
set upper5 rstart rend = .948*sqrt(%ndf)*(1+2.0*(t-rstart+1)/%ndf)
set lower5 rstart rend = -upper5
graph(header="CUSUM test") 3
# cusum
# lower5 / 2
# upper5 / 2
thank you
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Stability tests with kalman filter

Unread post by TomDoan »

Assuming the residuals start right at the beginning of the file, rstart=1, rend=85
moderator
Site Admin
Posts: 269
Joined: Thu Oct 19, 2006 4:33 pm

Re: Stability tests with kalman filter

Unread post by moderator »

RSTART and REND would need to be integers, not series, so you would use COMPUTE rather than SET to set them.

You want to set them equal to the desired starting and ending entry numbers or dates, as Tom Doan noted.
Aktar
Posts: 35
Joined: Thu Apr 16, 2009 8:12 am

Re: Stability tests with kalman filter

Unread post by Aktar »

than you very much it run !

a last question ;

Code: Select all

calendar 2000 1 12
allocate 108
open data Classeur1.xls
data(for=xls, org=obs) / recresids
table

compute rstart=2000:1
compute rend=2008:12
compute %ndf=(rend-rstart+1)
acc recresids rstart rend cusum
set upper5 rstart rend = .948*sqrt(%ndf)*(1+2.0*(t-rstart+1)/%ndf)
set lower5 rstart rend = -upper5
graph(header="CUSUM test") 3
# cusum
# lower5 / 2
# upper5 / 2


**cusum square
set recresidsqr = recresids^2
acc recresidsqr rstart rend cusumsq
set upper5 rstart rend = .948*sqrt(%ndf)*(1+2.0*(t-rstart+1)/%ndf)
set lower5 rstart rend = -upper5
graph(header="CUSUMQ test") 3
# cusum
# lower5 / 2
# upper5 / 2
I have the same thing when i compute cusum square test, it is something wrong in my prog ?
moderator
Site Admin
Posts: 269
Joined: Thu Oct 19, 2006 4:33 pm

Re: Stability tests with kalman filter

Unread post by moderator »

Aktar wrote:I have the same thing when i compute cusum square test
The same thing as what? Please clarify.
Aktar
Posts: 35
Joined: Thu Apr 16, 2009 8:12 am

Re: Stability tests with kalman filter

Unread post by Aktar »

sorry, i have the same graphic "cusum" when i compute the prog for cusum square and cusum


For cusum

Code: Select all

calendar 2000 1 12
allocate 108
open data Classeur1.xls
data(for=xls, org=obs) / recresids
table

compute rstart=2000:1
compute rend=2008:12
compute %ndf=(rend-rstart+1)
acc recresids rstart rend cusum
set upper5 rstart rend = .948*sqrt(%ndf)*(1+2.0*(t-rstart+1)/%ndf)
set lower5 rstart rend = -upper5
graph(header="CUSUM test") 3
# cusum
# lower5 / 2
# upper5 / 2
and for cusum square :

Code: Select all

calendar 2000 1 12
allocate 108
open data Classeur1.xls
data(for=xls, org=obs) / recresids
table

**cusum square

compute rstart=2002:2
compute rend=2008:12
compute %ndf=(rend-rstart+1)

set recresidsqr = recresids^2
acc recresidsqr rstart rend cusumsq
set upper5 rstart rend = .948*sqrt(%ndf)*(1+2.0*(t-rstart+1)/%ndf)
set lower5 rstart rend = -upper5
graph(header="CUSUMQ test") 3
# cusum
# lower5 / 2
# upper5 / 2
moderator
Site Admin
Posts: 269
Joined: Thu Oct 19, 2006 4:33 pm

Re: Stability tests with kalman filter

Unread post by moderator »

Aktar wrote:sorry, i have the same graphic "cusum" when i compute the prog for cusum square and cusum

...

Code: Select all

graph(header="CUSUMQ test") 3
# cusum
# lower5 / 2
# upper5 / 2
It appears from the GRAPH instruction above that you are graphing the series CUSUM, when you meant to graph the series CUSUMSQ.
Aktar
Posts: 35
Joined: Thu Apr 16, 2009 8:12 am

Re: Stability tests with kalman filter

Unread post by Aktar »

ok thanks but it normal that the corridor is the same for the 2 tests ?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Stability tests with kalman filter

Unread post by TomDoan »

Aktar wrote:ok thanks but it normal that the corridor is the same for the 2 tests ?
No, they're quite different (rather obviously, since the sums of squares can't be negative). The CUSUMQ is based upon the maximum gap between a straight line and the cumulated sum of squares, standardized to end at 1.0:

Code: Select all

set recresidsqr = recresids^2
acc(standardize) recresidsqr rstart rend cusumsq
set target rstart rend = (t-rstart+1.0)/(rend-rstart+1.0)
graph 2
# cusumsq
# target
If the squared residuals are roughly the same size throughout the data, that will tend to hug the line. If they're generally small, then get larger, it will drop well below the line early in the data set.
Post Reply