Graph by Actual Dates
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
Graph by Actual Dates
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.
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
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") Re: Graph by Actual Dates
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
Pardon me for asking what may be an obvious question, but what is the range of your workfile?
Re: Graph by Actual Dates
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
Oh, by the way there was a typo in my earlier command so if you just copied and pasted, it won't work
, you need to have one more "y" in the last format
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.
Code: Select all
smpl if @date>=@dateval("27/01/2006", "dd/mm/yyyy") and @date<=@dateval("28/03/2006", "dd/mm/yyyy") 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.
Re: Graph by Actual Dates
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!
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
-
- 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
That's not an easy one. I'll have to think about it.
Re: Graph by Actual Dates
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!
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
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
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
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.
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.
Re: Graph by Actual Dates
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....
Who is online
Users browsing this forum: No registered users and 2 guests
