On Fri, 23 Aug 2019, Riccardo (Jack) Lucchetti wrote:
On Fri, 23 Aug 2019, Sven Schreiber wrote:
> Hi,
>
> in the GUI it is easy to get a plot of estimated VAR residuals.
> But it seems surprisingly difficult to do the same thing via scripting.
> I can save the residuals by $uhat, but that gives me a matrix (not a
> variable list), and converting the columns in that matrix to series
> fails because of length mismatch.
>
> I know I _could_ adjust the workfile sample to match the effective
> sample of the VAR and then the conversion to series would work, but that
> feels quite clumsy. (And have to reset the workfile sample afterwards.)
>
> Any recommendations how to achieve that quick and easy?
This should do it:
<hansl>
set verbose off
open denmark.gdt --quiet
list X = LRM LRY IBO IDE
var 4 X --silent
matrix U = $uhat
cnameset(U, varnames(X))
gnuplot --matrix=U --with-lines --time-series --output=display
</hansl>
this could be made nicer with a column for time; unfortunately, I can't think
of any easy automatic way to construct this, other than introducing a couple
of new functions to retrieve the "t1" and "t2" integers that are
contained in
the matrix info.
Or perhaps, something like this (but it's not pretty)
<hansl>
set verbose off
open AWM18.gdt --quiet
list Y = YER PCR GCR ITR
list X = logs(Y)
scalar p = 4
var p X --silent --seasonals
tt = seq(0, $t2 - $t1 - p)/$pd
t0 = $obsmajor[$t1+p-1] + $obsminor[$t1+p-1]/$pd
tt = t0' + tt'
matrix U = $uhat ~ tt
cnameset(U, varnames(X)+ defarray("Time"))
gnuplot --matrix=U --with-lines --output=display
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------