Graph by Actual Dates

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

px41
Posts: 24
Joined: Wed Mar 02, 2011 7:44 pm

Graph by Actual Dates

Postby px41 » Mon Apr 18, 2011 11:22 am

Good Day everyone,

I have stacked data and I'm trying to do a graphical analysis of stock behavior surrounding a particular holiday. I would like to see what trend might exist within a time interval spanning one month before and one month after the holiday. I know how to call up different sample sizes for weekday,month, and year using the "smpl if @" function but I don't know how to target specific dates and date ranges with this function. Also, it's an annual holiday and the holiday dates change each year, so I would like to see what happens for each of these years (2006 to 2010).

For example,in 2006 the dates for the holiday (it's a two day holiday) are Feb 27 and 28, thus my time interval of interest would be 27th Jan 2006 to 28th March 2006. I tried entering "smpl if @date>=27/01/2006 and @date<=28/03/2006" but it says "WARNING: Sample contains no observations". I'm pretty sure there is data for this interval in my workfile so I must be overlooking something.

Thus, I'm wondering how can I generate a graph based on a particular interval of actual dates?

Kindly asking for and looking forward to your help. Thanking you in advance.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Graph by Actual Dates

Postby EViews Glenn » Mon Apr 18, 2011 1:26 pm

You need to convert your dates into date values:

Code: Select all

smpl if @date>=@dateval("27/01/2006", "dd/mm/yyyy") and @date<=@dateval("28/03/2006", "dd/mm/yyy")

px41
Posts: 24
Joined: Wed Mar 02, 2011 7:44 pm

Re: Graph by Actual Dates

Postby px41 » Mon Apr 18, 2011 3:16 pm

Hi Glenn, thanks for your response. I tried the code you gave and I got the same message about there not being enough observations. I changed around the month and day order and took out the "dd/mm/yyyy" and it said something about "insufficient arguments". I came across "series dval = @dateval(dates)" in the eviews manual concerning dates but upon entering it it says ""dates" is not defined". I apologize for my confusion but I'm not very EViews literate, what do you mean convert it to date values? Thanks for your patience and help Glenn.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Graph by Actual Dates

Postby EViews Glenn » Mon Apr 18, 2011 4:14 pm

Pardon me for asking what may be an obvious question, but what is the range of your workfile?

px41
Posts: 24
Joined: Wed Mar 02, 2011 7:44 pm

Re: Graph by Actual Dates

Postby px41 » Mon Apr 18, 2011 6:16 pm

Feel free to ask away, it just might be that I'm overlooking something obvious! The range of the workfile is "5/02/2005 to 10/29/2010" (x 28 crossids). That's mm/dd/yyyy which is the default order EViews seemed to organize my data when I was first setting up my workfile. Hope it helps.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Graph by Actual Dates

Postby EViews Glenn » Tue Apr 19, 2011 9:03 am

Oh, by the way there was a typo in my earlier command so if you just copied and pasted, it won't work :oops: , you need to have one more "y" in the last format

Code: Select all

smpl if @date>=@dateval("27/01/2006", "dd/mm/yyyy") and @date<=@dateval("28/03/2006", "dd/mm/yyyy")
I just tested on a workfile with your structure and you should be good to go.

Incidentally, if you want to change the date orientation to "dd/mm/yyyy" for your workfiles, you should go to General Options/Date representation, and change the setting there. Note that this doesn't change the internal representation of the date, only the way it is displayed. You can always specify a date value using whatever representation you want by providing an explicit format string as in the example above.

px41
Posts: 24
Joined: Wed Mar 02, 2011 7:44 pm

Re: Graph by Actual Dates

Postby px41 » Tue Apr 19, 2011 12:17 pm

Hi Glenn,

Ahh I see. It's fine, to err is human! Tried the code again and it works like a charm! Thanks so much. I really appreciate it.

One other question though. OK, sometimes the hardest part of solving a problem is asking the right question. So I'll try my best here. My aim is to consider the interval say 27/01 (dd/mm) to 28/03 (dd/mm) across 2006 to 2010 for one cross id. Maybe a picture might help, I did this one in paint to convey the idea. How can I do this?

Thanks in advance!
Attachments
Desired Graphical Analysis.jpg
Can EViews7 do this?
Desired Graphical Analysis.jpg (42.91 KiB) Viewed 10662 times

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Graph by Actual Dates

Postby EViews Glenn » Tue Apr 19, 2011 1:55 pm

That's not an easy one. I'll have to think about it.

px41
Posts: 24
Joined: Wed Mar 02, 2011 7:44 pm

Re: Graph by Actual Dates

Postby px41 » Tue Apr 19, 2011 2:56 pm

Oh ok. No problem take your time. I did some searching around and the closest I came to that was the Seasonal Graph. It gives means for months across the years. y-axis= price, x-axis= months of the year. If only I could replace the x-axis with a precise date interval....

It's ok for now, but I would like ultimately like the graph to depict the data at a finer resolution level than just months in general. If we can find a way to integrate the actual date intervals in to graph, as in the picture I uploaded that would be perfect.

Thanks for all your help thus far!

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: Graph by Actual Dates

Postby startz » Tue Apr 19, 2011 3:43 pm

Try faking it by making a different daily series for each year, and then copying and pasting all into one daily dated page. Be sure to not match by year.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Graph by Actual Dates

Postby EViews Glenn » Wed Apr 20, 2011 9:43 am

That's certainly the right idea, the hard question is how to do that and get the date labeling on the x-axis. I'm still thinking :)

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Graph by Actual Dates

Postby EViews Glenn » Wed Apr 20, 2011 10:05 am

Here's an idea...not quite your picture, but very close...

1. Create a new workfile page containing just the cross-section of interest by clicking on Copy/Extract from current page/By Link to new page..., and entering a sample restriction like "@all if crossid=1" or whatever condition you require for your cross-section identifier. You can use the pageextract command to do the same thing if you wish. If you are only going to want to plot a given subrange of the year, I would enter the restriction here in place of "@all".

2. In the new page, create a new variable for the year "series year = @year" and a new variable with the day and month of the observation "alpha day = @datestr(@date, "MM/DD")" Note the use of capital letters in creating the month/day string. I'll need this since we want to keep stuff in the right sort order (as you'll see).

3. Click on Proc/Reshape Current Page/Unstack in New Page.... Enter year in the unstacking identifiers field, and day in the observation identifiers box. You can use the pageunstack command to do the same thing.

4. Go to the last page and open the group representing the set of variables of interest. There should be one series for each year as Startz suggested. Click on View/Graph and click on OK to display the default multiple line graph. That should be close to what you want. The key here is that we have structured the page using the string representing the "month/day" in "MM/DD" format. You may have to freeze the graph and edit the legend...

Let me know if this works. I'll let you post a picture of the final output since my test series don't look as nice as your picture.

px41
Posts: 24
Joined: Wed Mar 02, 2011 7:44 pm

Re: Graph by Actual Dates

Postby px41 » Tue Apr 26, 2011 9:06 am

Sorry for my late response. Oh I see what Startz is saying but I'm not sure exactly how to do that. I'll spend some time figuring it out. Hmm, ok I'll follow your instructions Glenn and I'll let you know if I was successful. Thanks for the response! Now let me give it a try....


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests