Page 1 of 1
Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 5:27 am
by nadja123
Hi there,
a quick reply to this (stupid) question would be of a great help (deadline pressure etc):
How shall I raise matrix to power, I mean e.g. A^i, i=1 to 5, so that A^2 = A * A, etc? By mistake I thought, @epow() does this, but in fact that command raises each element to a power.
Many thanks!!!
Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 8:48 am
by EViews Gareth
Don't think so
Re: Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 11:19 am
by nadja123
Hi Gareth,
thanks for reply, which I, however, do not understand at all. I just need to use in a code something like A^i, i=1 to 5, so that A^2 = A * A, etc... Please can my question be replied, in the event I did not write some mathematical nonsense? It is maybe a small thing, but it is urgent for me.
Thanks!!
Re: Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 12:54 pm
by EViews Gareth
There is no function to raise a matrix to a power. Thus you'll have to write matrix A2 = A*A
Re: Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 1:10 pm
by nadja123
Re: Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 1:16 pm
by EViews Gareth
Code: Select all
matrix a30 = a
for !i=2 to 30
a30 = a30*a
next
Re: Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 1:42 pm
by nadja123
Gareth,
I tried to run your small code. It worked as it was. Now I ma trying to get it to a loop:
for !j = 2 to 5
matrix a{!j} = a
a{!j} = a{!j} * a
next
I do not understand everything about it, but it seems to me that it is using some sort of memory. I mean, at debugging it continues instead of running from the beginning. If I clear the memory by closing the workfile and program, anyway it does strange things.
In particular, it does not take the matrix to 0 or 1. But these two cases I can easily sacrifice as they give an easily known result.
Then, anyway I am getting strange things as from 2 on. I am sorry, I am not any strong in programming and maths... May I just please ask for more helping...? Thanks!! I am lost in this.
Re: Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 1:58 pm
by EViews Gareth
Can you describe what you're trying to do?
Re: Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 3:02 pm
by nadja123
Well, I just need to compute a set of impulse response coefficient matrices phi_{i}, using two known matrices A and B.
The formula is in the attached .pdf. Maybe I am stupid but I automatically supposed I could write a loop in Eviews using a command that would raise the A matrix to a power i going from 0 to an integer. I need to store the phi matrices to the workfile, extract coefficients from them into graphs... etc. I hope this attempt for explanation makes it more clear.... Thanks for helping, it is really important (urgent

)
PS By the way, the whole stuff with writing own code for IRF started when I realized that one is not really permitted to use an externally estimated identification (transformation) matrix in EV 6 VAR model. It was my post under the programming forum, "Structural VAR (EV 6) by nadja123 on Wed Apr 28, 2010 2:57 pm"
Re: Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 3:19 pm
by EViews Gareth
Code: Select all
for !i=1 to !n
matrix a!i = a
for !j=2 to !i
a!i = a!i*a
next
next
Re: Raising matrix to power (EV 6)
Posted: Sat May 08, 2010 3:25 pm
by nadja123
While you were writing the last post, I too wrote a few lines. I will have a look on your suggestion tomorrow (it is 0:22am for me), until then thanks. My apologies to Gareth and all forum users, my brain just stopped working when I was posting this whole question
Code: Select all
'starting with an existing matrix a
matrix a1 = a
for !j = 2 to 5
!i = !j - 1
matrix a{!j} = a{!i} * a
next