Page 1 of 1

How to write program for series of regressions

Posted: Thu Oct 30, 2008 5:27 am
by Teerapan
I'd like to run 200 regressions by replacing its dependent variable (same explanatory variables of all regressions) and obtain constant and coeffieicents of each regression. Any suggestion how I could deal with this? Thanks.

Re: How to write program for series of regressions

Posted: Thu Oct 30, 2008 5:39 am
by startz
I'd like to run 200 regressions by replacing its dependent variable (same explanatory variables of all regressions) and obtain constant and coeffieicents of each regression. Any suggestion how I could deal with this? Thanks.

Code: Select all

equation eq for %i x y eq.ls {%i} c z next
This runs the regressions, but you have to think about how you want to look at that many sets of results. You might save the results of each regression into a matrix, or you might "print" to a spool object.

Re: How to write program for series of regressions

Posted: Thu Oct 30, 2008 8:17 am
by Teerapan
This runs the regressions, but you have to think about how you want to look at that many sets of results. You might save the results of each regression into a matrix, or you might "print" to a spool object.
What if I want to save it into matrix?
Sorry, I am really new to EViews programming. :oops:

Re: How to write program for series of regressions

Posted: Thu Oct 30, 2008 8:30 am
by EViews Gareth
Having a for loop that runs through the 200 names is slightly unworkable, so Startz's method might not be the best.

I would put the dependent variables (all 200 of them) into a group, then use the group to run through the regressions. Something like:

Code: Select all

'create a workfile create u 100 group regs 'group for the X variables group deps 'group for the Y variables 'create some data for !i = 1 to 5 series x!i=nrnd regs.add x!i next for !i=1 to 200 series y!i = nrnd deps.add y!i next 'matrix to hold results - number of rows is equal to number of dependent variables, number of columns is equal to number of regressors matrix(deps.@count,regs.@count) coefs 'declare equation object to be used inside loop equation e1 'now do estimations for !i = 1 to deps.@count e1.ls deps(!i) regs rowplace(coefs,@transpose(e1.@coefs),!i) next
Note that that is a stand alone program - you would not need the data creation parts, you would just need to put the dependent variables in the group "deps" and the regressors in the group "regs"

Re: How to write program for series of regressions

Posted: Fri Dec 05, 2008 4:49 am
by Qmars
Hi
I have more or less the same problem in programming. I am trying to regress the number of cars in 150 countries using GDP as regressor for the period of 2003-2007. For both explanatory (GDP) and explained variables (car) the data for countries is represented with identifier like at_car, at_gdp etc. Therefore the file contains 150 set of data for GDP and 150 set of data for car.
What would be best way to write a program to calculate the intercept and coefficient for GDP and save the results in equation format for all countries?

Sorry if the question is very basic. I am new to programming :oops: