## Elementwise multiplication

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.
ral
Posts: 23
Joined: Tue Oct 21, 2014 2:44 pm

### Elementwise multiplication

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

I think you'll have to do it manually in a for loop.

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

### Re: Elementwise multiplication

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

Just multiply the matrices using *

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

### Re: Elementwise multiplication

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

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

### Re: Elementwise multiplication

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

### Who is online

Users browsing this forum: No registered users and 4 guests