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
matrix multiplication
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: matrix multiplication
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.
Re: matrix multiplication
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
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
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
Re: matrix multiplication
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?
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
Set the sample so that it only has 726,188 observations.
Re: matrix multiplication
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?
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 (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
Most likely just a facet of your data.
In general, of course, that will not be the case:
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
Re: matrix multiplication
Your are right Gareth. Facet of my data.
Who is online
Users browsing this forum: No registered users and 1 guest
