Matrix Fill from VAR Coefficients (Quick Question)

For questions regarding programming in the EViews programming language.

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

alex_hk90
Posts: 19
Joined: Tue Feb 22, 2011 1:48 pm

Matrix Fill from VAR Coefficients (Quick Question)

Postby alex_hk90 » Sat Apr 02, 2011 1:47 pm

I'm trying to transfer the coefficients from a reduced form VAR to coefficient matrices, but the way I've tried seems to require going via a scalar variable.

In the simplest case, the following works:
scalar C1_11 = var01.c(1,1)
var01_C1.fill(b=r) C1_11, 0, 0, 0, 0, 0, 0, 0, 0

But the following doesn't (it returns 'Syntax error'):
var01_C1.fill(b=r) var01.c(1,1), 0, 0, 0, 0, 0, 0, 0, 0

Is there any way of doing it that doesn't require temporary scalar variables?

Thanks in advance. :)

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

Re: Matrix Fill from VAR Coefficients (Quick Question)

Postby EViews Gareth » Sat Apr 02, 2011 1:52 pm

Code: Select all

var01_c1 = 0 var01_c1(1,1) = var01.c(1,1)

alex_hk90
Posts: 19
Joined: Tue Feb 22, 2011 1:48 pm

Re: Matrix Fill from VAR Coefficients (Quick Question)

Postby alex_hk90 » Sat Apr 02, 2011 2:15 pm

Code: Select all

var01_c1 = 0 var01_c1(1,1) = var01.c(1,1)
Thanks for the very quick reply. :) That method would still require one line per element, but it looks like it can easily be put in a loop so that's fine. :)

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

Re: Matrix Fill from VAR Coefficients (Quick Question)

Postby EViews Gareth » Sat Apr 02, 2011 2:38 pm

It isn't particularly clear what you're trying to do. Why not just do:

Code: Select all

matrix var01_c1 = var01.coefmat

alex_hk90
Posts: 19
Joined: Tue Feb 22, 2011 1:48 pm

Re: Matrix Fill from VAR Coefficients (Quick Question)

Postby alex_hk90 » Sat Apr 02, 2011 2:44 pm

It isn't particularly clear what you're trying to do. Why not just do:

Code: Select all

matrix var01_c1 = var01.coefmat
I want it in the standard format (where C1 is the matrix of all lag 1 coefficients, C2 for lag 2, etc.), where:
x_t = C1*x_t-1 + C2*x_t-2 + ...
is the reduced form VAR.

So with your first reply I can now just do:

Code: Select all

matrix(3,3) {%0} for !i = 1 to 3 for !j = 1 to 3 {%0}(!i,!j) = var01.c(!i,({%1}+(!j-1)*4)) next next
(where var01 is the reduced form VAR(4) [hence the hard-coded 4]; %0 is the resulting matrix [C#]; %1 is the lag [#])

Thanks again. :)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests