<?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: Finding best window of data in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/698048#M88357</link>
    <description>&lt;P&gt;Turns out our particular problem was far more complicated than we originally realized, so we ended up coding up the processing in python since we're more familiar with that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll flag&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/26800"&gt;@hogi&lt;/a&gt;'s as the solution to close the topic.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Nov 2023 18:57:49 GMT</pubDate>
    <dc:creator>BHarris</dc:creator>
    <dc:date>2023-11-14T18:57:49Z</dc:date>
    <item>
      <title>Finding best window of data</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/692797#M87834</link>
      <description>&lt;P&gt;As a companion to my last question...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to identify the best window in a data table, e.g. from&amp;nbsp;Samples/Data/Functional Data/Weekly Weather Data.jmp, I need to identify the X consecutive lines (moving window) with the highest TMAX by STATION.&amp;nbsp; Not sure whether to use the window with the highest average, or the lowest minimum, so I'd like to know how to do both.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As before, I'm sure there's a way to do this with JSL, but I'd prefer to use a function if possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried a bunch of things with Col Moving Average() and Col Rank() but it somehow feels just out of reach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 05:14:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/692797#M87834</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-11-01T05:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding best window of data</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/692909#M87842</link>
      <description>&lt;P&gt;I must be misunderstanding your question, but it sounds like you just want the column maximum by station - see the last column in the attached and the stored script Tabulating the results.&amp;nbsp; But I suspect you mean something else and I don't understand what you mean by "moving window."&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 11:50:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/692909#M87842</guid>
      <dc:creator>dale_lehman</dc:creator>
      <dc:date>2023-11-01T11:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Finding best window of data</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/694528#M87962</link>
      <description>&lt;P&gt;No, I'm looking to create a column where it has a "1" next to the X-consecutive rows, e.g. 4 consecutive rows, whose minimum value of another column across those 4 rows is the largest.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Nov 2023 23:24:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/694528#M87962</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-11-04T23:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Finding best window of data</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/694556#M87963</link>
      <description>&lt;P&gt;It would be helpful if you could provide an example of the end result of what you are looking for.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2023 03:34:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/694556#M87963</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-11-05T03:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Finding best window of data</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/694588#M87970</link>
      <description>&lt;P&gt;How about combining &lt;STRONG&gt;Col Max&lt;/STRONG&gt; (to find the Peak) with&amp;nbsp;&lt;STRONG&gt;Col Moving Average&lt;/STRONG&gt; (to stretch the search window)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;to mark the peak position, compare individual values with the maximum value&lt;BR /&gt;quick &amp;amp; dirty:&lt;BR /&gt;- maybe: 2 matches&lt;BR /&gt;- maybe [but unlikely]: a wrong match with the max value of another station&lt;/LI&gt;&lt;LI&gt;for&amp;nbsp;&lt;SPAN&gt;&lt;EM&gt;Weekly Weather Data&lt;/EM&gt;, one has to invest some extra effort:&lt;BR /&gt;for every station some weeks are missing&amp;nbsp; - so to search within the correct window, one has to inform Jmp about the missing data via split &amp;amp; stack (works as none of the weeks is completely missing).&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_1-1699198600823.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/58338iE3F67EBA5B2F2059/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_1-1699198600823.png" alt="hogi_1-1699198600823.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;dt = Open( "$SAMPLE_DATA/Functional Data/Weekly Weather Data.jmp" );

half_window_size = 2;

dtsplit = dt &amp;lt;&amp;lt; Split(
	Split By( :week of year ),
	Split( :TAVG ),
	Group( :STATION ),
	Remaining Columns( Drop All )
);

myNames=dt split &amp;lt;&amp;lt; get column names();
myNames= myNames[2::Nitems(myNames)];
dtstack = dtsplit &amp;lt;&amp;lt;
Stack(
	columns(myNames)
);

New Column( "window",Formula(Col Moving Average( :Data, 1, half_window_size, half_window_size, :STATION )));

New Column( "max_window",Formula( Col Maximum( :window, :STATION ) ));

New Column( "marker",Nominal,Formula( :window == :max_window ));

:Label &amp;lt;&amp;lt; Set Data Type(Numeric) &amp;lt;&amp;lt; set name ("week of year");

Graph Builder(
	Variables(
		X( :week of year ),
		Y( :Data ),
		Y( :window, Position( 1 ) ),
		Y( :max_window, Position( 1 ) ),
		Group X( :STATION, N View Levels( 1 )),
		Overlay( :marker )
	),
	Elements(
		Points( X, Y( 1 ), Overlay( 0 ) ),
		Points( X, Y( 2 )),
		Smoother( X, Y( 3 ) )
	)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2023 15:48:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/694588#M87970</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-11-05T15:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Finding best window of data</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/698048#M88357</link>
      <description>&lt;P&gt;Turns out our particular problem was far more complicated than we originally realized, so we ended up coding up the processing in python since we're more familiar with that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll flag&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/26800"&gt;@hogi&lt;/a&gt;'s as the solution to close the topic.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2023 18:57:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-best-window-of-data/m-p/698048#M88357</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-11-14T18:57:49Z</dc:date>
    </item>
  </channel>
</rss>

