exact sample size for various series

For questions regarding programming in the EViews programming language.

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

veni
Posts: 12
Joined: Fri Sep 02, 2016 6:04 am

exact sample size for various series

Postby veni » Wed Mar 15, 2017 7:34 am

Dear All
I have a excel file with 5000 time series. All the series have not the same history, that's why there are a lot of N/A to fill the whole sample. I import the series as matrix and then I convert it to series (Problem 1: The N/A's are converted to zeros which is a problem as the variable does not actually take the value of zero, but it's just unavailable).

The goal is to run 5000 regressions which obviously have different start and end dates (Problem 2). It's mandatory to know the start/end dates as at the end of the day, I need to know the length of the series and do the regression using a part of the sample and use the rest for an out-of-sample forecast.

I wrote a small code to identify those dates, but I cannot map the created variable with the dates.

Maybe I have to change the way I think the structure of the program.

Below I give you the code I wrote.
Any ideas are more than welcome.
Thanks for you time,
Veni

matrix eqpremd=@subextract(eqprem,1,2,@rows(eqprem),@columns(eqprem)) 'removes the first column which contains the dates
mtos(eqpremd,eq_prem) 'coverts the matrix to series

'check the availability of the raw data (all_hf_returns)
matrix(@rows(all_hf_returns),@columns(all_hf_returns)-1) test
for !i=2 to @columns(all_hf_returns)
for !j=1 to @rows(all_hf_returns)
test(!j,!i-1) = (all_hf_returns(!j,!i) <> na)
next
next

'Run the regressions and save the results. As it is, it does not account for the different sample sizes
matrix(@columns(eq_prem),1) r2
matrix(5,@columns(eq_prem)) pvals
for !i=1 to eq_prem.@count
%sn = eq_prem.@seriesname(!i)
equation eq01.ls {%sn} c infl(-1) tms(-1) dfy(-1) dfr(-1)
r2(!i)=eq01.@rbar2
colplace(pvals,eq01.@pvals,!i)
next

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

Re: exact sample size for various series

Postby EViews Gareth » Wed Mar 15, 2017 7:59 am

This all seems a little insane. Why are you importing into a matrix? Why not just open the Excel file up as series?

Once you have them as series you can use series.@last to retrieve the date of the last non-NA. You can use the DTOO and OTOD functions to convert from dates to observation space for calculations.

Alternatively (and I think what I would do) you could run the regression over the full workfile range. The regression will automatically drop all the NAs. You can then use the residual series from that regression to determine which observations were available (the residual series will have NAs for non-used observations), and you can use that to subsample further.
Follow us on Twitter @IHSEViews

veni
Posts: 12
Joined: Fri Sep 02, 2016 6:04 am

Re: exact sample size for various series

Postby veni » Wed Mar 15, 2017 8:13 am

Hi Gareth

Thanks for your quick reply. Of course it's insane :)
I'll try the dtoo and the other functions.

Thanks a lot!

Best
Veni


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 14 guests