How to write program for series of regressions
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
How to write program for series of regressions
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.
-
- Non-normality and collinearity are NOT problems!
- Posts: 3775
- Joined: Wed Sep 17, 2008 2:25 pm
Re: How to write program for series of regressions
Teerapan wrote: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
startz wrote: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.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to write program for series of regressions
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:
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"
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"
Follow us on Twitter @IHSEViews
Re: How to write program for series of regressions
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
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
Who is online
Users browsing this forum: No registered users and 49 guests