Hello!
Is it possible to integrate matrix and vector objects (changing over time) into the model environment and do matrix calculations inside it?
For example, I have a singleequations macroeconomic model. For estimating real exports it would be useful to use the real exchange rate of the trading partners weighted with the export share of the corresponding trading partners. These shares can be defined as a vector changing over time, the same applies for the countrybycountry exchange rates. In excel I would use the function "sumproduct" in these cases...
Another example: with inputoutputtables (e.g. 50*60 matrices) one can link the demand side of the economy with the supply side. These tables show how production in the economic sectors is affected by a change in private consumption for example. To calculate these effects, inverse coefficients of the matrix has to be derived. And the matrix itself can or should change over time also.
The handbook is not saying anything about this question, and my own tries has been unsuccessful so far. I guess that the model environment is limited to simple mathematical and basic logical operations, and my aim goes beyond the abilities of Eviews?!
Regards, Jan
Integration of matrices and vectors in model environment?
Moderators: EViews Gareth, EViews Moderator

 EViews Developer
 Posts: 161
 Joined: Wed Sep 17, 2008 10:39 am
Re: Integration of matrices and vectors in model environment?
For the most part, you're not going to be able to do matrix calculations during a model solve. You can use elements of matrices that have already been calculated before the model solve as coefficients in an equation.
It would also be possible to write an EViews program where you allowed only a single iteration during each call to the model solve procedure. You could then cary out matrix calculations 'between' iterations. This would effectively be a sort of GaussSeidel algorithm for updating the matrices as you solved the model.
As far as the IO model goes, you could presumably use EViews to solve the model by translating the IO matrix into a set of equations. i.e something like this:
y1 = A(1,1)*y1 + A(1,2)*y2 + B(1,1)*x1 + B(1,2)*x2
y2 = A(2,1)*y2 + A(2,2)*y2 + B(2,1)*x1 + B(2,2)*x2
where the y's are the output levels and the x's are the nonmanufactured inputs (this isn't my area, so I'm not sure of the correct terminology here) and A and B are coefficient matrices.
You probably wouldn't want to have to write out equation text like this by hand, but it wouldn't be hard to program something that generated the required text.
If you wanted the coefficients to change over time, you could write an EViews program that called the model solve procedure inside a loop, solving only a single period each time and updating the matrix at each time period to new values.
It would also be possible to write an EViews program where you allowed only a single iteration during each call to the model solve procedure. You could then cary out matrix calculations 'between' iterations. This would effectively be a sort of GaussSeidel algorithm for updating the matrices as you solved the model.
As far as the IO model goes, you could presumably use EViews to solve the model by translating the IO matrix into a set of equations. i.e something like this:
y1 = A(1,1)*y1 + A(1,2)*y2 + B(1,1)*x1 + B(1,2)*x2
y2 = A(2,1)*y2 + A(2,2)*y2 + B(2,1)*x1 + B(2,2)*x2
where the y's are the output levels and the x's are the nonmanufactured inputs (this isn't my area, so I'm not sure of the correct terminology here) and A and B are coefficient matrices.
You probably wouldn't want to have to write out equation text like this by hand, but it wouldn't be hard to program something that generated the required text.
If you wanted the coefficients to change over time, you could write an EViews program that called the model solve procedure inside a loop, solving only a single period each time and updating the matrix at each time period to new values.
Re: Integration of matrices and vectors in model environment?
Thank you for your answer Chris; it seems to be possible with some (or a lot) detours, but not quite comfortable.
Wouldn't that be a feature worth thinking of to implement in Eviews? As far as I understand this would be possible in principle, TROLL for example seems to be capable of dealing with timeindexed arrays inside simulations...
Wouldn't that be a feature worth thinking of to implement in Eviews? As far as I understand this would be possible in principle, TROLL for example seems to be capable of dealing with timeindexed arrays inside simulations...

 Posts: 2
 Joined: Wed Oct 02, 2013 4:51 pm
Re: Integration of matrices and vectors in model environment
Dear Chris and Jan
Has version 8 improved things? It has new matrix capabilities, so is the situation that Chris described still correct? I am interested in using inputoutput matrices in an integrated econometric/IO model. Thanks
Has version 8 improved things? It has new matrix capabilities, so is the situation that Chris described still correct? I am interested in using inputoutput matrices in an integrated econometric/IO model. Thanks

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 11923
 Joined: Tue Sep 16, 2008 5:38 pm
Re: Integration of matrices and vectors in model environment
Nothing has changed in that respect.
Follow us on Twitter @IHSEViews

 EViews Developer
 Posts: 2600
 Joined: Wed Oct 15, 2008 9:17 am
Re: Integration of matrices and vectors in model environment
Can you provide additional detail on exactly what you want solved?

 Posts: 2
 Joined: Wed Oct 02, 2013 4:51 pm
Re: Integration of matrices and vectors in model environment
Dear Glenn
The attached code shows a toy model. The B matrix is a standard Leontief (IA)^(1) matrix. I have used the clue in the thread and created 16 Bi,j variables for the sample period. This works, but is indeed inconvenient when the number of industries gets above toy numbers (e.g. 100). A time dimension to vectors and matrices would seem to be the desired enhancement, as Jan suggested. Further, one would want to set up equations which create adjustments to the IO coefficient matrices as well, as part of the model solution. Again, timedimensioned vectors and matrices would seem to be desirable to make for a more elegant and useful coding system. Multiple dimensioned, with time as a standard dimension, would be useful, e.g. consumers expenditure might be usefully dimensioned by time, industry and consumption category.
program TOY
smpl 1990 2012
equation eq_fd_agr.ls log(FD_AGR) c log(GRO_AGR(1)) log(GDP)
equation eq_fd_min.ls log(FD_MIN) c log(GRO_MIN(1)) log(GDP(1))
equation eq_fd_man.ls log(FD_MAN) c log(GRO_MAN(1)) log(GDP)
equation eq_fd_ser.ls log(FD_SER) c log(GRO_SER(1)) log(GDP)
model TOY
smpl 1990 2012
TOY.merge eq_fd_agr
TOY.merge eq_fd_min
TOY.merge eq_fd_man
TOY.merge eq_fd_ser
TOY.append @identity GRO_AGR = B11 * FD_AGR + B12 * FD_MIN + B13 * FD_MAN + B14 * FD_SER
TOY.append @identity GRO_MIN = B21 * FD_AGR + B22 * FD_MIN + B23 * FD_MAN + B24 * FD_SER
TOY.append @identity GRO_MAN = B31 * FD_AGR + B32 * FD_MIN + B33 * FD_MAN + B34 * FD_SER
TOY.append @identity GRO_SER = B41 * FD_AGR + B42 * FD_MIN + B43 * FD_MAN + B44 * FD_SER
TOY.solve
Thanks (PS how does one put the code into a little window?)
Peter
The attached code shows a toy model. The B matrix is a standard Leontief (IA)^(1) matrix. I have used the clue in the thread and created 16 Bi,j variables for the sample period. This works, but is indeed inconvenient when the number of industries gets above toy numbers (e.g. 100). A time dimension to vectors and matrices would seem to be the desired enhancement, as Jan suggested. Further, one would want to set up equations which create adjustments to the IO coefficient matrices as well, as part of the model solution. Again, timedimensioned vectors and matrices would seem to be desirable to make for a more elegant and useful coding system. Multiple dimensioned, with time as a standard dimension, would be useful, e.g. consumers expenditure might be usefully dimensioned by time, industry and consumption category.
program TOY
smpl 1990 2012
equation eq_fd_agr.ls log(FD_AGR) c log(GRO_AGR(1)) log(GDP)
equation eq_fd_min.ls log(FD_MIN) c log(GRO_MIN(1)) log(GDP(1))
equation eq_fd_man.ls log(FD_MAN) c log(GRO_MAN(1)) log(GDP)
equation eq_fd_ser.ls log(FD_SER) c log(GRO_SER(1)) log(GDP)
model TOY
smpl 1990 2012
TOY.merge eq_fd_agr
TOY.merge eq_fd_min
TOY.merge eq_fd_man
TOY.merge eq_fd_ser
TOY.append @identity GRO_AGR = B11 * FD_AGR + B12 * FD_MIN + B13 * FD_MAN + B14 * FD_SER
TOY.append @identity GRO_MIN = B21 * FD_AGR + B22 * FD_MIN + B23 * FD_MAN + B24 * FD_SER
TOY.append @identity GRO_MAN = B31 * FD_AGR + B32 * FD_MIN + B33 * FD_MAN + B34 * FD_SER
TOY.append @identity GRO_SER = B41 * FD_AGR + B42 * FD_MIN + B43 * FD_MAN + B44 * FD_SER
TOY.solve
Thanks (PS how does one put the code into a little window?)
Peter
Who is online
Users browsing this forum: No registered users and 3 guests