Hi all!
I'm working with several years of daily data, and I need to generate a dummy variables that is 1 if the average of weekend values is greater than the average of weekday values, and 0 for the opposite.
I figure I could start by creating a series that is the average of just the weekday values, and another that is the average of just the weekend values, then create a series using @recode that is 1 or 0 depending on the above inequality.
Is there a slick way to create these average series? Or, better yet, a better way to do this than my line of thinking?
Thanks!
Bob
weekday vs weekend average
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: weekday vs weekend average
Hello,
You have the right idea, which can be simplified to something of the form:
You have the right idea, which can be simplified to something of the form:
Code: Select all
series dummy = @mean(x, "if @weekday > 5") > @mean(x, "if @weekday <= 5")
Re: weekday vs weekend average
Thank you! This is a good start.
One wrinkle I forge to include is that this must evaluate the means on a week to week basis, or each week has it's own unique mean for the days just in that week. Any thoughts on how I'd add that into the mix?
I was thinking I could loop the week numbers through the smpl command in the loop.
One wrinkle I forge to include is that this must evaluate the means on a week to week basis, or each week has it's own unique mean for the days just in that week. Any thoughts on how I'd add that into the mix?
I was thinking I could loop the week numbers through the smpl command in the loop.
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: weekday vs weekend average
With the simplifying assumptions that a week begins on Monday and year boundaries should be ignored, I believe the following will work:
Code: Select all
series dummy = @meansby(x, @date-@weekday, "if @weekday > 5") > @meansby(x, @date-@weekday, "if @weekday <= 5")
Re: weekday vs weekend average
Thank you again.
And one last step.
I now need to convert this daily variables, into a weekly variable, that is 0 if the weekday average was less than the weekend average, and 1, if the weekend average was greater than the weekday avarege.
Thank you again!
And one last step.
I now need to convert this daily variables, into a weekly variable, that is 0 if the weekday average was less than the weekend average, and 1, if the weekend average was greater than the weekday avarege.
Thank you again!
Re: weekday vs weekend average
I simply used the recode function with an equality for if dummy < 1,0,1
hank you again for all the help!
hank you again for all the help!
Who is online
Users browsing this forum: No registered users and 18 guests