create series
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
martingale
- Posts: 51
- Joined: Tue Jul 24, 2012 11:36 am
create series
Hi
I use EViews 7.
I have tried without success to write a little program which creates series for standardized unexpected earnings (SUE). I have quarterly data for earnings per share(EPS) for 25 companies put together to a group called OBXEPS12AAR.
I try to use the following equation:
SUE=(EPS-EPS(-4))/(MOVSTDEV(EPS,4))
I need to make a program somewhat like:
For %i
series SUE=(EPS-EPS(-4))/(MOVSTDEV(EPS,4))
next
I haven't programmed before and I can't work the details out.
I 'd appreciate very much if anybody could come up with an example or suggestion or reference?
I use EViews 7.
I have tried without success to write a little program which creates series for standardized unexpected earnings (SUE). I have quarterly data for earnings per share(EPS) for 25 companies put together to a group called OBXEPS12AAR.
I try to use the following equation:
SUE=(EPS-EPS(-4))/(MOVSTDEV(EPS,4))
I need to make a program somewhat like:
For %i
series SUE=(EPS-EPS(-4))/(MOVSTDEV(EPS,4))
next
I haven't programmed before and I can't work the details out.
I 'd appreciate very much if anybody could come up with an example or suggestion or reference?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: create series
I'm not entirely sure what you are asking - or rather what you're trying to achieve.
The equation you wrote looks like it will correctly calculate SUE. What is going wrong?
Your for loop doesn't appear to have any reference to !i inside it. What are you looping over?
The equation you wrote looks like it will correctly calculate SUE. What is going wrong?
Your for loop doesn't appear to have any reference to !i inside it. What are you looping over?
-
martingale
- Posts: 51
- Joined: Tue Jul 24, 2012 11:36 am
Re: create series
Hi and thanx for the answer.
I have made a group which has data(earnings per share) for 25 companies(the data is in 25 columns, one column for each company). I want to use a program rutine to calculate SUE for the 25 companies but I don't know how to write such a program. What I would like to achieve is to automate the process in stead of doing the same calculation 25 times.
I have made a group which has data(earnings per share) for 25 companies(the data is in 25 columns, one column for each company). I want to use a program rutine to calculate SUE for the 25 companies but I don't know how to write such a program. What I would like to achieve is to automate the process in stead of doing the same calculation 25 times.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: create series
Code: Select all
For %i =1 to OBXEPS12AAR.@count
%name = obxeps12aar.@seriesname(!i)
%newname = "SUE_" + %name
series {%newname}=({%name}-{%name}(-4))/(MOVSTDEV({%name},4))
next
-
martingale
- Posts: 51
- Joined: Tue Jul 24, 2012 11:36 am
Re: create series
hi and thanx a lot, when I run the program I get the message "!i is not defined" (I uploaded the file in case)
- Attachments
-
- 25 firm in the oslobørs to EViews forum.WF1
- (25.08 KiB) Downloaded 513 times
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: create series
The first line should read
not "%i".
Code: Select all
For !i =1 to OBXEPS12AAR.@count
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
create series
My bad.
-
martingale
- Posts: 51
- Joined: Tue Jul 24, 2012 11:36 am
Re: create series
Code: Select all
For !i =1 to OBXEPS12AAR.@count
%name = obxeps12aar.@seriesname(!i)
%newname = "SUE_" + %name
series {%newname}=({%name}-{%name}(-4))/(@MOVSTDEV({%name},4))
nextIs there also a way to substitute observations with value 0 to "NA"? this is because the program halts when it come across 0's.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: create series
It shouldn't stop, it should just produce a message saying that NAs have been generated and continue ("Division by zero. Missing data generated"). The final series should already contain what you want.
-
martingale
- Posts: 51
- Joined: Tue Jul 24, 2012 11:36 am
Re: create series
The program halts at the first series "sue_n_fro_eps_" where the error message is generated. A solution is to increase maximum errors before halting but it might ignore sources of other types of errors. A better solution is to program a subistitution of 0's with "NA". How could this be done?
- Attachments
-
- Series generation halts EViews.jpg (90.57 KiB) Viewed 14280 times
-
- Division by zero EViews.jpg (21.9 KiB) Viewed 14280 times
-
martingale
- Posts: 51
- Joined: Tue Jul 24, 2012 11:36 am
Re: create series
Code: Select all
for !i =1 to OBXEPS12AAR.@count
%name = obxeps12aar.@seriesname(!i)
series {%name}=@recode({%name}=0, NA, -{%name})
next-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: create series
By stop, I meant within the one series generation. You are correct that after that series is generated, the program will stop.
I note that your proposed solution modifies the original series which generally makes me nervous.
Moreover, I don't think this modification is really what you want to do. You are replacing all values where the series equals zero with NAs, otherwise you are including the negative of the original series. Apart from the negative part, which I think is just a mistake, that substitution will solve the problem, but will also modify your @MOVSTDEV results everywhere there is a data 0 in the span, even if the original @MOVSTEDEV result is nonzero. What I think you want to do is to replace the 0's in the resulting moving standard deviation series:
Note that I don't mind overwriting the STDEVTMP since it's a temporary series.
I note that your proposed solution modifies the original series which generally makes me nervous.
Moreover, I don't think this modification is really what you want to do. You are replacing all values where the series equals zero with NAs, otherwise you are including the negative of the original series. Apart from the negative part, which I think is just a mistake, that substitution will solve the problem, but will also modify your @MOVSTDEV results everywhere there is a data 0 in the span, even if the original @MOVSTEDEV result is nonzero. What I think you want to do is to replace the 0's in the resulting moving standard deviation series:
Code: Select all
For !i =1 to OBXEPS12AAR.@count
%name = obxeps12aar.@seriesname(!i)
series stdevtmp = @MOVSTDEV({%name},4)
stdevtmp = @recode(stdevtmp=0, NA, stdevtemp)
%newname = "SUE_" + %name
series {%newname}=({%name}-{%name}(-4))/stdevtemp
delete stdevtemp
next
-
martingale
- Posts: 51
- Joined: Tue Jul 24, 2012 11:36 am
Re: create series
Hi Glenn
Thanx very much for the ansewr. You are right, the negative part was a plain spelling error.
Thanx very much for the ansewr. You are right, the negative part was a plain spelling error.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: create series
Glad it's working.
As I said, I don't like modifying original data unless I'm sure that's what I want. I almost always generate into a new series. The possibility of error is all the more reason not to overwrite the original series unless you are *absolutely* sure that's what you want to do. Once the data are modified, it may be impossible to "unmodify".
As I said, I don't like modifying original data unless I'm sure that's what I want. I almost always generate into a new series. The possibility of error is all the more reason not to overwrite the original series unless you are *absolutely* sure that's what you want to do. Once the data are modified, it may be impossible to "unmodify".
-
martingale
- Posts: 51
- Joined: Tue Jul 24, 2012 11:36 am
Re: create series
Code: Select all
For !i =1 to OBXEPS12AAR.@count
%name = obxeps12aar.@seriesname(!i)
series stdevtemp = @MOVSTDEV({%name},4)
stdevtemp = @recode(stdevtemp=0, NA, stdevtemp)
%newname = "SUE_" + %name
series {%newname}=({%name}-{%name}(-4))/stdevtemp
delete stdevtemp
nextIt works now fine like you said.
Who is online
Users browsing this forum: No registered users and 2 guests
