RATS 11
RATS 11

Procedures /

STAMPDIAGS Procedure

Home Page

← Previous Next →

@STAMPDiags produces the standard set of diagnostics for a (univariate) state space model used by the STAMP™ software. This includes a Q test for serial correlation, Normality test, and Goldfeld-Quandt type heteroscedasticity test.


 

@STAMPDiags( options )  resids  start end

Parameters

resids

series to analyze

start, end

range of resids to use. By default, the defined range of resids.

Options

NCORRS=number of correlations to use in computing the Q statistic

 [depends upon number of observations]

 

N=number of data points in the partitions for the heteroscedasticity test

  [roughly 1/3 of number of observations]

 

TITLE=title for report ["State Space Model Diagnostics"]

Example

This fits a local level state-space model to a set of data and does diagnostics on the standardized one-step predictive residuals (or recursive residuals) which should be uncorrelated, mean zero, variance one and normally distributed under the assumptions used in estimating the model.

 

*

* Commandeur & Koopman, An Introduction to State Space Time Series Analysis.

* Chapter 2 - Norway data

*

open data norwayfinland.txt

calendar(a) 1970

data(format=free,org=columns,skips=1) 1970:01 2003:01 year norway finland

*

set lognorway = log(norway)

*

@LocalDLMInit(irreg=sigsqeps) lognorway

nonlin sigsqeps sigsqxi

compute sigsqxi=sigsqeps*.01

*

dlm(a=1.0,c=1.0,sv=sigsqeps,sw=sigsqxi,presample=diffuse,y=lognorway,$

  method=bfgs,vhat=vhat,svhat=svhat)

set resids = %scalar(vhat)/sqrt(%scalar(svhat))

@STAMPDiags(ncorr=10) resids

 

Output

This is the output from the test above. The first test is the Ljung-Box Q test for serial correlation (done with 10 autocorrelation, with 1 degree of freedom correction), Normality is the Jarque-Bera test, and H is a test for a difference in the variance between the start and end of the residual series. The first 11 are tested vs the last 11. (By default, each of those is roughly a third of the data set with the middle third omitted). Under the null, this has an F distribution with 11,11 degrees of freedom. (The statistic shown in the larger variance over the smaller one, so it's just a one-tailed F).
 

State Space Model Diagnostics

          Statistic Sig. Level

Q(10-1)        6.23     0.7171

Normality      1.08     0.5822

H(11)          1.75     0.3688


 


Copyright © 2025 Thomas A. Doan