rename dummy and diagonal dummy
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
Re: rename dummy and diagonal dummy
It worked now with alpha series, but if the identification a series crossid =(1 1 1 1..., 2 2 2 2..., 3 3 3....) i get error message
" String added to scalar in "%SERIES_NAME = "D_"+CROSSID(1) + "_"+@DATESTR(@DATEVAL(@OTOD((1 - 1) * 3 + 1)), "YYYY_MM_DD_")+ @STR(1, "I03")"."
" String added to scalar in "%SERIES_NAME = "D_"+CROSSID(1) + "_"+@DATESTR(@DATEVAL(@OTOD((1 - 1) * 3 + 1)), "YYYY_MM_DD_")+ @STR(1, "I03")"."
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: rename dummy and diagonal dummy
I believe @crossid cannot be used in a scalar expression like that, but you could save @crossid to a series and then access an element of that series instead.
Re: rename dummy and diagonal dummy
i have make this series identif=@crossid i get the same error message how can solve this.
%series_name = "d_"+ identif(!i) + "_"+...
*) i have series named crossid in my workfile (1 1 1 1...,2222...)
%series_name = "d_"+ identif(!i) + "_"+...
*) i have series named crossid in my workfile (1 1 1 1...,2222...)
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: rename dummy and diagonal dummy
Silly me, I forgot to mention the string conversion. I also thought you meant @crossid, but if you already have a series crossid:
Code: Select all
%series_name = "d_" + @str(crossid(!i)) + "_" + ...
Re: rename dummy and diagonal dummy
Perfectly all named series works, you are not silly ok!.
could i generate this series dummy, i mean to generate just 4 dummy series ok, but it generate 8 series dummy contained zero value
could i generate this series dummy, i mean to generate just 4 dummy series ok, but it generate 8 series dummy contained zero value
Code: Select all
wfcreate 30min(Mon-Fri,8:00-9:00) 03/01/2000 06/01/2000 3
!size = 3 ' Every four observations go into one dummy.
for !i = 1 to @obsrange
!id = @floor((!i - 1) / !size) + 1
%series_name = "d_" + @str(!id, "i03")
if not @isobject(%series_name) then
series {%series_name} = @floor(@trend / !size) + 1 = !id
endif
next
- Attachments
-
- interday_spanning.png (26.88 KiB) Viewed 9788 times
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: rename dummy and diagonal dummy
Sure, since you have three cross sections just change the upper limit of the for loop from @obsrange to @obsrange / 3.
Re: rename dummy and diagonal dummy
How can referenced your code in my study. Should i write just EViews Matt Developer.
Thank you for your help. Thanks for all your efforts to make this possible.
See you soon.
Thank you for your help. Thanks for all your efforts to make this possible.
See you soon.
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: rename dummy and diagonal dummy
I believe you can just refer to the EViews development team.
Re: rename dummy and diagonal dummy
Hi everybody,
Can i fix this case with another way (without @isna and @nan), i have the same case with my data series.
series tx = @recode(@day<>@day(-1) or @isna(@day(-1)), 1, tx(-1) + 1)
series break=@recode(@during("2000m01 2001m05") or @during("2003m10 2004m12") or @during("2006m01 2007m04") or @during("2008m01 2015m02"), @nan(break(-1), 0) + 1, 0)
Can i fix this case with another way (without @isna and @nan), i have the same case with my data series.
series tx = @recode(@day<>@day(-1) or @isna(@day(-1)), 1, tx(-1) + 1)
series break=@recode(@during("2000m01 2001m05") or @during("2003m10 2004m12") or @during("2006m01 2007m04") or @during("2008m01 2015m02"), @nan(break(-1), 0) + 1, 0)
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: rename dummy and diagonal dummy
Hello,
Is there some reason you don't want to use @isna or @nan? Those functions let one concisely create the series.
Is there some reason you don't want to use @isna or @nan? Those functions let one concisely create the series.
Re: rename dummy and diagonal dummy
just to see how can fix the two cases by another ways, to understand the logic without functions.
Re: rename dummy and diagonal dummy
could you respond me please.
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: rename dummy and diagonal dummy
I see. Well, the basic logic behind both those series generating expressions is this: given some condition, either make the next value in the series one more than the preceding value, or set it to a specific value. Using the tx series as an example, you could write an equivalent program that explicitly assigns each value:
The first value in the series is fixed at 1, and for the rest of the observations the code checks for the transition to a new day. When a new day is found, the series' value for that observation is set to 1. Otherwise, the series' value is one more than the preceding value.
The above program isn't very big, but you can generate the same data in fewer lines by taking advantage of other EViews capabilities. Sort of half-way between the above program and the one-line solution would be:
The for loop and everything inside it have been replaced by @recode. However, the logic of tx(-1) + 1 only makes sense from the second observation onwards. tx(-1) is NA for the first observation, thus tx(-1) + 1 will be NA, which isn't what we want. The smpl line is there to make sure that the @recode logic skips the first observation. Since the first observation is skipped, we have to explicitly set it ourselves, which is done before the sample line.
Because the series is defined in terms of its own lag, we had to set the first observation differently than the other observations. A more concise way to do this is to use @isna or @nan to detect that special case directly within the @recode expression.
Code: Select all
series tx
tx(1) = 1
for !i = 2 to @obsrange
if @datepart(@dateval(@otod(!i)), "dd") <> @datepart(@dateval(@otod(!i - 1)), "dd") then
tx(!i) = 1
else
tx(!i) = tx(!i - 1) + 1
endif
next
The first value in the series is fixed at 1, and for the rest of the observations the code checks for the transition to a new day. When a new day is found, the series' value for that observation is set to 1. Otherwise, the series' value is one more than the preceding value.
The above program isn't very big, but you can generate the same data in fewer lines by taking advantage of other EViews capabilities. Sort of half-way between the above program and the one-line solution would be:
Code: Select all
series tx
tx(1) = 1
smpl @first+1 @last
tx = @recode(@day <> @day(-1), 1, tx(-1) + 1)
The for loop and everything inside it have been replaced by @recode. However, the logic of tx(-1) + 1 only makes sense from the second observation onwards. tx(-1) is NA for the first observation, thus tx(-1) + 1 will be NA, which isn't what we want. The smpl line is there to make sure that the @recode logic skips the first observation. Since the first observation is skipped, we have to explicitly set it ourselves, which is done before the sample line.
Because the series is defined in terms of its own lag, we had to set the first observation differently than the other observations. A more concise way to do this is to use @isna or @nan to detect that special case directly within the @recode expression.
Code: Select all
series tx = @recode(@day <> @day(-1) or @isna(@day(-1)), 1, tx(-1) + 1)
Re: rename dummy and diagonal dummy
I understand well now, Thanks for your quick response.
Who is online
Users browsing this forum: No registered users and 32 guests