<?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: Slope Calculation and Compilation for Multiple Cases with Varying Numbers of Observations in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42891#M24876</link>
    <description>&lt;P&gt;A script could extract the estimates, too, using several different techniques. The common iteration approach becomes cumbersome due to the By groups but can be straight-forward, if only brute force. A more elegant solution would use a single XPath query on the report display tree to retrieve all of thee slopes as a vector. I don't have time right now to research the exact syntax but it would be easy, details aside. Something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;plat &amp;lt;&amp;lt; XPath( "//NumberColBox[NumberColBoxHeader=\!"Estimate\!"]" ) &amp;lt;&amp;lt; Get( 2 );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 04 Aug 2017 18:19:00 GMT</pubDate>
    <dc:creator>Mark_Bailey</dc:creator>
    <dc:date>2017-08-04T18:19:00Z</dc:date>
    <item>
      <title>Slope Calculation and Compilation for Multiple Cases with Varying Numbers of Observations</title>
      <link>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42882#M24869</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I know that the topic of linear slope calculation has been discussed before but I could not find an efficient way to create a tabulated output of Slopes for a set of Cases (i.e. Patients) for which I have varying numbers of obervations as a function of time.&lt;/P&gt;&lt;P&gt;Here is a screen shot of the data (mock; the actual file is attached):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Mock data for SLOPE calculation" style="width: 562px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/7083i60BA9BD792C1BC98/image-size/large?v=v2&amp;amp;px=999" role="button" title="SLOPE_mock_data.PNG" alt="Mock data for SLOPE calculation" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Mock data for SLOPE calculation&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Following the advice of previous discussions in this board, I used the Fit Y by X (Change in Measure by Time) using Patient_ID as By variable, and plotting a linear fit with intercept constrains to 0:&lt;/P&gt;&lt;P&gt;Ouput: 5 analyses identical to the one below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SLOPE_mock_Plot.PNG" style="width: 495px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/7084iE49A0CFD9E138EA0/image-size/large?v=v2&amp;amp;px=999" role="button" title="SLOPE_mock_Plot.PNG" alt="SLOPE_mock_Plot.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where I'm stuck is how to collect the Estimate of the Slope into a new table that would look like:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Patient_ID&lt;/TD&gt;&lt;TD&gt;Slope&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AAA&lt;/TD&gt;&lt;TD&gt;m1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;BBB&lt;/TD&gt;&lt;TD&gt;m2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CCC&lt;/TD&gt;&lt;TD&gt;m3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DDD&lt;/TD&gt;&lt;TD&gt;m4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;EEE&lt;/TD&gt;&lt;TD&gt;m5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion would be welcome: I'm not attached to the original data format or the analysis method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:00:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42882#M24869</guid>
      <dc:creator>sornasst</dc:creator>
      <dc:date>2017-08-04T17:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: Slope Calculation and Compilation for Multiple Cases with Varying Numbers of Observations</title>
      <link>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42884#M24870</link>
      <description>&lt;P&gt;This code will do the trick. &amp;nbsp;The "secret" is to look at the underlying tree structure of the output, converted to a report.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = data table("SLOPE_Calculation_mock_data");

bv = dt &amp;lt;&amp;lt; Bivariate(
	Y( :Change in Measure ),
	X( :Time ),
	Fit Line( {Line Color( {213, 72, 87} )} ),
	By( :Patient_ID )
);

// Figure out how many patients there are
dtab = dt &amp;lt;&amp;lt; Tabulate(
	Show Control Panel( 0 ),
	Add Table( Row Table( Grouping Columns( :Patient_ID ) ) ),
	invisible
);

pdt = dtab &amp;lt;&amp;lt; Make Into Data Table;

np = nrows(pdt);
patient_list = pdt:Patient_ID &amp;lt;&amp;lt; get values;
dtab &amp;lt;&amp;lt; close window;
pdt &amp;lt;&amp;lt; new column("Slope", numeric, continuous);

bvrep = bv &amp;lt;&amp;lt; report;
//bvrep &amp;lt;&amp;lt; show tree structure;	// Used to get underlying structure

for (i = 1, i &amp;lt;= np, i++,
	parameter_estimates = bvrep[i][numbercolbox(7)] &amp;lt;&amp;lt; get;
	one_slope = parameter_estimates[2];
	pdt:Slope[i] = one_slope;
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:30:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42884#M24870</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-08-04T17:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Slope Calculation and Compilation for Multiple Cases with Varying Numbers of Observations</title>
      <link>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42886#M24872</link>
      <description>&lt;P&gt;You discovered the &lt;STRONG&gt;By&lt;/STRONG&gt; role group the data for separate regression analysis. (I hope that you know to press and hold the Ctrl key before clicking the red triangle and selecting the Fit Line command!) Now right-click on the Parameter Estimates table and select Make Combined Data Table.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:42:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42886#M24872</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-08-04T17:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Slope Calculation and Compilation for Multiple Cases with Varying Numbers of Observations</title>
      <link>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42888#M24873</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for your quick reply: it is what I was looking for with the exception that the "retrieval" of the parameter_estimate from the multi plot report does not work because the NumberColBox (7) only works for the first plot, the following plots have their corresponding NumberColBox 23, 37 and so on.&lt;/P&gt;&lt;P&gt;I'm not sure how to iterate through the NumberColBox call.&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:44:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42888#M24873</guid>
      <dc:creator>sornasst</dc:creator>
      <dc:date>2017-08-04T17:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Slope Calculation and Compilation for Multiple Cases with Varying Numbers of Observations</title>
      <link>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42889#M24874</link>
      <description>&lt;P&gt;Thanks: I always forget about this very neat feature&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:45:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42889#M24874</guid>
      <dc:creator>sornasst</dc:creator>
      <dc:date>2017-08-04T17:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Slope Calculation and Compilation for Multiple Cases with Varying Numbers of Observations</title>
      <link>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42891#M24876</link>
      <description>&lt;P&gt;A script could extract the estimates, too, using several different techniques. The common iteration approach becomes cumbersome due to the By groups but can be straight-forward, if only brute force. A more elegant solution would use a single XPath query on the report display tree to retrieve all of thee slopes as a vector. I don't have time right now to research the exact syntax but it would be easy, details aside. Something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;plat &amp;lt;&amp;lt; XPath( "//NumberColBox[NumberColBoxHeader=\!"Estimate\!"]" ) &amp;lt;&amp;lt; Get( 2 );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Aug 2017 18:19:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42891#M24876</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-08-04T18:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Slope Calculation and Compilation for Multiple Cases with Varying Numbers of Observations</title>
      <link>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42892#M24877</link>
      <description>&lt;P&gt;Check the tree structure and JMP version. &amp;nbsp;My code works in JMP 11.2.1, 12.2.0 and 13.1.0. &amp;nbsp;Sometimes there are differences in the underlying structures when going from one version to another. &amp;nbsp;If you see a regular pattern in the number col boxes (e.g. 7, 22, 37, 52, 67) you can build that into the loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 18:30:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Slope-Calculation-and-Compilation-for-Multiple-Cases-with/m-p/42892#M24877</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-08-04T18:30:50Z</dc:date>
    </item>
  </channel>
</rss>

