I have a script which finds the Rsquared value for one parameter versus many parameters. Once in a table it's simple to sort for the best values. It has worked very well over the years but when I try to push it to find the value for tens of thousands or more parameters it takes a very long time. I wondered if anyone knows a fast way in JSL to do this.
Things I have tried but all take too long:
1. Making a Bivariate report and reading the Rsq from the display tree.
xyp = Bivariate(Y(column(resp)), X(eval(fact)), Fit Polynomial(degree), invisible);
This command actually works faster than I would expect but looping through display tree to get the values takes most of the time.
2. Using Fit Model -> StepWise -> All Possible Models of 1 term.
This seems to only fit rows of data that have no missing data for all terms and I may have a lot of missing data for some terms. So it doesn't fit my needs.
3. Summing up squares with a function like the one below.
GetRsquared = function ({x,y}, {sx,sy,ssxx,ssyy,ssxy,nr,np,i},
sx=0;
sy=0;
ssxx=0;
ssyy=0;
ssxy=0;
nr=nrows(y);
np=nr;
for( i=1, i<=nr, i++,
if(is missing(x[i]),np--,
if(is missing(y[i]),np--,
sx=sx+x[i];
sy=sy+y[i];
ssxx=ssxx+x[i]*x[i];
ssyy=ssyy+y[i]*y[i];
ssxy=ssxy+x[i]*y[i]
)));
ssxx=ssxx-sx*sx/np;
ssyy=ssyy-sy*sy/np;
ssxy=ssxy-sx*sy/np;
r2=ssxy*ssxy/ssxx/ssyy
);