Matrix of autocovariance of a var

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

javvk
Posts: 4
Joined: Tue Jan 15, 2019 8:13 am

Matrix of autocovariance of a var

Postby javvk » Tue Jan 15, 2019 12:37 pm

Hi,
i want to know, how to do estimate the matrix of autocovariance 0 and 1 of a var.
I think, a loop could help me, but i don´t know how to use it.
this is my var

wfcreate u 1 600

smpl @first @first+1
series w= nrnd*@mean(9)*@sqrt(15)
series y= nrnd*@mean(12)*@sqrt(8)

smpl @first+2 @last
series u= nrnd*@sqrt(2)
series e= nrnd*@sqrt(6)

smpl @first+2 @last
series w= 0.2*w(-1) + 0.3*w(-2)+ u
series y= 0.4*y(-1) + 0.1*y(-2)+ e

var var2.ls(noconst) 1 2 w y
var2.results
var2.ls(noconst) 1 1 w y

Anyone knows how to do it??
thank u very much.

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: Matrix of autocovariance of a var

Postby EViews Matt » Tue Jan 15, 2019 3:00 pm

Hello,

EViews is more than capable of calculating the autocovariances and crosscovariances for you, so there's no need to loop through the data yourself. Here's a quick way to calculate what you want,

Code: Select all

group g w y w(-1) y(-1)
g.cov(out=tmp)
matrix ac0 = @subextract(tmpcov, 1, 1, 2, 2)
matrix ac1 = @subextract(tmpcov, 1, 3, 2, 4)
delete g tmpcov

The above code groups all the relevant data together and then calculates all the pairwise covariances. However, the information you asked for is just a subset of those results. The two @subextract calls copy just the lag 0 and lag 1 autocovariance information to two separate matrices.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 29 guests