Page 1 of 1
coefs factors by loop
Posted: Sat Feb 27, 2016 7:53 am
by ch2324
Hi everybody
this code extract coefs factors in the vectors but i get a constant value in the vectors 0.605271, I have a fault somewhere
Code: Select all
vector(12) v
equation eq
eq.ls y y(-1) y(-2) @expand(@month)
for !i= 1 to 12
for !j=3 to 14
v(!i)=eq.@coef(!j)
next
next
any help!
Re: coefs factors by loop
Posted: Sat Feb 27, 2016 9:33 am
by EViews Gareth
I
think you want:
Code: Select all
vector(12) v
equation eq
eq.ls y y(-1) y(-2) @expand(@month)
for !i= 1 to 12
!j = !i+2
v(!i)=eq.@coef(!j)
next
Re: coefs factors by loop
Posted: Sat Feb 27, 2016 12:27 pm
by ch2324
it work, thanks!.
i use this code but a get a constant value in the matrix:
Code: Select all
matrix(4,3) m
equation eq
eq.ls y y(-1) y(-2) @expand(@month)
for !i=1 to 4
for !j=1 to 3
!k=m(!i,!j)
m(!i,!j)=eq.@coef(!k)
next
next
i would just put the factors coefs by column in the matrix.
(*) there is a tini mistake in EV9 command Ref chap 11 p 259. v1 should be v.
Re: coefs factors by loop
Posted: Sun Feb 28, 2016 4:33 am
by ch2324
by this code i get one value of factors in m(1,1) but all others values are constant
Code: Select all
matrix(4,3) m
equation eq
eq.ls y y(-1) y(-2) @expand(@month)
for !i=1 to 4
for !j=1 to 3
for !k= 3 to 12
if !i>=1 and !j=1 and !k=!i+2 then
m(!i,!j)=eq.@coef(!k)
if !i>=1 and !j=2 and !k=!i+6 then
m(!i,!j)=eq.@coef(!k)
if !i>=1 and !j=3 and !k=!i+10 then
m(!i,!j)=eq.@coef(!k)
next
next
next
endif
endif
endif
I would highly appreciate if any of you could help me!
Re: coefs factors by loop
Posted: Mon Feb 29, 2016 9:20 am
by EViews Gareth
It is really difficult to figure out what you're trying to do.
Re: coefs factors by loop
Posted: Mon Feb 29, 2016 9:55 am
by ch2324
1)i would just place the four coefs of factors "c(3), c(4), c(5), c(6)" in the first column, and "c(7), c(8), c(9), c(10)" in the second column, ...etc
2) can i combined three vector(3) in the matrix(3,3) by function?
Re: coefs factors by loop
Posted: Mon Feb 29, 2016 10:15 am
by ch2324
1-sorry, is another question

ok!, how can combined vector to the matrix by function?
2-vector v1 = @vec(m1), extract column to the vector, but how can extract by row to the vector, i have used @rows but it not work.
3- it's solved but can i use if to simplify by "if"
Code: Select all
matrix(4,3) m
equation eq
eq.ls y y(-1) y(-2) @expand(@month)
for !i=1 to 4
!j=1
!k=!i+2
m(!i,!j)=eq.@coef(!k)
for !i=1 to 4
!j=2
!k=!i+6
m(!i,!j)=eq.@coef(!k)
for !i=1 to 4
!j=3
!k=!i+10
m(!i,!j)=eq.@coef(!k)
next
next
next
Re: coefs factors by loop
Posted: Mon Feb 29, 2016 10:41 am
by EViews Gareth
Re: coefs factors by loop
Posted: Mon Feb 29, 2016 11:26 am
by ch2324
thanks!
can you help me to simplify the code by "if", it's just to understand the methodologie of the loop by if.

Re: coefs factors by loop
Posted: Mon Feb 29, 2016 11:49 am
by EViews Gareth
That code is nearly impossible to follow. What are you trying to do?
Re: coefs factors by loop
Posted: Mon Feb 29, 2016 12:02 pm
by EViews Gareth
If you're trying to create a 4,3 matrix that contains the monthly coefficients:
Code: Select all
vector monthlycoefs = @subextract(eq.@coefs, 3) 'extract the coefficients from the 3rd onwards into a vector
matrix m = @unvec(monthlycoefs, 4) 'convert that vector into a matrix.
Re: coefs factors by loop
Posted: Mon Feb 29, 2016 1:18 pm
by ch2324
exactlly what that i need, i learned many things from you Mr Gareth many thanks!
(**) EViews 9 Command Ref, chap 11, pp 264-265
matrix xsub = x.@row(@fill(1, 3, 4))
extracts the first, third, and fourth rows of the matrix X into the matrix XSIB. XSIB should be xsub.
Re: coefs factors by loop
Posted: Sat Mar 05, 2016 11:40 am
by ch2324
(***)EViews 9 Command Ref, chap 11, p 264
vector a = x.@row(3)
extracts the third column of X into the vector a, "column should be row". :)