Page 1 of 1

Averaging by-group impulse response functions

Posted: Thu Jan 07, 2016 4:29 am
by arges
I have time-series data on three different variables for 3 individual stocks (i.e. I have a panel). I want to run a stock-by-stock VAR end ultimately end up with the average of the 3 stock-by-stock cumulative generalized impulse response functions (GIRF). Moreover, because I would like to have an idea about the aggregated standard error I will also have to average the stock-by-stock variances (see pg.34 http://horst.qfl-berlin.de/files/latent ... 914_GC.pdf for a more detailed explanation of what I am trying to achieve). I have gone through the basic Eviews programming tutorial and read some posts but, being an Eviews beginner I am still struggling with this.

Steps I will have to take:
1) Run VAR for each stock
2) Run GIRF for each stock and store coefficients + S.E.s
3) Take average of the coefficients
4) Sum the squared S.E.s and divide by the number of stocks squared (this is in line with the paper I mentioned)
(5) Make graphs of the averaged data)

I have attached a mockup dataset with random data (the actual dataset is much larger and contains 100 stock symbols). This is what I have come up with so far:

Code: Select all

'Create a for loop to run the VAR and GIRF for each stock for %sym AAPL GOOG MFB smpl if symbol=%sym var var_{%sym}.ls(noconst) 1 4 data1 data2 data3 var_{%sym}.impulse(10, t,a, imp = gen,se=a,matbyr=estimates_{%sym}) next 'Do the averaging of the coefficients + S.E.'s '??
So I am stuck at the point where I have to do the averaging of all the matrices. Also note that the way in which I have to name the stocks in the loop is not convenient since I have a lot of them.

Could anyone help me out? Many thanks in advance.


EDIT: after spending quite some time reading through documentation I have come up with the (inelegant) solution below. There are still some issues though. The biggest inconvenience is that I have to explicitly name the stock symbols (instead of using a function to get a list of all unique characters in the series for example). Moreover, if I understand the reference paper correct then the average SE is equal to square root(sum of the variances/number of stocks squared) but I don't know how to take the element-wise square root of a matrix (I am using EViews 8 by the way).

Code: Select all

'Create a for loop to run the VAR and GIRF for each stock for %sym AAPL GOOG MFB smpl if symbol=%sym var var_{%sym}.ls(noconst) 1 4 data1 data2 data3 var_{%sym}.impulse(10, t,a, imp = gen,se=a,matbyr=estimates_{%sym}) next 'Do the averaging of the coefficients matrix avg_coef = estimates_aapl for %sym GOOG MFB avg_coef = avg_coef + estimates_{%sym} next avg_coef=avg_coef/3 'Do the averaging of the S.E.s (method of the reference paper, but I'm not 100% sure that this is what they propose though??) matrix avg_se = @emult(estimates_aapl_se,estimates_aapl_se) for %sym GOOG MFB avg_se = avg_se + @emult(estimates_{%sym}_se,estimates_{%sym}_se) next avg_se=avg_se/9

It would be nice if anyone responded. I put quite some time in clearly formulating the question and I provided a reference, some sample data and a sample code.

Re: Averaging by-group impulse response functions

Posted: Wed Jan 13, 2016 1:55 pm
by arges
What is wrong with my question? After a week still no response while other questions get answered by the staff within 2 minutes of posting?

Re: Averaging by-group impulse response functions

Posted: Wed Jan 13, 2016 2:45 pm
by EViews Gareth
It isn't clear what your question is.