On Wed, 15 Feb 2006, john w wrote:
I got one question. Is it possible to implement as a new feature,
or to compute the procedure to detect large standardized residuals
(and dates) of VAR and VECM models for some standardized residual
value?
For example: detect all standardized residuals values and dates
for standardized residuals that exceede value of 2.
Here's a sample script that may help. It uses gretl's new matrix
facility (in CVS and the Windows snapshot).
open data9-7
set echo off
# 3-equation VAR
myvar <- var 2 PRICE INCOME PRIME
# save residuals matrix and cross-equation residual
# variance matrix
matrix vresid = myvar.$uhat
matrix var_vcv = myvar.$vcv
# get per-equation standard errors
matrix vse = sqrt(diag(var_vcv))
# the VAR residuals have two missing observations at the
# start of the data; advance the sample start to skip
# them
smpl +2 ;
loop i=1..3 --quiet
# extract the columns of vresid as series
series uhat$i = vresid[,$i]
# extract the per-equation residual standard errors
scalar se = vse[$i]
# make standardized residuals series
series ustd$i = uhat$i / se
# make dummy series identifying "big" residuals
series ubig$i = abs(ustd$i) > 2.0
endloop
# print the residuals info in various forms
print uhat1 uhat2 uhat3 --byobs
print ustd1 ustd2 ustd3 --byobs
print ubig1 ubig2 ubig3 --byobs
# count big residuals per equation
loop i=1..3 --quiet
scalar cbig = sum(ubig$i)
printf "Equation $i has %d standardized residuals > 2.0\n", cbig
endloop
Allin Cottrell