Page 1 of 1
Help needed! Multiple Regressions with the Y variable.
Posted: Thu Aug 25, 2011 7:44 am
by GregKU
Hi EViews,
I want to run some regressions with roughly 300 separate series of Y dependant variables. I want to regress each Y series against my independent X variable (actually only one). I don't need all the estimation output either, but just the value first co-efficient (i.e. the constant).
I've tried reading and experimenting with the Intro to Eviews Programming, but I haven't got anywhere.
Can you help?
Any info would me much appreciated.
Thanks,
Greg
Re: Help needed! Multiple Regressions with the Y variable.
Posted: Thu Aug 25, 2011 7:49 am
by EViews Gareth
That sounds pretty similar to the first example in the intro. Perhaps you could show us what you've got so far.
Re: Help needed! Multiple Regressions with the Y variable.
Posted: Thu Aug 25, 2011 9:51 am
by GregKU
Alas, I'm too embarrassed to post my code. I'm a very novice user.
However, maybe I should explain my data more. I've got roughly 300 Fund returns, which I want to perform a CAPM regression with. I imported my fund return data into my workfile, as well as my Market return data. Each Fund has its own series, which is monthly returns for over 5 years. So I have 300 fund returns in my workfile. Rather than have to type the Regression equation for each fund's return, I was hoping to use the programming language to save me having to write a similar equation 300 times.
As for the Vector, I think the code I'd have to use is something like:
scalar coefs(1)
coefs(1) a10.@coefs(1)
(with a10 being the name of my CAPM equation for fund a10- which is a code I have designated for that particular fund).
Sorry for all the blurb. Just thought it might help you, and perhaps others with the same problem!
Any help would be much appreciated.
Greg
Re: Help needed! Multiple Regressions with the Y variable.
Posted: Thu Aug 25, 2011 9:56 am
by EViews Gareth
Put the returns into a group, then do something like:
Code: Select all
matrix(2,300) coefs 'I'm assuming you have a single X variable plus a constant
equation eq
for !i=1 to 300 'loop through the group members
%sname = g.@seriesname(!i) 'get name of current member of the group (which is a series)
eq.ls {%sname} c x 'regress the current series against a constant and your x variable (change X to be the name of your variable)
colplace(coefs, eq.@coefs, !i) 'place the current coefficients into the matrix
next
Re: Help needed! Multiple Regressions with the Y variable.
Posted: Thu Aug 25, 2011 11:26 am
by GregKU
Gareth,
Thanks very much for that. I'll be trying it tomorrow morning my time, so I'll let you know!
Have a good one.
G
Re: Help needed! Multiple Regressions with the Y variable.
Posted: Thu May 08, 2014 6:19 am
by franknijenhuis
Hi Gareth,
I tried to do the above, changing the code to my requirements. However, I doesn't seem to work.
I have 2563 stocks, and the dependent variables are rf mktrf hml smb (without a fixed coefficient). I have opened all stocks (sr01,sr02,sr03....) as group sr.
Code: Select all
matrix(2,2563) coefs
for !i=1 to 2563 'loop through the group members
%sname = g.@seriesname(!i) 'get name of current member of the group (which is a series)
eq.ls {%sname} rf mktrf hml smb 'regress the current series against a constant and your x variable
colplace(coefs, eq.@coefs, !i) 'place the current coefficients into the matrix
next
does this not work because this only works with one dependent variable, or what should I change?
Thanks!
Frank
Re: Help needed! Multiple Regressions with the Y variable.
Posted: Thu May 08, 2014 8:01 am
by EViews Gareth
Change the size of your storage matrix so that is has enough rows to match the number of regressors.
Re: Help needed! Multiple Regressions with the Y variable.
Posted: Fri May 09, 2014 2:24 am
by franknijenhuis
thanks works now! Two more small questions. In the output file will coefficient 11 be refer to coefficient of series SR11(normal counting) or SR100 (eviews counting)?
Secondly, I tried to extend the code to running with both changing y and changing x resulting in the below. I think it errors on the double for statement, which I guess I'm not allowed to make. How can I avoid this?
Code: Select all
matrix(4,4555) coefs
for !i=1 to 4555 'loop through the group members
%sname = ret.@seriesname(!i) 'get name of current member of the group defining y
for !k=1 to 4555
%kname = fac.@seriesname(!k) ' get name of current member of the group defining factor in x
equation eq
eq.ls {%sname} mktrf hml smb {%kname} 'regress the current series against a constant and your x variable
colplace(coefs, eq.@coefs, !i) 'place the current coefficients into the matrix
next
next
Thanks again!
Re: Help needed! Multiple Regressions with the Y variable.
Posted: Fri May 09, 2014 8:09 am
by EViews Gareth
Actually I can see nothing wrong with that code.