<?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: Calculation a p-value in a data table (regression) using row formulae in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Calculation-a-p-value-in-a-data-table-regression-using-row/m-p/607663#M80930</link>
    <description>&lt;P&gt;I think you can get what you want from the Linear Regression() function.&amp;nbsp; Take a look in the Scripting Guide for the definition and example of how to use it.&amp;nbsp; Below, I created 2 new columns, "New Slope" and "PValue".&amp;nbsp; I set the format for the PValue column to "PVALUE".&amp;nbsp; I then set the formula for the PValue column to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() &amp;gt; 7,
	dt = Current Data Table();
	x = dt[Index( Row() - 7, Row() ), 2];
	y = dt[Index( Row() - 7, Row() ), 3];
	{Estimates, Std_Error, Diagnostics} = Linear Regression( y, x );
	:New Slope[Row()] = estimates[2];
	diagnostics["p_value"][1];
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the display&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1677798048185.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50681i81A9827F58D6DCCF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1677798048185.png" alt="txnelson_0-1677798048185.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() &amp;gt; 7,
	dt = Current Data Table();
	x = dt[Index( Row() - 7, Row() ), 2];
	y = dt[Index( Row() - 7, Row() ), 3];
	{Estimates, Std_Error, Diagnostics} = Linear Regression( y, x );
	:new slope[Row()] = estimates[2];
	diagnostics["p_value"][1];
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2023 23:06:15 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2023-03-02T23:06:15Z</dc:date>
    <item>
      <title>Calculation a p-value in a data table (regression) using row formulae</title>
      <link>https://community.jmp.com/t5/Discussions/Calculation-a-p-value-in-a-data-table-regression-using-row/m-p/607578#M80920</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Background: Suppose I have rows of x, y data (SN_C, Value [Sigma Units]) as shown in attached file but also pasted below.&amp;nbsp;&lt;/STRONG&gt;&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="fat_angus_1-1677788506229.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50676iC877B75236D8FD93/image-size/medium?v=v2&amp;amp;px=400" role="button" title="fat_angus_1-1677788506229.png" alt="fat_angus_1-1677788506229.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Slope_8 is calculated from the previous 8 [x.y] values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to compare the slope_8 value to the null hypothesis for linear regression (slope =0) and provide a p-value. Is there an easy way to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula for the slope 8 was taken from these discussion boards (@txnelson, &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;)and does exactly what I want after I did simple modification to use N=8&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() &amp;gt; 7,
	x = J( 8, 1, 1 ) || :SN_C[Index( Row() - 7, Row() )]`;
	y = :"Value (Sigma Units)"n[Index( Row() - 7, Row() )]`;
	(Inv( x` * x ) * x` * y)[2];
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I know I should know how to do this and my apologies for being too stupid to figure it out. Its been 30 years since I've taken matrix algebra :)&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:32:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculation-a-p-value-in-a-data-table-regression-using-row/m-p/607578#M80920</guid>
      <dc:creator>fat_angus</dc:creator>
      <dc:date>2023-06-08T16:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation a p-value in a data table (regression) using row formulae</title>
      <link>https://community.jmp.com/t5/Discussions/Calculation-a-p-value-in-a-data-table-regression-using-row/m-p/607663#M80930</link>
      <description>&lt;P&gt;I think you can get what you want from the Linear Regression() function.&amp;nbsp; Take a look in the Scripting Guide for the definition and example of how to use it.&amp;nbsp; Below, I created 2 new columns, "New Slope" and "PValue".&amp;nbsp; I set the format for the PValue column to "PVALUE".&amp;nbsp; I then set the formula for the PValue column to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() &amp;gt; 7,
	dt = Current Data Table();
	x = dt[Index( Row() - 7, Row() ), 2];
	y = dt[Index( Row() - 7, Row() ), 3];
	{Estimates, Std_Error, Diagnostics} = Linear Regression( y, x );
	:New Slope[Row()] = estimates[2];
	diagnostics["p_value"][1];
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the display&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1677798048185.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50681i81A9827F58D6DCCF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1677798048185.png" alt="txnelson_0-1677798048185.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Row() &amp;gt; 7,
	dt = Current Data Table();
	x = dt[Index( Row() - 7, Row() ), 2];
	y = dt[Index( Row() - 7, Row() ), 3];
	{Estimates, Std_Error, Diagnostics} = Linear Regression( y, x );
	:new slope[Row()] = estimates[2];
	diagnostics["p_value"][1];
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 23:06:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculation-a-p-value-in-a-data-table-regression-using-row/m-p/607663#M80930</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-03-02T23:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation a p-value in a data table (regression) using row formulae</title>
      <link>https://community.jmp.com/t5/Discussions/Calculation-a-p-value-in-a-data-table-regression-using-row/m-p/607886#M80939</link>
      <description>&lt;P&gt;txnelson... thanks so much. This was exactly what I was looking for. I sincerely appreciate this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 13:11:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculation-a-p-value-in-a-data-table-regression-using-row/m-p/607886#M80939</guid>
      <dc:creator>fat_angus</dc:creator>
      <dc:date>2023-03-03T13:11:10Z</dc:date>
    </item>
  </channel>
</rss>

