Page 1 of 1

R Squared Vector for the General Case

Posted: Tue Jun 23, 2015 7:49 am
by diggetybo
Hello,

I'm writing a tangent question on the intro to Eviews programming. I beleive it is the 4th program where a string loop is used to regress the variables on each other, then create a vector to store the respective r2s.

In the example...
Vector size: 10
Variables used: 5

I'm interested in writing a code for the general case( the case of regressing variables on each other); that is to say a case involving n regressors. So the point here is to replace:

Code: Select all

vector(10) r2s
with a code that calculates the size of the vector based on how many variables are involved. I'm guessing this can be done by using the group.@count syntax. However, I don't know the mathematical formula to calculate the vector size. It can't be as simple as 5*2=10, or is it? Maybe factorials are involved? It may look like:

Code: Select all

vector(fancy math formula) r2s
This way no mater how many variables we have, the vector size will be adequate.

Maybe someone who has a good handle on math can share a tip to this extent?

Thank you

Re: R Squared Vector for the General Case

Posted: Tue Jun 23, 2015 8:16 am
by EViews Gareth
Cheat.

Run a loop that loops through all the combinations, but all it does inside the loop is count. The the end of the loop you'll have a count of how many times the loop was run.

Re: R Squared Vector for the General Case

Posted: Tue Jun 23, 2015 8:56 am
by diggetybo
Hey Gareth, that's a great idea! I appreciate it

Re: R Squared Vector for the General Case

Posted: Tue Jun 23, 2015 9:12 am
by EViews Gareth
:D