I have a Stata data file where there are 42 countries and 35 industries. Each column shows one country's final use of products from all country-sectors. (see the attached image of the data structure).
I need to create a (42x42) block matrix, say D, from the data, where each block is a (35x35) diagonal submatrix formed from one country's final use of another country's 35 sectors(including its own). The final result will be a (42x35)x(42x35) matrix.
e.g. The first 35 row values in the first column are Australia's final use of the products from its own 35 sectors:
[ AUSfinaluse(1,1) ]
[.............................]
[ AUSfinaluse(i,1) ]
[.............................]
[AUSfinaluse(35,1)]
from which I want to form the first (35x35) submatrix or D(1,1) looking like this:
[ AUSfinaluse(1,1) 0............. 0 ]
[ ... .......................................... ]
[ 0 ... 0 AUSfinaluse(i,1) 0.....0 ]
[ ... .......................................... ]
[ 0 ...........0 AUSfinaluse(35,1) ]
The next 35 row values of the first column are Australia's final use of the products from Austria (AUT)'s 35 sectors, from which to create submatrix D(2,1), looking like this:
[ AUSfinaluse(36,1) 0............. 0 ]
[ ... .......................................... ]
[ 0 ... 0 AUSfinaluse(i,1) 0.....0 ]
[ ... .......................................... ]
[ 0 ...........0 AUSfinaluse(70,1) ]
I have to repeat this for Austrialia's final use (column AUSfinaluse) of the products from the rest of the 40 countries; and then, do the same thing column by column for all the 42 countries' final use (42 columns).
Any suggestion for an efficient solution to this task would be much appreciated!
I need to create a (42x42) block matrix, say D, from the data, where each block is a (35x35) diagonal submatrix formed from one country's final use of another country's 35 sectors(including its own). The final result will be a (42x35)x(42x35) matrix.
e.g. The first 35 row values in the first column are Australia's final use of the products from its own 35 sectors:
[ AUSfinaluse(1,1) ]
[.............................]
[ AUSfinaluse(i,1) ]
[.............................]
[AUSfinaluse(35,1)]
from which I want to form the first (35x35) submatrix or D(1,1) looking like this:
[ AUSfinaluse(1,1) 0............. 0 ]
[ ... .......................................... ]
[ 0 ... 0 AUSfinaluse(i,1) 0.....0 ]
[ ... .......................................... ]
[ 0 ...........0 AUSfinaluse(35,1) ]
The next 35 row values of the first column are Australia's final use of the products from Austria (AUT)'s 35 sectors, from which to create submatrix D(2,1), looking like this:
[ AUSfinaluse(36,1) 0............. 0 ]
[ ... .......................................... ]
[ 0 ... 0 AUSfinaluse(i,1) 0.....0 ]
[ ... .......................................... ]
[ 0 ...........0 AUSfinaluse(70,1) ]
I have to repeat this for Austrialia's final use (column AUSfinaluse) of the products from the rest of the 40 countries; and then, do the same thing column by column for all the 42 countries' final use (42 columns).
Any suggestion for an efficient solution to this task would be much appreciated!
Comment