Removing NA values from a series in the workfile
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Removing NA values from a series in the workfile
What exactly are you trying to do?
Follow us on Twitter @IHSEViews
Re: Removing NA values from a series in the workfile
I need to calculate the moving average for 50 series(6 such files) and then generate buy sell signals. I am trying to do this using programming. I cannot use directly the paneled series I have taken into eviews. To arrange them properly, I have unstacked different workfiles and then do some work in excel to get data arranged. this data I need to transfer into eviews for which moving average needs to be calculated. While unstacking, "NA" is inserted in between. and while calculating Moving average, eviews will skip the cell above and below NA. So, I need to filter this out either in programming or before programming so that series fed into programming is proper. Kindly suggest.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Removing NA values from a series in the workfile
Why not just use the @mav function that calculates the moving average without propagating NAs?
Follow us on Twitter @IHSEViews
Re: Removing NA values from a series in the workfile
The problem with using @mav is that, it returns the cell value before and after NA as it is without averaging which I do not want.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- Joined: Tue Sep 16, 2008 5:38 pm
Removing NA values from a series in the workfile
I think you're going to have to just loop through our series one at a time then.
Follow us on Twitter @IHSEViews
-
- EViews Developer
- Posts: 2672
- Joined: Wed Oct 15, 2008 9:17 am
Re: Removing NA values from a series in the workfile
There are alternatives to @mav which have different behavior around missings. A comment and a couple of questions. First, note that @mav computes the *backward* moving average. If you want the centered moving average you'll have to use the @mavc. Now the questions: how do you want to compute the moving average and how do you want to handle missings?
Re: Removing NA values from a series in the workfile
Gareth, I dint get you. Currently in the program(which am still working on), I am looping to generate moving averages for different series and am using @movav
Glenn, I am using @movav and I want to calculate the moving average in this way @movav(x,3) = (X+X(–1)+X(–2))/ 3. Currently I want a solution to handle the missings which my program is not doing. I am directly feeding the series which does not have NA's. My data which is dated irregular panels also does not have NA's.But I have to use unstacking in eviews to arrange the data properly before I go for moving averages and this unstacking is creating NA's which I have to overcome. Hope you are clear with my problem now. If there is solution in eveiws to remove NAs for all series at a time it will be good.
Thanks
Glenn, I am using @movav and I want to calculate the moving average in this way @movav(x,3) = (X+X(–1)+X(–2))/ 3. Currently I want a solution to handle the missings which my program is not doing. I am directly feeding the series which does not have NA's. My data which is dated irregular panels also does not have NA's.But I have to use unstacking in eviews to arrange the data properly before I go for moving averages and this unstacking is creating NA's which I have to overcome. Hope you are clear with my problem now. If there is solution in eveiws to remove NAs for all series at a time it will be good.
Thanks
Re: Removing NA values from a series in the workfile
Can anyone help me to code this. I have many series rather than one. What is the code for doing so?
Many thanks.
Many thanks.
EViews Gareth wrote:Proc->Contract Current Page
then set the sample to "if X<>NA" where X is the series with the NAs.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Removing NA values from a series in the workfile
What exactly are you trying to do?
Follow us on Twitter @IHSEViews
Re: Removing NA values from a series in the workfile
EViews Gareth wrote:What exactly are you trying to do?
Hi Gareth
I have an excel file which includes a big matrix of:
firs column: independent variable 1's series (smb)
second column: independent variable 2' series (hml)
third column: independent variable 3's series (mom)
fourth column: firm 1's return series
fifth column: firm 2's return series
sixth column: firm 3's return series
.
.
.
till
.
the 366th column: firm j's return series
each row is a time point from 2000/01/01 to 2010/12/31. In this case, first 3 columns are full of data but firm's return series contain missing data.
When I load this matrix to Eviews, my firm's return series contain nan data.
I need to run a GARCH model for each firm's return on smb, hml and mom. But nan data stops the program continues. I cannot exclude nan manually as there are two problems:
(1) too many firms , it is time-consuming
(2) even I do it, for example for firm 1's return series, all series are reset to meet the period of firm 1's time period, which is not true. The return series varies by firm.
Thanks for your help.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Removing NA values from a series in the workfile
ok, but what are you trying to do when removing NAs? Do you want to remove any row for which any firm has an NA, or remove any row for which all firms have an NA?
Follow us on Twitter @IHSEViews
Re: Removing NA values from a series in the workfile
EViews Gareth wrote:ok, but what are you trying to do when removing NAs? Do you want to remove any row for which any firm has an NA, or remove any row for which all firms have an NA?
Hi Gareth,
To answer your question, it is neither.
I try to remove any row of na for that particular firm. Firm B's rows are not affected by firm A's rows of na.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Removing NA values from a series in the workfile
You cannot do that. If you remove a row, it is removed from all series.
Follow us on Twitter @IHSEViews
Re: Removing NA values from a series in the workfile
EViews Gareth wrote:You cannot do that. If you remove a row, it is removed from all series.
Many thanks your reply Gareth. Do you think there is a code to import the excel and then asks for particular column?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Removing NA values from a series in the workfile
Yes, both the wfopen and import commands have a range statement to select the range of cells to import.
Follow us on Twitter @IHSEViews
Who is online
Users browsing this forum: No registered users and 17 guests