Page 1 of 1

Permutation of all Independent Variables

Posted: Mon Nov 28, 2011 12:14 pm
by mrod305
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?

Re: Permutation of all Independent Variables

Posted: Mon Nov 28, 2011 2:26 pm
by EViews Gareth
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

Posted: Wed Dec 14, 2011 8:55 am
by mrod305
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!

Re: Permutation of all Independent Variables

Posted: Wed Dec 14, 2011 9:34 am
by EViews Gareth
When you run your program, just set the maximum number of errors to something high.

Re: Permutation of all Independent Variables

Posted: Wed Dec 14, 2011 10:02 am
by mrod305
How do I do that? I'm new to e-views programming, so what's syntax/command for that? Thanks!

Re: Permutation of all Independent Variables

Posted: Wed Dec 14, 2011 10:11 am
by EViews Gareth
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.