Programming a table matrix

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

YK_Econ
Posts: 36
Joined: Wed Jan 28, 2015 8:34 am

Programming a table matrix

Postby YK_Econ » Tue Nov 03, 2015 3:51 am

Hi everybody,

I do panel estimations. I have 4x8 (=NxK) different estimations. 4 different dependent variables times 8 different regressions.

I want to create a matrix table(table1), where I present the main findings.

table1(1,K) = coefficient of LOG(WS(-1)) / (coefficient LOG(consumption) * (-1))

so the long-run relationship in an ECM model between WS and consumption. What I want to program now, is that this result is in the first row in 8 different columns.

second row is investment (same procedure)

third row (which i might have troubles with as well) is the sum of the first two rows.

that is what i got so far:

Code: Select all

matrix(8,5) table1 for !i = 1 to 8 for !h = 1 to 3 table1(!h,!i) = {i}.@coef(!h) next next
and it doesnt work (and i am not surprised by that)

best
YK

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

Re: Programming a table matrix

Postby EViews Gareth » Tue Nov 03, 2015 9:10 am

You need to reference the names of the equations when using .@coef. What are your equation names?

YK_Econ
Posts: 36
Joined: Wed Jan 28, 2015 8:34 am

Re: Programming a table matrix

Postby YK_Econ » Tue Nov 03, 2015 10:53 am

i came so far by now:

Code: Select all

matrix(4,5) check for !n = 1 to 2 for !h = 2 to 10 check(1,!n) = c{!n}.@coef(!h) next next
and now it puts the 10th coef into the matrix (however i want the sum of coefs 2 to 10)

my equation names are c1, c2 ... , c8, i1, ... , i8, ci1,...,ci8, y1,...,y8

btw. this is just my simplified try program, i still want to get what i wanted to get initially.

many thanks
YK

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

Re: Programming a table matrix

Postby EViews Gareth » Tue Nov 03, 2015 11:10 am

Code: Select all

check(1,!n) = @sum(c{!n}.@coefs) - c{!n}.@coef(!)

YK_Econ
Posts: 36
Joined: Wed Jan 28, 2015 8:34 am

Re: Programming a table matrix

Postby YK_Econ » Tue Nov 03, 2015 11:23 am

check(1,!n) = @sum(c{!n}.@coefs) - c{!n}.@coef(!h)

'whole loop:
matrix(4,5) check
for !n = 1 to 2
for !h = 2 to 10
check(1,!n) = @sum(c{!n}.@coefs) - c{!n}.@coef(!h)
next
next
tried this, but gives me wrong values. I can't figure out which value it calculated. I want to obtain the sum of the 2nd to the 10th coef.

thanks
best
YK

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

Re: Programming a table matrix

Postby EViews Gareth » Tue Nov 03, 2015 11:31 am

I took the sum of all the coefficients, then minused the first coefficient. I was assuming you had only 10.

YK_Econ
Posts: 36
Joined: Wed Jan 28, 2015 8:34 am

Re: Programming a table matrix

Postby YK_Econ » Tue Nov 03, 2015 11:39 am

sorry. i should be more explicit.

i have 30 coefs. i want the sum of the 2nd to the 10th.

at the end of the day, i want the sum of coef 2 to 10 divided by 1-(sum of coefs 11 to 18)

and coef 3 divided by coef 5 * (-1) * scalar inv_gdp * scalar one_ws (for example: (coefx3/(coefx4*(-1)))*scalar inv_gdp * scalar one_ws )

thanks
best

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

Re: Programming a table matrix

Postby EViews Gareth » Tue Nov 03, 2015 11:41 am

Just do the addition manually. coef(2)+coef(3)...

YK_Econ
Posts: 36
Joined: Wed Jan 28, 2015 8:34 am

Re: Programming a table matrix

Postby YK_Econ » Tue Nov 03, 2015 11:57 am

isnt there a way to make a loop?

because in the end it is a 5x8 matrix. 40 times typing this is a pain.

thx

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

Re: Programming a table matrix

Postby EViews Gareth » Tue Nov 03, 2015 12:28 pm

Yes, you could loop through them.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests