<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: A speedy way to create a table of Rsquared values in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63776#M34116</link>
    <description>&lt;P&gt;Thank you all for your help.&amp;nbsp; I would like to summarize here,&amp;nbsp;just so there is a record for future JMP explorers.&lt;/P&gt;
&lt;P&gt;I was trying to find a way to quickly determine all the R Squared values of one term vs many terms, up to&amp;nbsp;~100,000 terms.&lt;/P&gt;
&lt;P&gt;In my trial I was fitting 2,000 terms, using an HP EliteBook with Windows 7,&amp;nbsp; 64-bit Operating System, Intel Core i5-4300U CPU @190 GHz 2.50 Ghz, 16 GB RAM.&lt;/P&gt;
&lt;P&gt;My original method of either 1) looping a bivariate fit and reading the R squared from the display tree, or 2) brute forcing calculations, both took ~ 37 sec on my laptop.&amp;nbsp; That's ~ 30 minutes for 100,000 terms!&amp;nbsp; And&amp;nbsp;want to do this for more than one response term!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The method of using the Multivariate platform consumed all my computers resources for ~ 15 minutes and then crashed due to insufficient memory.&amp;nbsp; Don't try this at home.&lt;/P&gt;
&lt;P&gt;The method on using Response Screening from KarenC took 1 sec!&amp;nbsp; This is clearly the solution.&amp;nbsp; I marked a response from&amp;nbsp;mikedriscoll as the Solution only because&amp;nbsp;he summarizes the discussion and he shows the code to use.&lt;/P&gt;
&lt;P&gt;To be complete, here is the code I used in the end.&lt;/P&gt;
&lt;P&gt;dt is my original table of data.&lt;/P&gt;
&lt;P&gt;resp is a character string naming the&amp;nbsp;y column of interest.&lt;/P&gt;
&lt;P&gt;fact is a list of character strings naming the&amp;nbsp;x columns of interest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1 = dt &amp;lt;&amp;lt; Response Screening(Y(column(resp)), X(eval(fact)));
// Note:  This is not a normal table and JMP will not recognize dt1 as a table
// The 'table' is called "Pvalues".  Hopefully you don't already have a table of that name.
//  Of course you can write more code to make this error proof.
// To immediately move this information to a normal JMP table I took a subset.
dt2 = Data Table( "PValues" ) &amp;lt;&amp;lt; Subset( All rows, Selected columns only( 0 ) );
// Now I can do other things, like ...
dt2 &amp;lt;&amp;lt; Sort( By( :RSquare ), Order( Descending ), Replace Table );
rsq = dt2:RSquare&amp;lt;&amp;lt; get as matrix;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jul 2018 16:56:25 GMT</pubDate>
    <dc:creator>pcarroll1</dc:creator>
    <dc:date>2018-07-24T16:56:25Z</dc:date>
    <item>
      <title>A speedy way to create a table of Rsquared values</title>
      <link>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63677#M34070</link>
      <description>&lt;P&gt;I have a script which finds the Rsquared value for one parameter versus many parameters.&amp;nbsp; Once in a table it's simple to sort for the best values.&amp;nbsp; It has worked very well over the years but when I try to push it to find the value&amp;nbsp;for tens of thousands or more parameters it takes a very long time.&amp;nbsp; I wondered if anyone knows a fast way in JSL to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Things I have tried but all take too long:&lt;/P&gt;&lt;P&gt;1. Making a Bivariate report and reading the Rsq from the display tree.&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;xyp = &lt;/FONT&gt;&lt;FONT color="#800000" face="Consolas" size="2"&gt;Bivariate&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(Y(&lt;/FONT&gt;&lt;FONT color="#0000dd" face="Consolas" size="2"&gt;column&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(resp)), &lt;FONT face="Consolas" size="2"&gt;X(&lt;/FONT&gt;&lt;FONT color="#0000dd" face="Consolas" size="2"&gt;eval&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(fact)),&amp;nbsp;Fit Polynomial(degree), invisible);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;This command actually works faster than I would expect but&amp;nbsp;looping through display tree to get the values takes most of the time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;2. Using&amp;nbsp;Fit Model -&amp;gt; &amp;nbsp;StepWise -&amp;gt; All Possible Models of 1 term.&lt;/P&gt;&lt;P&gt;This&amp;nbsp;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.&amp;nbsp; So it doesn't fit my needs.&lt;/P&gt;&lt;P&gt;3. Summing up&amp;nbsp;squares with a function like the one below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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&amp;lt;=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
	);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 18:06:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63677#M34070</guid>
      <dc:creator>pcarroll1</dc:creator>
      <dc:date>2018-07-23T18:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: A speedy way to create a table of Rsquared values</title>
      <link>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63678#M34071</link>
      <description>&lt;P&gt;I have a script that does pretty much the same thing. Used to use the bivariate, now I use multivariate (see subset of the script below).&amp;nbsp; I recently found a bug which I haven't yet fixed, likely with special characters in the column name. But overall this should work. I don't recall if I've used it on such large datasets, but for the data I worked with this was much faster.&amp;nbsp; Note that to get a generic # of x's vs a generic # of y's, it is actually calculating for (num_x + num_y) vs (num_x + num_y), which is still faster than looping through the bivariate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: Karen's method looks much more efficient / elegant than this one. If I ever need to update my script I would definitely check out that method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	numX = nitems(xParamNames);
	numy = nitems(yParamNames);


	yxParamNames = concat(yParamNames, xParamNames);

	mvObj = Multivariate(
//		Y(evallist(yParamList)
		Y(evallist(yxParamNames)

		),
		Estimation Method( "Row-wise" ),
		Matrix Format( "Square" ),
		Scatterplot Matrix(0
		)
	);

	
	
	corrMatrixObj = mvObj &amp;lt;&amp;lt; xpath( "//OutlineBox[ text() = 'Correlations']//MatrixBox");
	corrMatrix = corrMatrixObj &amp;lt;&amp;lt; get();
	corrMatrix = corrMatrix[1];
	
	corrMatRows = 1::numY;
	corrMatCols = (numY+1)::(numY+numX);
	sub_corrMatrix = corrMatrix[corrMatRows,corrMatCols];
	myRsqr = aslist(power(sub_corrMatrix,2));		// rsqr is corr matrix to the power 2. rest of script expects a list. 
	
	mvObj&amp;lt;&amp;lt; closewindow();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 20:33:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63678#M34071</guid>
      <dc:creator>mikedriscoll</dc:creator>
      <dc:date>2018-07-23T20:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: A speedy way to create a table of Rsquared values</title>
      <link>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63681#M34074</link>
      <description>&lt;P&gt;Recently I have been using Analyze&amp;gt;Screening&amp;gt;Resposne Screening (not JSL just the UI) to get RSq values.&amp;nbsp;This works for one versus many parameters or many vs. many parameters. &amp;nbsp;It is fast. You end up with other information, however, the RSq values are in the pvalue table that is generated. Bonus Tip: in the P-value table you can select rows (pairs of parameters) and run the "Fit Selected Items" table scritp to get bivariate fits. &amp;nbsp;I love this as I always want to see a relationship that appears strong numerically before I really believe it.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 19:18:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63681#M34074</guid>
      <dc:creator>KarenC</dc:creator>
      <dc:date>2018-07-23T19:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: A speedy way to create a table of Rsquared values</title>
      <link>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63694#M34078</link>
      <description>&lt;P&gt;Mike,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Thanks for the response.&amp;nbsp; I tried this.&amp;nbsp; Is this only recording the R of terms&amp;nbsp;common over all the data?&amp;nbsp; I wonder if it's robust to bad columns of data.&lt;/P&gt;&lt;P&gt;Pat&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 20:40:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63694#M34078</guid>
      <dc:creator>pcarroll1</dc:creator>
      <dc:date>2018-07-23T20:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: A speedy way to create a table of Rsquared values</title>
      <link>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63695#M34079</link>
      <description>&lt;P&gt;Karen,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; This is very fast and seems to get all the parameters I could ever want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My application is part&amp;nbsp;of a script that does other things with the results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you think it can be scripted?&lt;/P&gt;&lt;P&gt;I'm surprised that there is no Source variable for the table.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 20:44:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63695#M34079</guid>
      <dc:creator>pcarroll1</dc:creator>
      <dc:date>2018-07-23T20:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: A speedy way to create a table of Rsquared values</title>
      <link>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63696#M34080</link>
      <description>&lt;P&gt;I am also suprised there is not a "Source" entry on the new data table.&amp;nbsp; I suggest that you&amp;nbsp; add an entry in the JMP Wish List asking for this to be added.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 21:02:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63696#M34080</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-07-23T21:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: A speedy way to create a table of Rsquared values</title>
      <link>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63697#M34081</link>
      <description>&lt;P&gt;In response to your first question about my script, multivariate only has the "Y" variables, so I concatenate X's and Y's and let it calculate it. I dont' recall what I do for overlap but I suppose I handle it somehow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The response screening that Karen pointed out makes much more sense for what I was trying to do.&amp;nbsp; It can be scripted apparently. Run it as a test, then look at the red triangle from the report output, not the table. The top red triangle. Click save script -&amp;gt; to script window and you can see it. I don't know how to get the reference to the table and the r values, but I'd probably get a list of open tables before the script was executed... then find the new one after it is generated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Response Screening( Y( .... ), X(....&amp;nbsp; ) )&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 21:03:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63697#M34081</guid>
      <dc:creator>mikedriscoll</dc:creator>
      <dc:date>2018-07-23T21:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: A speedy way to create a table of Rsquared values</title>
      <link>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63698#M34082</link>
      <description>&lt;P&gt;You can call the Response Screening platform from JSL...from there my JSL skills can't help you.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 21:06:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63698#M34082</guid>
      <dc:creator>KarenC</dc:creator>
      <dc:date>2018-07-23T21:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: A speedy way to create a table of Rsquared values</title>
      <link>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63776#M34116</link>
      <description>&lt;P&gt;Thank you all for your help.&amp;nbsp; I would like to summarize here,&amp;nbsp;just so there is a record for future JMP explorers.&lt;/P&gt;
&lt;P&gt;I was trying to find a way to quickly determine all the R Squared values of one term vs many terms, up to&amp;nbsp;~100,000 terms.&lt;/P&gt;
&lt;P&gt;In my trial I was fitting 2,000 terms, using an HP EliteBook with Windows 7,&amp;nbsp; 64-bit Operating System, Intel Core i5-4300U CPU @190 GHz 2.50 Ghz, 16 GB RAM.&lt;/P&gt;
&lt;P&gt;My original method of either 1) looping a bivariate fit and reading the R squared from the display tree, or 2) brute forcing calculations, both took ~ 37 sec on my laptop.&amp;nbsp; That's ~ 30 minutes for 100,000 terms!&amp;nbsp; And&amp;nbsp;want to do this for more than one response term!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The method of using the Multivariate platform consumed all my computers resources for ~ 15 minutes and then crashed due to insufficient memory.&amp;nbsp; Don't try this at home.&lt;/P&gt;
&lt;P&gt;The method on using Response Screening from KarenC took 1 sec!&amp;nbsp; This is clearly the solution.&amp;nbsp; I marked a response from&amp;nbsp;mikedriscoll as the Solution only because&amp;nbsp;he summarizes the discussion and he shows the code to use.&lt;/P&gt;
&lt;P&gt;To be complete, here is the code I used in the end.&lt;/P&gt;
&lt;P&gt;dt is my original table of data.&lt;/P&gt;
&lt;P&gt;resp is a character string naming the&amp;nbsp;y column of interest.&lt;/P&gt;
&lt;P&gt;fact is a list of character strings naming the&amp;nbsp;x columns of interest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1 = dt &amp;lt;&amp;lt; Response Screening(Y(column(resp)), X(eval(fact)));
// Note:  This is not a normal table and JMP will not recognize dt1 as a table
// The 'table' is called "Pvalues".  Hopefully you don't already have a table of that name.
//  Of course you can write more code to make this error proof.
// To immediately move this information to a normal JMP table I took a subset.
dt2 = Data Table( "PValues" ) &amp;lt;&amp;lt; Subset( All rows, Selected columns only( 0 ) );
// Now I can do other things, like ...
dt2 &amp;lt;&amp;lt; Sort( By( :RSquare ), Order( Descending ), Replace Table );
rsq = dt2:RSquare&amp;lt;&amp;lt; get as matrix;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 16:56:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-speedy-way-to-create-a-table-of-Rsquared-values/m-p/63776#M34116</guid>
      <dc:creator>pcarroll1</dc:creator>
      <dc:date>2018-07-24T16:56:25Z</dc:date>
    </item>
  </channel>
</rss>

