Removing NA values from a series in the workfile

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13294
Joined: Tue Sep 16, 2008 5:38 pm

Re: Removing NA values from a series in the workfile

Postby EViews Gareth » Thu Mar 15, 2012 10:08 am

What exactly are you trying to do?
Follow us on Twitter @IHSEViews

deepaib
Posts: 7
Joined: Tue Mar 13, 2012 9:38 pm

Re: Removing NA values from a series in the workfile

Postby deepaib » Thu Mar 15, 2012 6:59 pm

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13294
Joined: Tue Sep 16, 2008 5:38 pm

Re: Removing NA values from a series in the workfile

Postby EViews Gareth » Thu Mar 15, 2012 10:22 pm

Why not just use the @mav function that calculates the moving average without propagating NAs?
Follow us on Twitter @IHSEViews

deepaib
Posts: 7
Joined: Tue Mar 13, 2012 9:38 pm

Re: Removing NA values from a series in the workfile

Postby deepaib » Fri Mar 16, 2012 4:41 am

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13294
Joined: Tue Sep 16, 2008 5:38 pm

Removing NA values from a series in the workfile

Postby EViews Gareth » Fri Mar 16, 2012 7:20 am

I think you're going to have to just loop through our series one at a time then.
Follow us on Twitter @IHSEViews

EViews Glenn
EViews Developer
Posts: 2671
Joined: Wed Oct 15, 2008 9:17 am

Re: Removing NA values from a series in the workfile

Postby EViews Glenn » Fri Mar 16, 2012 10:32 am

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?

deepaib
Posts: 7
Joined: Tue Mar 13, 2012 9:38 pm

Re: Removing NA values from a series in the workfile

Postby deepaib » Sat Mar 17, 2012 3:23 am

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

misscats
Posts: 29
Joined: Wed Mar 19, 2014 8:37 am

Re: Removing NA values from a series in the workfile

Postby misscats » Tue Apr 01, 2014 8:20 am

Can anyone help me to code this. I have many series rather than one. What is the code for doing so?

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13294
Joined: Tue Sep 16, 2008 5:38 pm

Re: Removing NA values from a series in the workfile

Postby EViews Gareth » Tue Apr 01, 2014 8:29 am

What exactly are you trying to do?
Follow us on Twitter @IHSEViews

misscats
Posts: 29
Joined: Wed Mar 19, 2014 8:37 am

Re: Removing NA values from a series in the workfile

Postby misscats » Tue Apr 01, 2014 8:55 am

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13294
Joined: Tue Sep 16, 2008 5:38 pm

Re: Removing NA values from a series in the workfile

Postby EViews Gareth » Tue Apr 01, 2014 8:59 am

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

misscats
Posts: 29
Joined: Wed Mar 19, 2014 8:37 am

Re: Removing NA values from a series in the workfile

Postby misscats » Tue Apr 01, 2014 10:17 am

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13294
Joined: Tue Sep 16, 2008 5:38 pm

Re: Removing NA values from a series in the workfile

Postby EViews Gareth » Tue Apr 01, 2014 10:58 am

You cannot do that. If you remove a row, it is removed from all series.
Follow us on Twitter @IHSEViews

misscats
Posts: 29
Joined: Wed Mar 19, 2014 8:37 am

Re: Removing NA values from a series in the workfile

Postby misscats » Tue Apr 01, 2014 11:28 am

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?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13294
Joined: Tue Sep 16, 2008 5:38 pm

Re: Removing NA values from a series in the workfile

Postby EViews Gareth » Tue Apr 01, 2014 11:31 am

Yes, both the wfopen and import commands have a range statement to select the range of cells to import.
Follow us on Twitter @IHSEViews


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 23 guests