Handling missing values/NAs

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

tode
Posts: 7
Joined: Mon Jun 29, 2009 8:07 am

Handling missing values/NAs

Postby tode » Mon Jun 29, 2009 8:32 am

Hello everybody,

I have a question regarding the way EViews treates missing values. Currently, I am writing a small program to estimate the market betas of 38 firms. I use a loop with 38 diagonal BEKK models, each with the return of one firm and "the" market to find the conditional covariances of the firm with the market etc.

The problem is, that the data is not available over the entire estimation period for every firm, and the loop causes a failure notice which says that there is "no valid obeservation in the sysXY.arch @diagbekk c arch(1) garch(1)...". I think that the problem is due to the treatement of missing values although I thought that EViews simply excludes them if not necessary. To solve the problem, I tried the estimation for two firms separately, of which one has data over the entire period and the other not. For the first firm, there is no problem and the estimation works, but for the other firm the above mentioned problem arises again. So my suspicion seems to be validated. However, I was not able to figure out, how to exclude the NAs and only work with available data.

Now my question: Does anybody know how to solve the problem? A first step would perhaps be if anyone knew how to program that only those firms which have returns over the entire period are considered since when I tried to do it, EViews always stopped after the first firm without complete data.

Many thanks in advance,

Tobi

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

Re: Handling missing values/NAs

Postby EViews Gareth » Mon Jun 29, 2009 8:40 am

Without seeing your workfile/program, I'm not sure I can help with the specific error you're getting, but in general, you could always just set your error count to a high number and then run your program, so it will ignore any errors thrown up by missing values.

http://forums.eviews.com/viewtopic.php?f=5&t=827&p=2777

tode
Posts: 7
Joined: Mon Jun 29, 2009 8:07 am

Re: Handling missing values/NAs

Postby tode » Tue Jun 30, 2009 1:40 am

Hello,

I've worked on the program, and that's what it looks like at the moment:

Code: Select all

'test 'change path to program path %path = @runpath cd %path 'load workfile load data_300609 'set sample from 01/07/2004 to 01/05/2005 smpl 01/07/2004 01/05/2005 'start FOR loop for 38 assets to estimate the market betas for !i = 1 to 38 if @cumnas(r{!i}) < 1 then 'make series of excess returns series djstoxx_y=djstoxx_r - euribor_weekly series y{!i}=r{!i} - euribor_weekly 'create system of djstoxx_r and asset !i system sys{!i} sys{!i}.append djstoxx_y = c(1) sys{!i}.append y{!i} = c(2) 'estimate diagonal BEKK(1,1) for system sys{!i}.arch @diagbekk c arch(1) garch(1) 'create variance, covariance time series of market and asset !i sys{!i}.makegarch '(name=arch{!i}) 'calculate beta time series series beta{!i} = garch_01_02/garch_01'arch{!i}_01_02 / arch{!i}_01 endif 'end For loop next 'show estimated betas of all 38 assets group betas beta1 beta2 beta3 beta4 beta5 beta6 beta7 beta8 beta9 beta10 beta11 beta12 beta13 beta14 beta15 beta16 beta17 beta18 beta19 beta20 beta21 beta22 beta23 beta24 beta25 beta26 beta27 beta28 beta29 beta30 beta31 beta32 beta33 beta34 beta35 beta36 beta37 beta38 show betas.line
Actually, I wanted to use "name=arch{!i} in makegarch and thereafter, but it didn't work. Thanks for the tipp with increasing the number of errors, the program works for some of the assets, but not all - those with NAs in the time series do not work. So I wanted to include an if condition so that only those assets are considered in the loop which have full period data, but unfortunately it didn't work. The programm know looks pretty much like one example program, named beta.prg.

Could anyone please tell me how to program the if condition correctly? Furthermore, I do not understand, why the naming of my variance-covariance series does not work. And if anyone knew why EViews does not simply estimates without using the NAs, it would be perfect...

Any help is highly appreciated,

thanks,

Tobi

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

Re: Handling missing values/NAs

Postby EViews Gareth » Tue Jun 30, 2009 8:47 am

You might like to use the @obs function rather than the @cumnas function.


I'm not sure why the makegarch doesn't work for you, I see nothing wrong with the way you're doing it. What error message does it give?

tode
Posts: 7
Joined: Mon Jun 29, 2009 8:07 am

Re: Handling missing values/NAs

Postby tode » Tue Jun 30, 2009 10:41 am

The error is:

"This view/proc requires at least one valid endogenous variable in "DO-SYSXY.MAKEGARCH (NAME=ARCHXY_)"

But anyway, the original question was why does the arch not simply ignore estimations in which missing values arise? Is there a reasonable explanation?

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

Re: Handling missing values/NAs

Postby EViews Gareth » Tue Jun 30, 2009 10:51 am

The dynamics of ARCH require that there is a continuous sample of data available.

tode
Posts: 7
Joined: Mon Jun 29, 2009 8:07 am

Re: Handling missing values/NAs

Postby tode » Tue Jun 30, 2009 11:40 am

Thank you very much.

arthurs seat
Posts: 4
Joined: Sat Sep 26, 2009 11:22 pm

Re: Handling missing values/NAs

Postby arthurs seat » Sat Sep 26, 2009 11:51 pm

can i ask what you ended up doing? I have the same problem and have NA in the pairwise samples, is an if statement shunning them the only way

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Handling missing values/NAs

Postby trubador » Mon Sep 28, 2009 5:41 am

If you cannot handle the missing values properly, then you should better delete them casewise and use the resulting continuous sample in estimating GARCH models.

arthurs seat
Posts: 4
Joined: Sat Sep 26, 2009 11:22 pm

Re: Handling missing values/NAs

Postby arthurs seat » Mon Sep 28, 2009 6:19 am

thank you trubador this is exactly what i have done

vasudhak
Posts: 4
Joined: Sat May 24, 2014 3:27 am

Re: Handling missing values/NAs

Postby vasudhak » Sat May 24, 2014 3:33 am

Hello,

I am using Eviews 7, I am an amateur. I have stock return series of 45 companies in 5-day per week format over 150 days. I want to establish there GARCH model, but Eviews prompt me saying that we cannot run MA models on discontinuous series.

I have some NA values in my stock return series, some are missing data and other are government holidays. Can you please suggest how to deal with these NA values and establish GARCH model hence.

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

Re: Handling missing values/NAs

Postby EViews Gareth » Sat May 24, 2014 12:35 pm

You'll need to remove those observations from the workfile. Something like:

Code: Select all

pagecontract if returns<>na

vasudhak
Posts: 4
Joined: Sat May 24, 2014 3:27 am

Re: Handling missing values/NAs

Postby vasudhak » Sat May 24, 2014 8:48 pm

That is the question, how to remove. I don't see any page contract option. Is there any other way of handling missing data ?

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

Re: Handling missing values/NAs

Postby EViews Gareth » Sat May 24, 2014 9:03 pm

That is the answer

vasudhak
Posts: 4
Joined: Sat May 24, 2014 3:27 am

Re: Handling missing values/NAs

Postby vasudhak » Sun May 25, 2014 12:15 am

I am sorry I am not able to understand, the page contract option does not give any such facility. Can you please elaborately explain me. I am an amateur, I lack knowledge in this field, it will be very helpful if you can guide me through this.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest