Page 1 of 1

Dynamic equation

Posted: Tue Aug 03, 2010 9:02 am
by Chris_Ger
Hello everybody,

I am using E-view 7.0. My problem:

I have to define several equations, where variables for these equations depend on input from a "INPUT_MATRIX" and a "REFERENCE_MATRIX". The "INPUT_MATRIX" comprises of 1 and 0, indicating which variables from the "REFERENCE_MATRIX" shall be applied.

For example:
Matrix(1,4) INPUT_MATRIX.fill 1,1,0,1
Matrix(1,4) REFERENCE_MATRIX.fill C,AR(1),AR(2),X

combining INPUT_MATRIX and REFERENCE_MATRIX results into the independent variables of a equation which are:
1*C=C
1*AR(1)=AR(1)
0*AR(2)=-
1*X=X

I tried to define equations based on:
dependent_variable=C(1)*1+C(2)*1*AR(1)+C(3)*0*AR(2)+C(4)*1*X
in order to derive the equation
dependent_variable=C(1)+C(2)*AR(1)+C(4)*X
but it does not work.

Does anybody has an idea how to solve that problem in Eviews?

Thank you very much for your support.

Best regards,
Chris

Re: Dynamic equation

Posted: Tue Aug 03, 2010 9:11 am
by EViews Gareth
Matrices cannot contain string data. Further, you cannot perform multiplication on strings (thus 1*AR(1)) will not work.

You could store the strings in a table object, rather than a matrix. Or, perhaps better, in a simple string variable.

You can choose whether to include a specific string with an if statement, rather than your multiplication.

Thus, it would look something like this:

Code: Select all

table regressors regressors(1,1) = "C" regressors(2,1) = "AR(1)" regressors(3,1) = "AR(2)" regressors(4,1) = "X" vector(4) input_matrix input_matrix.fill 1,1,0,1 %myregs = "" for !i=1 to @rows(input_matrix) if input_matrix(!i) = 1 then %myregs = %myregs + @regressors(!i,1) endif next equation e1.ls dependent_variable {%myregs}

or

Code: Select all

%regressors = "C AR(1) AR(2) X" vector(4) input_matrix input_matrix.fill 1,1,0,1 %myregs = "" for !i=1 to @rows(input_matrix) if input_matrix(!i) = 1 then %myregs = %myregs + @word(%regressors,!i) endif next equation e1.ls dependent_variable {%myregs}

Re: Dynamic equation

Posted: Tue Aug 03, 2010 9:50 am
by Chris_Ger
Great, it works. Thank you very much