add coefs of lags up

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

add coefs of lags up

Postby YK_Econ » Thu Nov 05, 2015 9:20 am

Hi,

I have 12 regressions with 3 different dependent variables, where the independent variables change. So it is a 3x4 system. For example, I want to obtain for regression i1 the following: scalar1= 1st coef. then scalar2 = scalar1 + 2 coef; scalar3 = scalar2 + 3rd coef and so on.

this is how far i got. i think it is just a minor mistake in there. Would be nice if anybody could help me.

Code: Select all

matrix (70,70) lags_spec for %dpv c i y 'for dep var eq for !eqnr= 1 to 4 'for equation number for !h= 1 to 8 'for the lag scalar effect_{%dpv}{!eqnr}{!h} = 0 effect_{%dpv}{!eqnr}{!h} = effect_{%dpv}{!eqnr}{(!h-1)} + {%dpv}{!eqnr}.@coef(!h) 'i think i doesn't want to have the -1 in effect_{%dpv}{!eqnr}{!h-1} lags_spec({((!eqnr)+(!h))},1) = effect_c{!eqnr}{!h} 'this is the matrix where i would like to put the results into next next next
the thing with the matrix must also work differently. I would like to get all my results into a matrix.

Thanks
Best
YK

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

Re: add coefs of lags up

Postby EViews Gareth » Thu Nov 05, 2015 9:24 am

Hard to spot anything wrong.

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

Re: add coefs of lags up

Postby YK_Econ » Thu Nov 05, 2015 9:30 am

eviews says:

EFFECT_c11 is not defined or is an illegal command in
"EFFECT_{%DPV}{!EQNR}{!H} = EFFECT_{%DPV}{!EQNR}{(!H
-1)} + {%DPV}{!EQNR}.@COEF(!H)".

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

Re: add coefs of lags up

Postby EViews Gareth » Thu Nov 05, 2015 9:37 am

Does it exist?

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

Re: add coefs of lags up

Postby YK_Econ » Thu Nov 05, 2015 9:42 am

if you mean effect_c11then yes, and it must exist because of

Code: Select all

for %dpv c i y 'for dep var eq for !eqnr= 1 to 4 'for equation number for !h= 1 to 8 'for the lag scalar effect_{%dpv}{!eqnr}{!h} = 0 next next next

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

Re: add coefs of lags up

Postby EViews Gareth » Thu Nov 05, 2015 9:49 am

But you're using h-1 not h

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

Re: add coefs of lags up

Postby YK_Econ » Thu Nov 05, 2015 10:05 am

oh yes! this is true! is there any way how i can come around this problem, considering what i want to obtain in the end? as far as i think, the only problem is the first result (where it doesnt have to add up anything).

it is the following: scalar1 = coef1, scalar2= scalar1 + coef2 and so on.

i think this is quite tricky

thanks

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

Re: add coefs of lags up

Postby EViews Gareth » Thu Nov 05, 2015 10:10 am

Perhaps start at 2 inside the loop and calculate the first one outside the loop.

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

Re: add coefs of lags up

Postby YK_Econ » Thu Nov 05, 2015 11:00 am

hmmmm tried this, but got same error (EFFECT_c12 is not defined or is an illegal command in
"EFFECT_{%DPV}{!EQNR}{!H} = EFFECT_{%DPV}{!EQNR}{(!H
-1)} + {%DPV}{!EQNR}.@COEF(!H)".)

Code: Select all

matrix (70,70) lags_spec scalar effect_c11 = c1.@coef(1) for %dpv c i y 'for dep var eq for !eqnr= 1 to 4 'for equation number for !h= 2 to 8 'for the lag scalar effect_{%dpv}{!eqnr}{!h} = 0 effect_{%dpv}{!eqnr}{!h} = effect_{%dpv}{!eqnr}{(!h-1)} + {%dpv}{!eqnr}.@coef(!h) lags_spec({((!eqnr)+(!h))},1) = effect_c{!eqnr}{!h} next next next

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

Re: add coefs of lags up

Postby EViews Gareth » Thu Nov 05, 2015 11:46 am

You've gone too far out the loop. I think you probably want something like:

Code: Select all

matrix (70,70) lags_spec for %dpv c i y 'for dep var eq for !eqnr= 1 to 4 'for equation number scalar effect_{%dpv}{!eqnr}1 = {%dpv}{!eqnr}.@coef(1) for !h= 2 to 8 'for the lag scalar effect_{%dpv}{!eqnr}{!h} = 0 effect_{%dpv}{!eqnr}{!h} = effect_{%dpv}{!eqnr}{(!h-1)} + {%dpv}{!eqnr}.@coef(!h) lags_spec({((!eqnr)+(!h))},1) = effect_c{!eqnr}{!h} next next next

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

Re: add coefs of lags up

Postby YK_Econ » Mon Nov 09, 2015 4:16 am

it still doesnt work. it is again: "EFFECT_c12 is not defined or is an illegal command in
"EFFECT_{%DPV}{!EQNR}{!H} = EFFECT_{%DPV}{!EQNR}{(!H
-1)} + {%DPV}{!EQNR}.@COEF(!H)"

hmm.. i really need to make this guy work. any other suggestions?

thanks
best
YK

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

Re: add coefs of lags up

Postby YK_Econ » Mon Nov 09, 2015 10:40 am

this one worked finally!

Code: Select all

'calculate the sum of the WS-coefs continuisly for %dpv c i y 'for dep var eq for !eqnr= 1 to 4 'for equation number for !h=1 to 8 scalar effect_{%dpv}{!eqnr}{!h} = {%dpv}{!eqnr}.@coef(!h) next next next for %dpv c i y 'for dep var eq for !eqnr= 1 to 4 'for equation number for !h=2 to 8 !hm1 = !h-1 scalar effect_{%dpv}{!eqnr}{!h} = effect_{%dpv}{!eqnr}{!hm1} + {%dpv}{!eqnr}.@coef(!h) next next next
cheers for that!



best
YK


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests