Matrix assigments problems

For questions regarding programming in the EViews programming language.

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

diallo85
Posts: 3
Joined: Fri Jul 20, 2012 10:41 am

Matrix assigments problems

Postby diallo85 » Sat Jul 21, 2012 8:37 am

Greetings everyone!

I have a small problem I could use some help with.

I am trying to compute a rolling VAR and rearrange the output coefficients in a row of a new matrix (A), so I could plot their evolution over time.

The only problem is that during the assignment process, the new matrix (A) does not contain the coefficients as they appear in the var output.

I've stuck for 3days now. This is the code as I wrote it:

Code: Select all

' set sample smpl @all ' find size of workfile series _temp = 1 !length = @obs(_temp) delete _temp ' set fixed sample size !ssize = 1002 !lag=1 'Create Group containing all variables to include in var group G CAC DJ EON EXCH IMS INT5 NSDQ OIL 'Number of columns in VAR output !K = G.@count for !t = 1 to !length-!ssize+1 ' set rolling subsample smpl @first+!t-1 @first+!t+!ssize-2 'Create VAR system var var.LS 1 !lag CAC DJ EON EXCH IMS INT5 NSDQ OIL matrix((!K*!lag)+1,!K) temp = var.@coefmat for !c = 1 to (!K*(!K*!lag)+1) for !j = 1 to !K for !i = 1 to ((!k*!lag)+1) 'save coefficients var_coefs(!t,!c) = temp(!i,1) next next next next show var_coefs

--------------------------
Can anyone give me fresh insight please!!!!

Thank you in advance!

DIALLO85

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

Matrix assigments problems

Postby EViews Gareth » Sat Jul 21, 2012 9:27 am

Need a bit more info on what you're trying to do, I think.

diallo85
Posts: 3
Joined: Fri Jul 20, 2012 10:41 am

Re: Matrix assigments problems

Postby diallo85 » Sat Jul 21, 2012 9:40 am

Need a bit more info on what you're trying to do, I think.
VAR estimation output comes in the form of a (K*P+1,K) matrix, K being the number of variables and P the number of lags (+1 is for intercept).

I am trying to put this (K*P+1, K) matrix into a (1, K*(K*P+1)) matrix (i.e. a rowvector) containing all estimated coefficients aligned in the row.

a e i
b f j
c g k
d h m

becomes

a b c d e f g h i j k m

Does that help a bit more?

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

Re: Matrix assigments problems

Postby EViews Gareth » Sat Jul 21, 2012 10:18 am

Don't you just want to vec it then?

Code: Select all

vector temp = @vec(var.@coefmat)

diallo85
Posts: 3
Joined: Fri Jul 20, 2012 10:41 am

Re: Matrix assigments problems

Postby diallo85 » Sat Jul 21, 2012 12:27 pm

Don't you just want to vec it then?

Code: Select all

vector temp = @vec(var.@coefmat)

Thank you Gareth, I couldnt possibly thank you enought.

I was nowhere close to thinking of the @vec function! Thank you a million

Its working great, and I have succeded in onstructing my code in its entirety!

great idea this forum thing and great job being done here!!

Thanx ;)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests