Forming a series

For questions regarding programming in the EViews programming language.

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

mjfl
Posts: 49
Joined: Mon Jul 18, 2011 8:18 am

Forming a series

Postby mjfl » Sat Nov 12, 2011 3:26 am

Dear Glenn, Gareth and all,

Code: Select all

series y = z_piet1a series x = mu for !horizon= 95 to 126 smpl 1978q1 1978q1+!horizon var var{!horizon}.ls 1 3 y x smpl 1978q1+!horizon+2 1978q1+!horizon+5 var{!horizon}.fcast _f{!horizon} next smpl @all
allows me to create dynamic forecast of 4 periods for each horizon.
e.g y_f95 gives dynamic forecast for 2002q2 to 2003q1 while the rest are unchanged.
y_f96 gives 2002q3 to 2003q2 etc.

i hope to sum the values in y_f95 from 2002q2 to 2003q1 and divide by 4 before storing the value in another new series called zebra in 2002q1.
this means a sum divide and append to new series.

can u teach me how to do so using this code or another code seperately? i cant seem to find any links on extraction of value and appending it back.
thk u so much.
Last edited by mjfl on Sun Nov 13, 2011 6:18 pm, edited 1 time in total.

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

Re: Forming a series

Postby EViews Gareth » Sun Nov 13, 2011 4:33 pm

Not quite sure I follow, but either the @movav function will do what you want, or you can just set the sample to be those periods you want to sum over, then use @sum.

mjfl
Posts: 49
Joined: Mon Jul 18, 2011 8:18 am

Re: Forming a series

Postby mjfl » Sun Nov 13, 2011 6:14 pm

hi gareth,

thank you so much, i got what i wanted! wow. @movav is useful.
can i ask another 2 questions on groups?

1.i have a program which i'm running with series x always changing and i need to run it over all the series in the workfile except the obvious resid and c.
is it possible to automate the process?

2. another seperate question

Code: Select all

series y = z_piet1a series x = f_sti for !horizon= 95 to 126 smpl 1978q1 1978q1+!horizon var var{!horizon}.ls 1 4 y x
is it possible to let series x take on f_sti,d(f_sti),d(f_sti,2),log(f_sti) and dlog(f_sti) automatically in a program so that i do not have to retype and each time to generate new vars or eqns in a simialr setting?

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

Re: Forming a series

Postby EViews Gareth » Sun Nov 13, 2011 7:20 pm

Use @wlookup to find the names of all the series in the workfile, then loop over them:

Code: Select all

%names = @wlookup("*", "series") for %var {%names} ... next
Yes, just loop over the specifications:

Code: Select all

%specs = "f_sti d(f_sti) d(f_sti,2) log(f_sti) dlog(f_sti)" for %var {%specs} series x = {%var} next

mjfl
Posts: 49
Joined: Mon Jul 18, 2011 8:18 am

Re: Forming a series

Postby mjfl » Mon Nov 14, 2011 6:40 pm

hi gareth, i tried it in my setting, the 1st one worked! thank u!
the second one didnt.
how can i capture the equations in the different specification in different equations?(i will try VAR after learning this)
i mean i like an equation1 for f_sti, eqaution2 for d(f_sti) etc etc?
do you have a basic example?

can i ask 2 more questions?

1.

Code: Select all

for !horizon= 95 to 129 smpl 1978q1 1978q1+!horizon equation eq{!horizon} for !i=0 to !maxlags for !j=0 to !maxlags eq{!horizon}.ls(cov=hac) y c x( to -!i) z( to -!j) if eq{!horizon}.@sc < !sc then !best2lag =!j !bestlag = !i !sc = eq{!horizon}.@sc endif next next
this loop allows me to choose models base on lowest sic. i know there is QLR test with certain trim and the recent baiperron test which helps to detect structural breaks.
can i in any way put in any of these test (or u could reccomend) in the loop so that it chooses first, no structural break second, lowest sic? i wish to obtain a good fit model that shows no structural break.

2. seperate issue: for a VAR

Code: Select all

var var{!horizon}.ls 1 4 y x
is it possible to let the 4 become an 'n' and allow 'n' to run from 1 to 20 instead?

many thks for the response. really helps.

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

Re: Forming a series

Postby EViews Gareth » Tue Nov 15, 2011 8:49 am

Code: Select all

create u 100 series f_sti=rnd series x = nrnd for %var "f_sti d(f_sti)" equation eq1.ls {%var} c x next
With regards to the QLR / baiperron test stuff, yes it is probably possible with a lot of coding.

Code: Select all

create u 100 series y=nrnd series x=nrnd for !i=1 to 20 var var!i.ls 1 !i y x next

mjfl
Posts: 49
Joined: Mon Jul 18, 2011 8:18 am

Re: Forming a series

Postby mjfl » Tue Nov 15, 2011 5:23 pm

hi Gareth,

1. gd knowing var lags can be looped. :)
2. the one with f_sti and d(f_sti) still does not work as i was hoping to get eq1: ls. y x c eq2: ls. d(y) x c etc. and then allow y to change in variable thats why i asked about

Code: Select all

%deplist = @wlookup("a*", "series")
with the idea of fusing it myelf. how could the above be done?
3. for the QLR/BaiParron, which do u recommend me trying to code and can i call the pvalue of these tests just like the normal cases?

thk u so much. things are moving now. :)

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

Re: Forming a series

Postby EViews Gareth » Tue Nov 15, 2011 7:09 pm

Code: Select all

create u 100 series f_sti=rnd series x = nrnd !i=1 for %var "f_sti d(f_sti)" equation eq!i.ls {%var} c x !i=!i+1 next

mjfl
Posts: 49
Joined: Mon Jul 18, 2011 8:18 am

Re: Forming a series

Postby mjfl » Tue Nov 15, 2011 10:34 pm

Code: Select all

create u 100 series f_sti=rnd series x = nrnd !i=1 for %var "f_sti d(f_sti)" equation eq!i.ls {%var} c x !i=!i+1 next
hi gareth, i think i gave u a wrong idea.

1. how can one do a multiple regression such that letting x change, eq1 is ls. y x c eq2 is ls. y d(x) eq 3 is ls. y dlog(x) etc

2. on a seperate note, if a workfile has 6 series a b f g h j, how do i create a program to create a workfile with a b f g h j d(a) d(b) d(f) d(g) d(h) d(j)? or must one genr one by one esp if there are 50 series?

thank u for the reply.

mjfl
Posts: 49
Joined: Mon Jul 18, 2011 8:18 am

Re: Forming a series

Postby mjfl » Tue Nov 15, 2011 10:36 pm

Code: Select all

create u 100 series f_sti=rnd series x = nrnd !i=1 for %var "f_sti d(f_sti)" equation eq!i.ls {%var} c x !i=!i+1 next
hi gareth, i think i gave u a wrong idea.

1. how can one do a multiple regression such that letting x change, eq1 is ls. y x c eq2 is ls. y d(x) eq 3 is ls. y dlog(x) etc

2. on a seperate note, if a workfile has 6 series a b f g h j, how do i create a program to create a workfile (old or new is fine) with a b f g h j d(a) d(b) d(f) d(g) d(h) d(j)? or must one genr one by one esp if there are 50 series?

thank u for the reply.

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

Forming a series

Postby EViews Gareth » Tue Nov 15, 2011 11:41 pm

Loops are loops. Just follow the same format and change the bits you need.

mjfl
Posts: 49
Joined: Mon Jul 18, 2011 8:18 am

Re: Forming a series

Postby mjfl » Thu Nov 17, 2011 6:51 am

Dear Gareth,

i have attached anew workfile.
can i ask how could i code something so that it compares
k_baa1 with k_daa1 with k_faa1 with k_haa1 with k_jaa1 (all scalars) and find the smallest one given that i would like 1,2,3...42 instead.

i tried @wlookup with this code to call and then verbally inspect to choose the smallest scalar but it doesnt work:

Code: Select all

%deplist = @wlookup(" *1 ", "series") for %dep {%deplist} show scalar{%dep} next
Attachments
sgmasterexph1.WF1
(379.48 KiB) Downloaded 732 times

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

Re: Forming a series

Postby EViews Gareth » Thu Nov 17, 2011 8:48 am

The second argument in the @wlookup function indicates what type of object to look for. You have it set to "series", when you're looking for scalars.

mjfl
Posts: 49
Joined: Mon Jul 18, 2011 8:18 am

Re: Forming a series

Postby mjfl » Thu Nov 17, 2011 5:08 pm

The second argument in the @wlookup function indicates what type of object to look for. You have it set to "series", when you're looking for scalars.
hi gareth, my apology it doesnt work even if one sets it to scalar (it was a poor cut and paste).
can i by any chance call them so that i can only ask for the smallest scalar?

and may i also ask using wald test, can i "call" for the pvalue in the f-stat?
thk u!

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

Re: Forming a series

Postby EViews Gareth » Thu Nov 17, 2011 5:10 pm

Code: Select all

=@wlookup("*1", "scalar")
works for me.

http://forums.eviews.com/viewtopic.php?f=5&t=18


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests