weekday vs weekend average

For questions regarding programming in the EViews programming language.

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

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

weekday vs weekend average

Postby BT454 » Wed Jan 20, 2021 8:07 am

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

EViews Matt
EViews Developer
Posts: 563
Joined: Thu Apr 25, 2013 7:48 pm

Re: weekday vs weekend average

Postby EViews Matt » Wed Jan 20, 2021 10:51 am

Hello,

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")

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: weekday vs weekend average

Postby BT454 » Wed Jan 20, 2021 11:34 am

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.

EViews Matt
EViews Developer
Posts: 563
Joined: Thu Apr 25, 2013 7:48 pm

Re: weekday vs weekend average

Postby EViews Matt » Wed Jan 20, 2021 11:55 am

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")

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: weekday vs weekend average

Postby BT454 » Wed Jan 20, 2021 12:13 pm

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!

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: weekday vs weekend average

Postby BT454 » Wed Jan 20, 2021 12:33 pm

I simply used the recode function with an equality for if dummy < 1,0,1
hank you again for all the help!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 18 guests