R Squared Vector for the General Case

For econometric discussions not necessarily related to EViews.

Moderators: EViews Gareth, EViews Moderator

diggetybo
Posts: 152
Joined: Mon Jun 23, 2014 12:04 am

R Squared Vector for the General Case

Postby diggetybo » Tue Jun 23, 2015 7:49 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: R Squared Vector for the General Case

Postby EViews Gareth » Tue Jun 23, 2015 8:16 am

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.

diggetybo
Posts: 152
Joined: Mon Jun 23, 2014 12:04 am

Re: R Squared Vector for the General Case

Postby diggetybo » Tue Jun 23, 2015 8:56 am

Hey Gareth, that's a great idea! I appreciate it

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: R Squared Vector for the General Case

Postby EViews Gareth » Tue Jun 23, 2015 9:12 am

:D


Return to “Econometric Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests