Elementwise multiplication

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Jason, EViews Moderator, EViews Pamela

ral
Posts: 23
Joined: Tue Oct 21, 2014 2:44 pm

Elementwise multiplication

Postby ral » Tue Oct 21, 2014 2:51 pm

I have a TxN matrix A that I want to multiply by a Tx1 vector b elementwise. That is, I want to multiply each of the N columns of length T by the vector b. This would work with the function @emult if the two matrices were of the same dimension (e.g., if A were Tx1 in my case). Is there a workaround for this problem?

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

Re: Elementwise multiplication

Postby EViews Gareth » Tue Oct 21, 2014 3:40 pm

I think you'll have to do it manually in a for loop.
Follow us on Twitter @IHSEViews

awatt43
Posts: 7
Joined: Mon Aug 21, 2017 12:19 am

Re: Elementwise multiplication

Postby awatt43 » Wed Sep 13, 2017 1:26 am

Hi there,
I am looking for the eviews command that would replicate the excel function mmult, this function is described as "Returns the matrix product of two arrays. The result is an array with the same number of rows as array1 and the same number of columns as array2.".

I have been using @inner but this seems to give me different results.

Any help would be much appreciated!

Thanks,
Abi

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

Re: Elementwise multiplication

Postby EViews Gareth » Wed Sep 13, 2017 6:00 am

Just multiply the matrices using *
Follow us on Twitter @IHSEViews

awatt43
Posts: 7
Joined: Mon Aug 21, 2017 12:19 am

Re: Elementwise multiplication

Postby awatt43 » Wed Sep 13, 2017 6:55 am

Hi Gareth

This only works if the matrices are of the same size, in excel the data has to be the same number of columns as rows in the first.

Is there a way to do the matrix product of two matrices of differing sizes?

First matrix is 15x15 and the second is 1x15.

Thanks,
Abi

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

Re: Elementwise multiplication

Postby EViews Gareth » Wed Sep 13, 2017 7:28 am

Follow us on Twitter @IHSEViews

awatt43
Posts: 7
Joined: Mon Aug 21, 2017 12:19 am

Re: Elementwise multiplication

Postby awatt43 » Wed Sep 13, 2017 7:48 am

Oh wow! I was being genuinely moronic... Just needed to transpose one of the matrices. Apologies!


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 4 guests