Page 1 of 1

Matrix assigments problems

Posted: Sat Jul 21, 2012 8:37 am
by diallo85
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

Matrix assigments problems

Posted: Sat Jul 21, 2012 9:27 am
by EViews Gareth
Need a bit more info on what you're trying to do, I think.

Re: Matrix assigments problems

Posted: Sat Jul 21, 2012 9:40 am
by diallo85
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?

Re: Matrix assigments problems

Posted: Sat Jul 21, 2012 10:18 am
by EViews Gareth
Don't you just want to vec it then?

Code: Select all

vector temp = @vec(var.@coefmat)

Re: Matrix assigments problems

Posted: Sat Jul 21, 2012 12:27 pm
by diallo85
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 ;)