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
Help needed! Multiple Regressions with the Y variable.
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Help needed! Multiple Regressions with the Y variable.
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.
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
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
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Help needed! Multiple Regressions with the Y variable.
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.
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
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
-
franknijenhuis
- Posts: 3
- Joined: Wed May 07, 2014 2:15 am
Re: Help needed! Multiple Regressions with the Y variable.
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.
does this not work because this only works with one dependent variable, or what should I change?
Thanks!
Frank
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
Thanks!
Frank
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Help needed! Multiple Regressions with the Y variable.
Change the size of your storage matrix so that is has enough rows to match the number of regressors.
-
franknijenhuis
- Posts: 3
- Joined: Wed May 07, 2014 2:15 am
Re: Help needed! Multiple Regressions with the Y variable.
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?
Thanks again!
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
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Help needed! Multiple Regressions with the Y variable.
Actually I can see nothing wrong with that code.
Who is online
Users browsing this forum: No registered users and 2 guests
