On Tue, 13 Oct 2020, Allin Cottrell wrote:
On Tue, 13 Oct 2020, Daniel Ventosa-Santaulària wrote:
> Hello everyone,
> I am having trouble with the recovery of the residuals in a VAR model. If
> if do it though the GUI everything is ok, but if I try to do it through a
> code, then I can only recover the residuals (as a time series) of the
> first equation, but for the remaining equations, I can only get them as a
> matrix. Here is this simple example code:
>
> open np.gdt
> var 2 rgnp emply interest --robust
> series Resid1=$uhat[,1] # This one works perfectly
> series Resid2=$uhat[,2] # This one does not; mismatch between series and
> matrix
>
> this is probably a rookie's mistake, but I cannot see where the problem is.
It seems like this ought to work, I need to take a closer look. But you can
extract the other columns of $uhat as series if you set the sample range to
start at the first observation used by the VAR:
smpl 1911 ;
series Resid1=$uhat[,1]
series Resid2=$uhat[,2]
A slight generalisation:
<hansl>
open np.gdt
list X = rgnp emply interest
var 2 X --robust
scalar t1 = $system.t1
scalar t2 = $system.t2
U = $uhat
smpl t1 t2
loop foreach i X
series Res_$i = $uhat[,i]
endloop
smpl full
</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
-------------------------------------------------------