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)
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Raising matrix to power (EV 6)
Don't think so
Re: Raising matrix to power (EV 6)
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!!
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!!
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Raising matrix to power (EV 6)
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)
Gareth,
you are nice I mean but... I was not serious when I wrote i=1 to 5, that was just kinda give an example. I need to take it to 30 or so! I am writing a code for IRFs that use an externally estimated indentification (transformation matrix) and quite need to compute about 30 periods ahead
I think this topic belongs under tips and missing things in EV rather than under programming forum. I'm going to paste it there... :?
you are nice I mean but... I was not serious when I wrote i=1 to 5, that was just kinda give an example. I need to take it to 30 or so! I am writing a code for IRFs that use an externally estimated indentification (transformation matrix) and quite need to compute about 30 periods ahead
I think this topic belongs under tips and missing things in EV rather than under programming forum. I'm going to paste it there... :?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Raising matrix to power (EV 6)
Code: Select all
matrix a30 = a
for !i=2 to 30
a30 = a30*a
next
Re: Raising matrix to power (EV 6)
Gareth,
I tried to run your small code. It worked as it was. Now I ma trying to get it to a loop:
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.
I tried to run your small code. It worked as it was. Now I ma trying to get it to a loop:
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.for !j = 2 to 5
matrix a{!j} = a
a{!j} = a{!j} * a
next
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.
- Attachments
-
- commandpower.prg
- (81 Bytes) Downloaded 599 times
-
- matrixpower.WF1
- (8.13 KiB) Downloaded 492 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Raising matrix to power (EV 6)
Can you describe what you're trying to do?
Re: Raising matrix to power (EV 6)
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"
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"
- Attachments
-
- 08052010.pdf
- (15.84 KiB) Downloaded 664 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Raising matrix to power (EV 6)
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)
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
Who is online
Users browsing this forum: No registered users and 2 guests
