Page 2 of 3

Re: Removing NA values from a series in the workfile

Posted: Thu Mar 15, 2012 10:08 am
by EViews Gareth
What exactly are you trying to do?

Re: Removing NA values from a series in the workfile

Posted: Thu Mar 15, 2012 6:59 pm
by deepaib
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.

Re: Removing NA values from a series in the workfile

Posted: Thu Mar 15, 2012 10:22 pm
by EViews Gareth
Why not just use the @mav function that calculates the moving average without propagating NAs?

Re: Removing NA values from a series in the workfile

Posted: Fri Mar 16, 2012 4:41 am
by deepaib
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.

Removing NA values from a series in the workfile

Posted: Fri Mar 16, 2012 7:20 am
by EViews Gareth
I think you're going to have to just loop through our series one at a time then.

Re: Removing NA values from a series in the workfile

Posted: Fri Mar 16, 2012 10:32 am
by EViews Glenn
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

Posted: Sat Mar 17, 2012 3:23 am
by deepaib
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

Re: Removing NA values from a series in the workfile

Posted: Tue Apr 01, 2014 8:20 am
by misscats
Can anyone help me to code this. I have many series rather than one. What is the code for doing so?

Many thanks.
Proc->Contract Current Page

then set the sample to "if X<>NA" where X is the series with the NAs.

Re: Removing NA values from a series in the workfile

Posted: Tue Apr 01, 2014 8:29 am
by EViews Gareth
What exactly are you trying to do?

Re: Removing NA values from a series in the workfile

Posted: Tue Apr 01, 2014 8:55 am
by misscats
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.

Re: Removing NA values from a series in the workfile

Posted: Tue Apr 01, 2014 8:59 am
by EViews Gareth
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?

Re: Removing NA values from a series in the workfile

Posted: Tue Apr 01, 2014 10:17 am
by misscats
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.

Re: Removing NA values from a series in the workfile

Posted: Tue Apr 01, 2014 10:58 am
by EViews Gareth
You cannot do that. If you remove a row, it is removed from all series.

Re: Removing NA values from a series in the workfile

Posted: Tue Apr 01, 2014 11:28 am
by misscats
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?

Re: Removing NA values from a series in the workfile

Posted: Tue Apr 01, 2014 11:31 am
by EViews Gareth
Yes, both the wfopen and import commands have a range statement to select the range of cells to import.