<?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: Fast Way to calculate &amp;quot;nested&amp;quot; Col ... aggregations - like MAD in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/m-p/883820#M104793</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/26800"&gt;@hogi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;another trick:&lt;BR /&gt;- wait for the next version of JMP ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I just tried it with the EA version of JMP19 - A significant improvement !&lt;BR /&gt;-&amp;gt; just a few seconds instead of several minutes&lt;BR /&gt;wonderful : )&lt;/P&gt;</description>
    <pubDate>Tue, 08 Jul 2025 06:25:01 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2025-07-08T06:25:01Z</dc:date>
    <item>
      <title>Fast Way to calculate "nested" Col ... aggregations - like MAD</title>
      <link>https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/m-p/882261#M104618</link>
      <description>&lt;P&gt;In 2017&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3244"&gt;@Kevin_Anderson&lt;/a&gt;&amp;nbsp;submitted a wish to add a functionality to calculate&amp;nbsp;&lt;LI-MESSAGE title="Robust Means and Standard Deviation functions in JSL and Formula Editor" uid="48441" url="https://community.jmp.com/t5/JMP-Wish-List/Robust-Means-and-Standard-Deviation-functions-in-JSL-and-Formula/m-p/48441#U48441" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In 2022 an extended version of the wish was submitted by&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;:&lt;BR /&gt;&lt;LI-MESSAGE title="Add normalization and robust statistical functions (and matrix functions)" uid="504984" url="https://community.jmp.com/t5/JMP-Wish-List/Add-normalization-and-robust-statistical-functions-and-matrix/m-p/504984#U504984" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;BR /&gt;with the comment:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;Most of these could already be implemented fairly easily by using existing statistical functions, but I would much rather have them as normal functionality in JMP (native implementation could also be &lt;STRONG&gt;faster&lt;/STRONG&gt;?). In my opinion, these are very useful and powerful functions (like are all other Statistical Col functions).&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another function to determine a robust estimator for the variation of values:&lt;BR /&gt;&lt;STRONG&gt;MAD: Median Absolute Deviation.&lt;/STRONG&gt;&lt;BR /&gt;&lt;A href="https://en.wikipedia.org/wiki/Median_absolute_deviation" target="_blank" rel="noopener"&gt;https://en.wikipedia.org/wiki/Median_absolute_deviation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1751225253705.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/77541iCB69FC68EAAC94C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1751225253705.png" alt="hogi_0-1751225253705.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;which can be determined via (*):&lt;BR /&gt;- calculate the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Median()&lt;/FONT&gt; of the values&lt;/P&gt;
&lt;P&gt;- calculate the difference between the values and the median&lt;/P&gt;
&lt;P&gt;- remove the signs&lt;/P&gt;
&lt;P&gt;- calculate the median&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to calculate MAD for a column, you can use the &lt;FONT face="courier new,courier"&gt;Tables/summary&lt;/FONT&gt;&amp;nbsp;platform:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_1-1751225391676.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/77542iB5FA29A671510F44/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_1-1751225391676.png" alt="hogi_1-1751225391676.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Often, users want to calculate MAD for individual groups.&lt;BR /&gt;But unfortunately, there is no &lt;FONT face="courier new,courier"&gt;Col MAD (values, grouping)&lt;/FONT&gt; function in JSL - &lt;A href="https://community.jmp.com/t5/JMP-Wish-List/Add-normalization-and-robust-statistical-functions-and-matrix/idc-p/582911/highlight/true#M3528" target="_blank"&gt;not yet&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;On the other hand, it's very easy to follow the steps in (*) and calculate MAD "manually" via JSL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );

t0=hptime();

New Column( "MAD",
	Formula( Col Median( Abs( :height - Col Median( :height, :sex ) ), :sex ) )
);

dt &amp;lt;&amp;lt; run formulas();

show((hptime()-t0)/1000000)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But wait - the &lt;FONT face="courier new,courier"&gt;Col Median&lt;/FONT&gt;&amp;nbsp;inside the &lt;FONT face="courier new,courier"&gt;Col Median&lt;/FONT&gt; looks frightening - what if JMP calculates the values again and again with every row()?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Let's check if this is the case - by making the data table larger (6.4Mio rows):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );

For Each( {i}, {1, 2},
	dts = Repeat( {dt}, 400 );
	dt = dt &amp;lt;&amp;lt; Concatenate( dts, );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With the larger data table, it takes several minutes to do the calculation (JMP18.2.1).&lt;BR /&gt;&lt;BR /&gt;An easy trick:&lt;BR /&gt;Split the calculation into 2 calculations:&amp;nbsp;&lt;BR /&gt;- first calculate a column with the grouped median values&lt;/P&gt;
&lt;P&gt;- then calculate MAD&lt;BR /&gt;&lt;BR /&gt;another trick:&lt;BR /&gt;- wait for the next version of JMP ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;are there more tricks?&lt;/P&gt;</description>
      <pubDate>Sun, 29 Jun 2025 20:09:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/m-p/882261#M104618</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-06-29T20:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Fast Way to calculate "nested" Col ... aggregations - like MAD</title>
      <link>https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/m-p/883820#M104793</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/26800"&gt;@hogi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;another trick:&lt;BR /&gt;- wait for the next version of JMP ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I just tried it with the EA version of JMP19 - A significant improvement !&lt;BR /&gt;-&amp;gt; just a few seconds instead of several minutes&lt;BR /&gt;wonderful : )&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jul 2025 06:25:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/m-p/883820#M104793</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-07-08T06:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fast Way to calculate "nested" Col ... aggregations - like MAD</title>
      <link>https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/m-p/887467#M104961</link>
      <description>&lt;P&gt;Next step:&lt;BR /&gt;How to share the knowledge with colleagues - or via the Marketplace?&lt;BR /&gt;&lt;BR /&gt;My idea:&lt;BR /&gt;use JSL to create a Custom Function&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Add Custom Functions(
	New Custom Function(
		"COL",
		"MAD",
		Function( {value, byGroup},
			Col Median( Abs( value - Col Median( value, byGroup ) ), byGroup ) 
		),
		&amp;lt;&amp;lt;Formula Category( "Statistical" )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and share the script as an AddIn ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then every user can use the new col aggregation via:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1752812552776.png" style="width: 634px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/78511iB36DC814E08879CA/image-dimensions/634x317?v=v2" width="634" height="317" role="button" title="hogi_0-1752812552776.png" alt="hogi_0-1752812552776.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;&lt;BR /&gt;Unfortunately: This approach doesn't work : (&lt;BR /&gt;Does anybody find the error?&lt;BR /&gt;&lt;BR /&gt;For debugging, you can use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

Add Custom Functions(
	New Custom Function(
		"COL",
		"Median",
		Function( {value, byGroup},
			Col Median( value, byGroup )
		),
		&amp;lt;&amp;lt;Formula Category( "Statistical" )
	)
);

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

New Column( "my COL MEDIAN", Formula( COL:Median( :height, :sex ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;on my system (JMP 18.2.0 &amp;amp; JMP 19 EA 9) , the result looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_1-1752673972482.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/78359i9DDF3E6A0C6735EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_1-1752673972482.png" alt="hogi_1-1752673972482.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;does it take the value of the first row?&lt;BR /&gt;- and use it for "F" , not having any value for "M"?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jul 2025 21:24:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/m-p/887467#M104961</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-07-18T21:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Fast Way to calculate "nested" Col ... aggregations - like MAD</title>
      <link>https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/m-p/888083#M105027</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1643"&gt;@Jasean&lt;/a&gt;&amp;nbsp;for providing the solution::)&lt;/img&gt;&lt;BR /&gt;&lt;BR /&gt;add &lt;FONT face="courier new,courier"&gt;Expr&lt;/FONT&gt; to protect the arguments of the function from being evaluated:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1752872492819.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/78560i02A6CD10C4B99229/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1752872492819.png" alt="hogi_0-1752872492819.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;PRE&gt;&lt;CODE class=" language-jsl"&gt;Add Custom Functions(
	New Custom Function(
		"COL",
		"MAD",
		Function( {value, byGroup},
			Col Median( Abs( value - Col Median( value, byGroup ) ), byGroup ) 
		),
		&amp;lt;&amp;lt;Formula Category( "Statistical" )
	)
);

New Column( "Col MAD",
	Formula( COL:MAD( Expr( :height ), Expr( :sex ) ) )
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;cool!&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jul 2025 21:24:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/m-p/888083#M105027</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-07-18T21:24:59Z</dc:date>
    </item>
  </channel>
</rss>

