Dummy variable UP/Down
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
Dummy variable UP/Down
Hi, I have multiple time series of stock returns, I want to create dummy variables that are 1 when the return increase and 0 when the return decrease. The problem am facing when the returns is the same for several months. For instance, the returns for the following 7 months are 3,4,2,5,5,5,5, I want the dummy variable to be 1 for the last 4 months and not only for the fourth month. Please I would appreciate any help.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13330
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Dummy variable UP/Down
When you create your dummy variable, instead of using ">", use ">=" instead.
Follow us on Twitter @IHSEViews
Re: Dummy variable UP/Down
Thanks for reply. I used this command: series dummy=@recode(y>=y(-1),1,0), but I still have the same problem.Please can you advice?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13330
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Dummy variable UP/Down
It works.
Code: Select all
wfcreate u 7
series y
y.fill 3,4,2,5,5,5,5
series dummy = @recode(y>=y(-1),1,0)
show dummy
Follow us on Twitter @IHSEViews
Re: Dummy variable UP/Down
Sorry, It is my bad that I did not well explain what I want to do. I attached an Excel file in which I typed the Dummy that I want. Please can you help which code can do that? Much appreciated,
- Attachments
-
- Dummy.xlsx
- Dummy
- (15.71 KiB) Downloaded 169 times
Re: Dummy variable UP/Down
I would appreciate it if I get a reply to my question.
-
- Non-normality and collinearity are NOT problems!
- Posts: 3775
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Dummy variable UP/Down
Gareth's suggestion does what you ask. In your file you have the dummy stay zero if the return stays constant after it first falls. Is that what you want?
Re: Dummy variable UP/Down
Yes, I want the dummy to stay constant (0 or 1) if the return stays constant. Please can you help?
-
- EViews Developer
- Posts: 565
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Dummy variable UP/Down
Hello,
Building on Gareth's example, a self-referential expression lets you maintain the previous dummy value in the case that the return is constant.
Building on Gareth's example, a self-referential expression lets you maintain the previous dummy value in the case that the return is constant.
Code: Select all
series dummy = @recode(y>y(-1),1,@recode(y<y(-1),0,@nan(dummy(-1),1)))
Re: Dummy variable UP/Down
Amazing, this is exactly what I want. Thanks.
Who is online
Users browsing this forum: Majestic-12 [Bot] and 9 guests