Line and 5year Max/Min range on the same seasonal graph

For questions regarding programming in the EViews programming language.

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

eviewsuserforum
Posts: 19
Joined: Wed Apr 22, 2015 5:11 am

Line and 5year Max/Min range on the same seasonal graph

Postby eviewsuserforum » Wed Sep 02, 2015 3:53 am

Hi everyone

I want a to draw a seasonal chart (monthly data, x-axis on from Jan to Dec), showing a line for the data of the current year and the 5-year max-min range .

See the pic: http://imgur.com/Tyhf8m9

I first start by slicing my sample, restricting it to 2015

Code: Select all

@smpl 2015 2015
I then draw the line for 2015, creating line chart named myChart from my series named myData :

Code: Select all

graph myChart myData
Now, how can I compute the min and max value for each month (Jan to Dec) from 2010 to 2014? Then how do I add this range (my understanding is that is is a band graph in Eviews) to my chart?

Thank you

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

Re: Line and 5year Max/Min range on the same seasonal graph

Postby EViews Gareth » Wed Sep 02, 2015 10:00 am

Something like this:

Code: Select all

create m 2010 2015 series mydata = rnd*140 series monthmaxes = @maxsby(mydata, @month, "2010 2014") series monthmins = @minsby(mydata, @month, "2010 2014") group g monthmaxes monthmins mydata show g.mixed band(1,2) line(3)

eviewsuserforum
Posts: 19
Joined: Wed Apr 22, 2015 5:11 am

Re: Line and 5year Max/Min range on the same seasonal graph

Postby eviewsuserforum » Fri Sep 04, 2015 1:12 am

Thank you for your reply.

Unfortunately, Eviews doesn't seem to like line and band chart types on the same graph (I have had such problems while trying out myself before I leave a question in this forum).

Code: Select all

MIXED is not a valid view for G in "SHOW G.MIXED BAND(1,2) LINE(3)"
How can I force Eviews to plot a line and bands on the same graph, please?

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

Re: Line and 5year Max/Min range on the same seasonal graph

Postby EViews Gareth » Fri Sep 04, 2015 6:36 am

Which version?

eviewsuserforum
Posts: 19
Joined: Wed Apr 22, 2015 5:11 am

Re: Line and 5year Max/Min range on the same seasonal graph

Postby eviewsuserforum » Tue Sep 08, 2015 5:23 am

Hello. Sorry for the late reply.

I am using Eviews 8, Standard Edition - May 6 2013 build.

Thank you.

EViews Jason
EViews Developer
Posts: 870
Joined: Tue Sep 16, 2008 3:50 pm

Re: Line and 5year Max/Min range on the same seasonal graph

Postby EViews Jason » Wed Sep 09, 2015 9:29 am

The 'mixed' command is a new EViews 9 feature

If you are only going to have 1 band and 1 line, then in 8 you could use.

Code: Select all

create m 2010 2015 series mydata = rnd*140 series monthmaxes = @maxsby(mydata, @month, "2010 2014") series monthmins = @minsby(mydata, @month, "2010 2014") group g monthmaxes monthmins mydata show g.band
If you add anymore more series to your group 'mixed' will provide a lot more flexibility. In this simple case, 'band' should suffice.

eviewsuserforum
Posts: 19
Joined: Wed Apr 22, 2015 5:11 am

Re: Line and 5year Max/Min range on the same seasonal graph

Postby eviewsuserforum » Thu Sep 10, 2015 1:23 am

Thank you Jason.

Gloups, I actually want to plot the 5-year range, a line for the current year, and a line for the previous year and the line (forecast) for the ea to come.

Thanks.

EDIT: I finally did something along what follows:

Code: Select all

create m 2010 2015 series mydata = rnd*100 series mydata2 = rnd*100 series monthmaxes = @maxsby(mydata, @month, "2010 2014") series monthmins = @minsby(mydata, @month, "2010 2014") group g monthmaxes monthmins mydata mydata mydata2 mydata2 ' One can 'control' lines size like this ' group g monthmaxes monthmins mydata mydata*0.995 mydata2 mydata2*0.995 show g.band

EViews Jason
EViews Developer
Posts: 870
Joined: Tue Sep 16, 2008 3:50 pm

Re: Line and 5year Max/Min range on the same seasonal graph

Postby EViews Jason » Fri Sep 11, 2015 2:06 pm

Clever. So you basically added 3 bands where 2 of the bands are very small, such that they appear to be lines.

For future reference in EViews 9, you could use

Code: Select all

group g monthmaxes monthmins mydata mydata2 show g.mixed band(1,2) line(3,4)

eviewsuserforum
Posts: 19
Joined: Wed Apr 22, 2015 5:11 am

Re: Line and 5year Max/Min range on the same seasonal graph

Postby eviewsuserforum » Mon Sep 14, 2015 4:50 am

Say I want to use the code showed the other:

Code: Select all

create m 2010 2015 series mydata = rnd*100 series mydata2 = rnd*100 series monthmaxes = @maxsby(mydata, @month, "2010 2014") series monthmins = @minsby(mydata, @month, "2010 2014") group g monthmaxes monthmins mydata mydata mydata2 mydata2 ' One can 'control' lines size like this ' group g monthmaxes monthmins mydata mydata*0.995 mydata2 mydata2*0.995 show g.band
How can I control the name of the series, eg how do I set the name of the range ("monthmaxes monthmins") to the string "5-year range"?

And what is the equivalent for a group object of .setupdate(a) that I usually use for graph objects?

Thank you.

EViews Jason
EViews Developer
Posts: 870
Joined: Tue Sep 16, 2008 3:50 pm

Re: Line and 5year Max/Min range on the same seasonal graph

Postby EViews Jason » Mon Sep 14, 2015 8:53 am

Try:

Code: Select all

create m 2010 2015 series mydata = rnd*100 series mydata2 = rnd*100 series monthmaxes = @maxsby(mydata, @month, "2010 2014") series monthmins = @minsby(mydata, @month, "2010 2014") group g monthmaxes monthmins mydata mydata mydata2 mydata2 ' One can 'control' lines size like this ' group g monthmaxes monthmins mydata mydata*0.995 mydata2 mydata2*0.995 freeze(mygraph) g.band show mygraph mygraph.setelem(1) legend("5-year range") mygraph.setelem(2) legend("")

There isn't an equivalent for a group object of .setupdate(a), since group objects are always updated (i.e. they always are set to auto). But with my above example, you may want

Code: Select all

mygraph.setupdate(a)

eviewsuserforum
Posts: 19
Joined: Wed Apr 22, 2015 5:11 am

Re: Line and 5year Max/Min range on the same seasonal graph

Postby eviewsuserforum » Tue Sep 15, 2015 1:13 am

Hello Jason. Thank you!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests