Page 1 of 1

re: bugs when loop thru a large group of stocks

Posted: Sat Nov 23, 2013 6:04 pm
by sauleung
Dear Sir,

I am using an Eviews 8 with a build of 19th November 2013. I am trying to run a CAPM market model for each stock of a group (the group contains 5000 stocks) over the 1994-2012.

While the workfile is structured as daily data, I am sampling them using quarters (smpl 1994q1 1994q1, etc) so that a regression is run on the daily observations for each stock in each quarter. I have an exclusion criteria that only stocks with more than 50 trading days available in each quarter is to be estimated.

However, each time I run this programme, Eviews just crashed. Then I tried with Eviews 7, the crash still occurred. Would you please look into this issue? Eviews has always been my favourite software as it is very efficient and convenient.

Here is the code I am using:

smpl @all
!rowcounter=2
table(10,500000) tab

tab(1, 1)="year"
tab(1,2)="quarter"
tab(1,3)="beta"
tab(1,4)="total risk"
tab(1,5)="ivol"
tab(1,6)="avail_obs"
tab(1,7)="name"

for !year=1994 to 2012

for !q=1 to 4

%date=@str(!year) + "q" + @str(!q)

smpl %date %date

for !h = 1 to ret.@count
%name= ret.@seriesname(!h)

scalar obss=@obs({%name})
if obss>=50 then

tab(!rowcounter, 1)=!year
tab(!rowcounter,2)=!q

equation eq1.ls(n) {%name}-rf c mkt_rf int
tab(!rowcounter, 3)=eq1.@coefs(2)
genr resid1=resid
resid=0
tab(!rowcounter, 5)=@stdev(resid1)*7.74597

genr new={%name}-rf
tab(!rowcounter,4)=@stdev(new)*7.74597

delete resid1
delete new

tab(!rowcounter,6)=obss
tab(!rowcounter,7)=%name

delete obss

!rowcounter=!rowcounter+1
else
endif
next
next
next


The workfile is quite large and I am not sure how I can upload it.

Thanks again for helping in this matter. Please advise whether this is my code that created the crash or is it a bug issue?

Many thanks,
SL

re: bugs when loop thru a large group of stocks

Posted: Sat Nov 23, 2013 6:14 pm
by EViews Gareth
How large is the workfile? Have you tried zipping it?

Re: re: bugs when loop thru a large group of stocks

Posted: Sat Nov 23, 2013 6:59 pm
by sauleung
Hi Gareth,

Thanks for the quick reply. Much appreciated.

I find that after zipping, the file size seems okay, thanks for reminding me!

I have uploaded the file to my google drive with the following link:
https://drive.google.com/file/d/0B99_wN ... sp=sharing

Please let me know if you need more information or any questions.

Many thanks,
SL

Re: re: bugs when loop thru a large group of stocks

Posted: Sat Nov 23, 2013 7:20 pm
by EViews Gareth
Thanks, we'll look into it on Monday.

Re: re: bugs when loop thru a large group of stocks

Posted: Mon Nov 25, 2013 11:57 am
by EViews Gareth
Tricky one...

Basically it is due to the table blowing out memory. There is a slight error in your program (I believe). You created the table with 10 rows and 500,000 columns. Then, in your program, each time you loop through a stock you move to the next row of the table. Thus you're adding lots of rows to the table. Each row has 500,000 columns, so before long you've created a huge table and you run out of memory.

We'll fix the crash so that an "Out of memory" error occurs, rather than EViews crashing. But for your particular case, you're better off just not sizing the table at all. Simply change the line:

Code: Select all

table(10,500000) tab
to be:

Code: Select all

table tab
and you'll find it works much better.

Re: re: bugs when loop thru a large group of stocks

Posted: Mon Nov 25, 2013 7:11 pm
by sauleung
Thanks Gareth! I got it now, I meant to make a table with lots of rows and few columns, a careless mistake.

Cheers,
SL

Re: re: bugs when loop thru a large group of stocks

Posted: Mon Nov 25, 2013 7:14 pm
by EViews Gareth
You're better off making one with no rows and columns and letting EViews make them as it needs.