Page 1 of 1

Fall Dummy variable for SAD hypothesis

Posted: Fri Aug 11, 2017 4:58 am
by hmurphy94
hi

i have daily data to test the see composite index. i want to create a dummy variable that equals 1 between 21st of september and 20th december, and one that equals 1 between 21st december and 20th march for all years. however, i seem to be only able to create it for one year of the sample using

series dummy4 = @recode(@date>@dateval("1991/09/21") and @date<@dateval("1991/12/20"), 1, 0)

i tried dropping the 1991 in the hope it would work for all years but it either comes up 0 for every figure or else n/a. the data sample is 1991/1/07 to 2016/1/08. thanks!

Re: Fall Dummy variable for SAD hypothesis

Posted: Fri Aug 11, 2017 8:57 am
by EViews Matt
Hello,

There are several ways to do what you want, here are two. I've removed the unnecessary @recode.

Code: Select all

series dummy4 = @date > @dateval(@str(@datepart(@date, "YY")) + "/09/21") and @date < @dateval(@str(@datepart(@date, "YY")) + "/12/20")

or

Code: Select all

series dummy4 = (@month = 9 and @day > 21 or @month > 9) and (@month = 12 and @day < 20 or @month < 12)

Re: Fall Dummy variable for SAD hypothesis

Posted: Tue Aug 22, 2017 6:43 am
by hmurphy94
hi thank you for your response.

however, when trying to make the dummy variable between the 21st december and the 20th match, all values are 0? is this because the dummy is spanning over different calendar years? the same thing happened when i tried to the a dummy from the 21st sept to 20th march. do you know how i can correct this?

also, when i tried to use the first way you posted:
series dummy4 = @date > @dateval(@str(@datepart(@date, "YY")) + "/09/21") and @date < @dateval(@str(@datepart(@date, "YY")) + "/12/20")
it came up: Numeric operator applied to string data

many thanks
hugh

Re: Fall Dummy variable for SAD hypothesis

Posted: Tue Aug 22, 2017 10:45 am
by EViews Matt
You'll note that the second expression I used doesn't involve the year. Such expressions are evaluated for each date in the current sample, and no date is both after Dec. 21 and before Mar. 20 (of the same year), hence your dummy series would be filled with zeros. You need to alter your expression to be independent of the year. Thinking in terms of Dec. 21 through Mar. 20 crosses a year boundary, as you noticed, but it's equivalent to think in terms of before Mar. 20 or after Dec. 21, e.g.,

Code: Select all

series dummy5 = (@month = 3 and @day < 20 or @month < 3) or (@month = 12 and @day > 21)

For the other expression that was erroring, what version of EViews are you using? I only tested that expression with EViews 9 and 10.