I have the following variables:
y, x1, x2, x3, x4
They are not a time series. They are an unstructured panel.
I want to run a program that gives me a linear regression with every possible permutation. I want to store R-squared, t-stats, and AIC.
The permutations should include regressions with one-to-many variables. For example I want the results as if I had typed in all of these:
y x1
y x1 x2
y x1 x2 x3
y x1 x2 x3 x4
y x1 x3
y x1 x4
y x2 x3
y x2 x3 x4
y x2 x4
....etc etc.
How do I write a program that will run that regression for me?
Permutation of all Independent Variables
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Permutation of all Independent Variables
I'm sure there is a more efficient method, but this seems to work:
Code: Select all
%vars1 = "x1 x2 x3 x4 "
for %var1 {%vars1}
for %var2 {%vars1}
for %var3 {%vars1}
for %var4 {%vars1}
%vars = %var1 + " " + %var2 + " " + %var3 + " " + %var4
%vars = @wunique(%vars)
%vars = @wsort(%vars)
%eqname = "eq_" + @replace(%vars, " ", "_")
if @isobject(%eqname) = 0 then
equation {%eqname}.ls y {%vars}
endif
next
next
next
next
Re: Permutation of all Independent Variables
In the course of the recursion, I get a "near singular matrix" error when it is trying to run one of the regression.
Is it possible to override this, so that if it gets the error, the recursion continues through?
The issue is that some of the permutations probably do have this error. But some do not. I don't want the entire process interrupted just because one of the regressions gives this error.
Thanks!
Is it possible to override this, so that if it gets the error, the recursion continues through?
The issue is that some of the permutations probably do have this error. But some do not. I don't want the entire process interrupted just because one of the regressions gives this error.
Thanks!
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Permutation of all Independent Variables
When you run your program, just set the maximum number of errors to something high.
Re: Permutation of all Independent Variables
How do I do that? I'm new to e-views programming, so what's syntax/command for that? Thanks!
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Permutation of all Independent Variables
When you hit the run button on your program there is an option to set the number of errors. It isn't a command - it is on the dialog.
Who is online
Users browsing this forum: No registered users and 2 guests
