matrix multiplication

For questions regarding programming in the EViews programming language.

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

mark
Posts: 37
Joined: Thu Mar 12, 2009 3:27 pm

matrix multiplication

Postby mark » Wed Mar 18, 2009 11:46 am

Hi

I have m1(320,727) and m2(727,727).

Is there any way to multiply these to get m3 or must both matrices by the same dimension? Thanks

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

Re: matrix multiplication

Postby EViews Gareth » Wed Mar 18, 2009 11:51 am

For matrix multiplication, the matrices have to be conformable, such that to perform A*B, the columns of A must equal the rows of B.

aelshahat
Posts: 2
Joined: Fri Jun 06, 2014 12:11 pm

Re: matrix multiplication

Postby aelshahat » Tue Jun 10, 2014 12:55 pm

I converted a group1 (5 time-series so it is T X 5) to a matrix using @convert, now I need to multiply this matrix with the output of a PCA (5X5 EigenVector). I tried the following but nothing workds:
I typed the following in the command pane:
matrix m3 = emult(group1,pca) ---> in the manual it says that both matrices need to be identical (is that the problem?) If, yes, then how would you multiply a conformable, non-identical matrices? The error message is: Sizes do not match in matrix function.

I also used the object/generate series, then typed: matrix m3 = group1*pca

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

Re: matrix multiplication

Postby EViews Gareth » Tue Jun 10, 2014 1:00 pm

emult does element wise multiplication. If you want to do actual matrix multiplication, you just need to type:

Code: Select all

matrix m2 = @convert(group1) matrix m3 = m2*pca

aelshahat
Posts: 2
Joined: Fri Jun 06, 2014 12:11 pm

Re: matrix multiplication

Postby aelshahat » Tue Jun 10, 2014 2:25 pm

Thank you for your prompt reply.
I have another problem: when I tried to convert the matrix back to a group. I used mtos(m3,g2) but it gave me the following error message: "m3 is not the same length as the sample". The sample is 726,190 and m3 is 726,188 (the first and last rows were eliminated as they contained NA).
How do you suggest that I make the conversion back to a group?

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

Re: matrix multiplication

Postby EViews Gareth » Tue Jun 10, 2014 2:27 pm

Set the sample so that it only has 726,188 observations.

huseyinky
Posts: 18
Joined: Mon Apr 20, 2009 1:59 pm

Re: matrix multiplication

Postby huseyinky » Mon Jan 30, 2017 3:43 pm

Hi
I have a matrix(12,12) A and a vector(12) B. When I declare a vector AB=@inverse(A)*B, I get very unreasonable result that all elements of AB same but must be different. Does anyone has any explanation for that?
Attachments
Adsız.png
Adsız.png (108.44 KiB) Viewed 11682 times

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

Re: matrix multiplication

Postby EViews Gareth » Mon Jan 30, 2017 3:52 pm

Most likely just a facet of your data.

In general, of course, that will not be the case:

Code: Select all

create u 10 matrix(12,12) a rnd(a) a=a*a vector(12) b rnd(b) show a show b vector ab=@inverse(a)*b show ab

huseyinky
Posts: 18
Joined: Mon Apr 20, 2009 1:59 pm

Re: matrix multiplication

Postby huseyinky » Mon Jan 30, 2017 4:03 pm

Your are right Gareth. Facet of my data.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest