<?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: Looking for a formula to find the &amp;quot;elbow&amp;quot; in my data in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/781695#M96450</link>
    <description>&lt;P&gt;Ok, so this solution is way-WAY more complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Imagine if you fitted a function to the peak curve, and then calculated the second derivative? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Byron_JMP_0-1723661313708.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/67127i7772A53A32C02D23/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Byron_JMP_0-1723661313708.png" alt="Byron_JMP_0-1723661313708.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It's easier to see graphically. In the figure, the first trace is the original data, a model for a fit, the first and second derivatives of the fit. &amp;nbsp;It might not be easy to see, but the maximum of the second derivative (Blue line) is the middle of the elbow on the first line (triangle marker).&lt;BR /&gt;&lt;BR /&gt;Here's how I got there with JSL. (Note: I changed the name of the first column)&lt;BR /&gt;In this script I let JMP sort out all the calculus along with the curve fit.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
Names Default To Here( 1 );
dt=Open( "$Examples/Example for Elbow.jmp" );

obj=dt &amp;lt;&amp;lt;Fit Curve( Y( :Counts ), X( :time), Fit Skew Normal Peak );
obj &amp;lt;&amp;lt; (Fit["Skew Normal Peak"] &amp;lt;&amp;lt; Save Prediction Formula);
obj &amp;lt;&amp;lt; Close Window;

formula=column(3)&amp;lt;&amp;lt;get formula;
derivative = Derivative(name expr(formula), Time);
second = Derivative(name expr(derivative), Time);
dt&amp;lt;&amp;lt;new column("First Derivative", formula (name expr(derivative)));
dt&amp;lt;&amp;lt;new column("Second Derivative", formula (name expr(second)));
dt&amp;lt;&amp;lt;new column("Peak Start", formula( Col Maximum( :Second Derivative ) == :Second Derivative, 1 ) );
dt&amp;lt;&amp;lt;Select where(:Peak Start == 1)&amp;lt;&amp;lt;Colors( "Red" )&amp;lt;&amp;lt;Markers( "Filled Up Triangle" );
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The last step turns the "elbow" row into a red triangle marker. But you could just as easily subset the selected row into a table and add it to a table with all your other fits. I didn't try this with hundreds of tables but I think it would execute fairly quickly if you put it in a loop to iterate through a lot of data tables.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Aug 2024 18:57:31 GMT</pubDate>
    <dc:creator>Byron_JMP</dc:creator>
    <dc:date>2024-08-14T18:57:31Z</dc:date>
    <item>
      <title>Looking for a formula to find the "elbow" in my data</title>
      <link>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/780091#M96180</link>
      <description>&lt;P&gt;Hi JMP friends,&lt;/P&gt;&lt;P&gt;(On regular JMP 18.0.1, example data attached)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am analyzing some data wherein I need to find the time (x point) at which my data has an "elbow" or inflection. I have an initial mini-peak in my data and have been doing this work manually. However, this is slow and I would like to automate it, as I will be doing this for hundreds of tests that return graphs similar to the below, with varying peak times/amounts and varying 'flat' times. The 'flat' times are generally not very flat, but rather very gradually decreasing. You can see in the attached image of the graph (Example/dummy data) what spot/area I would like to find.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help on what I could do would be really helpful. I think setting up a flag column would be a good way to find this, but am not sure of the JSL or formula I can use to have the flag work.&lt;/P&gt;&lt;P&gt;Any help on figuring this out would be great, thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RZordich_2-1723075719846.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66952iD3F9D6DC7A777677/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RZordich_2-1723075719846.png" alt="RZordich_2-1723075719846.png" /&gt;&lt;/span&gt;&lt;/P&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 00:12:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/780091#M96180</guid>
      <dc:creator>RZordich</dc:creator>
      <dc:date>2024-08-08T00:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for a formula to find the "elbow" in my data</title>
      <link>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/780150#M96184</link>
      <description>&lt;P&gt;I approached finding the elbow as the data point, where the next 10 data points are all greater than the previous data point.&amp;nbsp; This is absolutely a made up algorithm.&amp;nbsp; But it looks like it might be a possible way to identify the elbow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1723080855091.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66954iCA7AD895B7987EEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1723080855091.png" alt="txnelson_0-1723080855091.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1723080898039.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66955iEE3CEC37F8A6DEF8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_1-1723080898039.png" alt="txnelson_1-1723080898039.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the formula I created for the column I named Elbow&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;As Constant(
	flag = 0;
	lookAhead = 10;
);
val = .;
If( flag == 0 &amp;amp; Row() &amp;lt; N Rows( Current Data Table() ) - lookAhead,
	If(
		Min(
			:Counts[Index( Row() + 1, Row() + lookAhead + 1 )] - :Counts[
			Index( Row(), Row() + lookAhead )]
		) &amp;gt; 0,
		val = (flag = 1)
	)
);
val;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Aug 2024 01:35:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/780150#M96184</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-08-08T01:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for a formula to find the "elbow" in my data</title>
      <link>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/781695#M96450</link>
      <description>&lt;P&gt;Ok, so this solution is way-WAY more complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Imagine if you fitted a function to the peak curve, and then calculated the second derivative? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Byron_JMP_0-1723661313708.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/67127i7772A53A32C02D23/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Byron_JMP_0-1723661313708.png" alt="Byron_JMP_0-1723661313708.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It's easier to see graphically. In the figure, the first trace is the original data, a model for a fit, the first and second derivatives of the fit. &amp;nbsp;It might not be easy to see, but the maximum of the second derivative (Blue line) is the middle of the elbow on the first line (triangle marker).&lt;BR /&gt;&lt;BR /&gt;Here's how I got there with JSL. (Note: I changed the name of the first column)&lt;BR /&gt;In this script I let JMP sort out all the calculus along with the curve fit.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
Names Default To Here( 1 );
dt=Open( "$Examples/Example for Elbow.jmp" );

obj=dt &amp;lt;&amp;lt;Fit Curve( Y( :Counts ), X( :time), Fit Skew Normal Peak );
obj &amp;lt;&amp;lt; (Fit["Skew Normal Peak"] &amp;lt;&amp;lt; Save Prediction Formula);
obj &amp;lt;&amp;lt; Close Window;

formula=column(3)&amp;lt;&amp;lt;get formula;
derivative = Derivative(name expr(formula), Time);
second = Derivative(name expr(derivative), Time);
dt&amp;lt;&amp;lt;new column("First Derivative", formula (name expr(derivative)));
dt&amp;lt;&amp;lt;new column("Second Derivative", formula (name expr(second)));
dt&amp;lt;&amp;lt;new column("Peak Start", formula( Col Maximum( :Second Derivative ) == :Second Derivative, 1 ) );
dt&amp;lt;&amp;lt;Select where(:Peak Start == 1)&amp;lt;&amp;lt;Colors( "Red" )&amp;lt;&amp;lt;Markers( "Filled Up Triangle" );
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The last step turns the "elbow" row into a red triangle marker. But you could just as easily subset the selected row into a table and add it to a table with all your other fits. I didn't try this with hundreds of tables but I think it would execute fairly quickly if you put it in a loop to iterate through a lot of data tables.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 18:57:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/781695#M96450</guid>
      <dc:creator>Byron_JMP</dc:creator>
      <dc:date>2024-08-14T18:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for a formula to find the "elbow" in my data</title>
      <link>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/783434#M96774</link>
      <description>&lt;P&gt;You might have a look at the Spectris Add-in. &amp;nbsp;It can be used to fit both the primary peak and the secondary peak (probably what's causing that shoulder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.jmp.com/t5/JMP-Add-Ins/Spectris-Graphical-spectral-data-processing/ta-p/650521" target="_blank"&gt;https://community.jmp.com/t5/JMP-Add-Ins/Spectris-Graphical-spectral-data-processing/ta-p/650521&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;M&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 14:21:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/783434#M96774</guid>
      <dc:creator>MikeD_Anderson</dc:creator>
      <dc:date>2024-08-22T14:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for a formula to find the "elbow" in my data</title>
      <link>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/783501#M96785</link>
      <description>&lt;P&gt;Hi Byron,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this one! I have tried 2nd derivative on a smoothed function, and it didn't seem to work. But I haven't tried the skew normal function. I'll give that a try and see what that catches for me! I'm also looking at figuring out a way to now script in the 'Kneedle' algorithm, which is something I found that finds the 'elbow' point in graphs really well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Rochelle&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 17:37:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looking-for-a-formula-to-find-the-quot-elbow-quot-in-my-data/m-p/783501#M96785</guid>
      <dc:creator>RZordich</dc:creator>
      <dc:date>2024-08-22T17:37:26Z</dc:date>
    </item>
  </channel>
</rss>

