<?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: Need help writing optimal code for extracting R^2 and Slope from Bivariate Fit in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/497867#M73461</link>
    <description>&lt;P&gt;There are at least three different ways to get those values:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Get them from Bivariate Report with your method of choice&lt;/LI&gt;
&lt;LI&gt;Get them by using Make Into Data Table/Make Combined Data Table and get them from the data tables created&lt;/LI&gt;
&lt;LI&gt;Use matrix function&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;In this case I would either use option 1 or 2 because you will have to create the Bivariate anyway&lt;/P&gt;</description>
    <pubDate>Wed, 01 Jun 2022 19:49:42 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2022-06-01T19:49:42Z</dc:date>
    <item>
      <title>Need help writing optimal code for extracting R^2 and Slope from Bivariate Fit</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/497820#M73460</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to ask the community to nudge me in the right direction.&lt;/P&gt;&lt;P&gt;I need to extract R^2 and Slope form the report and display it on the plot itself like so:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2022-06-01 12_13_08-Window.png" style="width: 383px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/42872iD11801648DB8D953/image-size/large?v=v2&amp;amp;px=999" role="button" title="2022-06-01 12_13_08-Window.png" alt="2022-06-01 12_13_08-Window.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm going to do this with parsing Display Trees and then looking into Add Graphics Script to the plot itself.&lt;/P&gt;&lt;P&gt;But, since this task seems to me very standard and routine, I have to ask couple of questions before digging into Display Trees:&lt;/P&gt;&lt;P&gt;1. Is there a more straight forward way of doing that? Like &lt;EM&gt;Combined Data Table&lt;/EM&gt; (which gives slope but does not give R^2) for getting number or like&amp;nbsp;&lt;EM&gt;Line Of Fit( X, Y, Legend( 5 ), R²( 1 ), Equation( 1 ) )&lt;/EM&gt; in graph builder (customer wants to use Bivariate Fit)&lt;/P&gt;&lt;P&gt;2. Maybe somebody already has a snippet of code ready to use for this task?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:00:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/497820#M73460</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2023-06-09T17:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need help writing optimal code for extracting R^2 and Slope from Bivariate Fit</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/497867#M73461</link>
      <description>&lt;P&gt;There are at least three different ways to get those values:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Get them from Bivariate Report with your method of choice&lt;/LI&gt;
&lt;LI&gt;Get them by using Make Into Data Table/Make Combined Data Table and get them from the data tables created&lt;/LI&gt;
&lt;LI&gt;Use matrix function&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;In this case I would either use option 1 or 2 because you will have to create the Bivariate anyway&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 19:49:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/497867#M73461</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-06-01T19:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need help writing optimal code for extracting R^2 and Slope from Bivariate Fit</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/497973#M73463</link>
      <description>&lt;P&gt;You can get really close with Graph Builder&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Equation includes the slope." style="width: 919px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/42884i7023F11C45882DA6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Equation includes the slope." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Equation includes the slope.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 22:23:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/497973#M73463</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2022-06-01T22:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need help writing optimal code for extracting R^2 and Slope from Bivariate Fit</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/498004#M73465</link>
      <description>&lt;P&gt;If you just need the values, and not the graph, you can use the Linear Regression() function, and get the values from there&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );
/*Simple Linear Regression: y = intercept + beta * x + error*/
y = :height &amp;lt;&amp;lt; get values;
X = :weight &amp;lt;&amp;lt; get values;
{Estimates, Std_Error, Diagnostics} = Linear Regression( y, X, &amp;lt;&amp;lt;printToLog ); 
 
RSquare = Diagnostics["RSquare"];
slope = Estimates[2];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;rsquare = 0.502917160762804;
slope = 0.135507698709946;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jun 2022 00:21:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/498004#M73465</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-06-02T00:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need help writing optimal code for extracting R^2 and Slope from Bivariate Fit</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/498186#M73467</link>
      <description>&lt;P&gt;Yes, I scripted that already (as I mentioned in the initial question it's easy by adding&amp;nbsp;&lt;EM&gt;Line Of Fit( X, Y, Legend( 5 ), R²( 1 ), Equation( 1 ) ) &lt;/EM&gt;into the Graph Builder Code), however, customer doesn't like Graph Builder for some reason and insists on using Bivariate Fit.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 06:17:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/498186#M73467</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2022-06-02T06:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help writing optimal code for extracting R^2 and Slope from Bivariate Fit</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/498187#M73468</link>
      <description>&lt;P&gt;I need graph too, and it has to be Bivariate Fit. Previously the customer was taking a screenshot of the plot and portion of the report below to have Slope and R^2 included (basically image in my initial question without red markings). I'm automating the whole thing and I want to get rid of the report and just write those two values on the plot itself (as illustrated on my screenshot with red text on the plot).&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 06:20:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/498187#M73468</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2022-06-02T06:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need help writing optimal code for extracting R^2 and Slope from Bivariate Fit</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/498203#M73469</link>
      <description>&lt;P&gt;Here is an example that should get you started.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1654155994175.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/42897iFB05A3D7D3F75C44/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1654155994175.png" alt="txnelson_0-1654155994175.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );

biv = Bivariate( Y( :height ), X( :weight ), Fit Line( {Line Color( {212, 73, 88} )} ) );
Report( biv )[framebox( 1 )] &amp;lt;&amp;lt; add graphics script(
	Text Color( {212, 73, 88} );
	xMin = Current Report()[axisbox( 2 )] &amp;lt;&amp;lt; get min;
	yMin = Current Report()[axisbox( 1 )] &amp;lt;&amp;lt; get min;
	xMax = Current Report()[axisbox( 2 )] &amp;lt;&amp;lt; get max;
	yMax = Current Report()[axisbox( 1 )] &amp;lt;&amp;lt; get max;
	textList = {};
	Insert Into( textList, xMin + (xMax - xMin) * .25 );
	Insert Into( textList, yMax - (yMax - yMin) * .1 );
	R2 = Current Report()["Summary of Fit"][Number Col Box( 1 )][1];
	R2 = "R^2 = " || Format( R2, "Fixed Dec", 5, 3 );
	Text( Right Justified, textList, R2 );
	textList = {};
	Insert Into( textList, xMin + (xMax - xMin) * .32 );
	Insert Into( textList, yMax - (yMax - yMin) * .15 );
	Slope = Current Report()["Parameter Estimates"][Number Col Box( 1 )][2];
	Slope = "Slope = " || format(Slope,"Fixed Dec",9,5);
	Text(Right Justified, textList, Slope);
);
report(biv)["Linear Fit"] &amp;lt;&amp;lt; visibility("collapse");
report(biv)[PictureBox(2)] &amp;lt;&amp;lt; visibility("collapse");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Documentation for the Graphic additions, and the Display Tree manipulationq can be found in the Scripting Guide and the Scripting Index&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 07:48:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/498203#M73469</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-06-02T07:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need help writing optimal code for extracting R^2 and Slope from Bivariate Fit</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/498208#M73470</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt=Open("$SAMPLE_DATA/Tablet Production.jmp");

biv=dt&amp;lt;&amp;lt;Bivariate(
	Y( :Dissolution ),
	X( :Mill Time ),
	Fit Line( {Line Color( {212, 73, 88} )} )

);

slope=report(biv)[NumberColBox(13)][2];
r2=report(biv)[NumberColBox(1)][1];

slope=round(slope,3);
r2=round(r2,3);


Eval(Parse(Eval Insert("biv&amp;lt;&amp;lt;SendToReport(
		Dispatch(
			{},
			\!"Bivar Plot\!",
			FrameBox,
			Add Text Annotation(
				Text( \!"Rsq=^r2^
Slope=^slope^\!" ),
				Fixed Size( 0 ),
				Text Box( {2, 16, 100, 70} ),
				Filled( 0 )
			)
		)
	);")));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jun 2022 07:56:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-writing-optimal-code-for-extracting-R-2-and-Slope-from/m-p/498208#M73470</guid>
      <dc:creator>HadleyMyers</dc:creator>
      <dc:date>2022-06-02T07:56:28Z</dc:date>
    </item>
  </channel>
</rss>

