<?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: Calculate Moving R2 in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228393#M45311</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;.&amp;nbsp;What is the function to calculate R2 in JSL? (sorry I am new to JSL scripting and couldn't find it online).&lt;/P&gt;</description>
    <pubDate>Mon, 07 Oct 2019 18:46:00 GMT</pubDate>
    <dc:creator>shasheminassab</dc:creator>
    <dc:date>2019-10-07T18:46:00Z</dc:date>
    <item>
      <title>Calculate Moving R2</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228358#M45308</link>
      <description>&lt;P&gt;How can I calculate R2 between two variables (i.e. columns) in a moving window (e.g., 10 pairs of data at a time)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sina&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 16:32:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228358#M45308</guid>
      <dc:creator>shasheminassab</dc:creator>
      <dc:date>2019-10-07T16:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Moving R2</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228381#M45310</link>
      <description>&lt;P&gt;See this discussion about &lt;A href="https://community.jmp.com/t5/Discussions/Calculating-linear-regression-slope-in-formula/m-p/36411" target="_self"&gt;performing linear regression in a column formula&lt;/A&gt;. This approach could be extended to obtain R square or other results.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 18:06:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228381#M45310</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2019-10-07T18:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Moving R2</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228393#M45311</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;.&amp;nbsp;What is the function to calculate R2 in JSL? (sorry I am new to JSL scripting and couldn't find it online).&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 18:46:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228393#M45311</guid>
      <dc:creator>shasheminassab</dc:creator>
      <dc:date>2019-10-07T18:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Moving R2</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228406#M45313</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/16275"&gt;@shasheminassab&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;take a look at this:&lt;BR /&gt;&lt;A href="http://www.pega-analytics.co.uk/blog/linear-regression-matrix-form/" target="_self"&gt;http://www.pega-analytics.co.uk/blog/linear-regression-matrix-form/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 19:43:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228406#M45313</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2019-10-07T19:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Moving R2</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228409#M45316</link>
      <description>&lt;P&gt;I understand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example based on the Big Class data table in the Sample Data folder. It fits a moving linear regression with a span of 5. It returns the R square value in each row. You can run this script to see how it works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// example creates a new column with a moving R square with a span of 5
// for regression of :weight versus :height
dt &amp;lt;&amp;lt; New Column( "Moving R Square",
	Numeric,
	Continuous,
	Formula(
		If( Row() &amp;gt; 2 &amp;amp; Row() &amp;lt; (N Row()-1),
			x = J( 5, 1, 1 ) || :height[Index( Row() - 2, Row() + 2 )]`;
			y = :weight[Index( Row() - 2, Row() + 2 )]`;
			sst = Sum( (y - Mean( y )) ^ 2 );
			b = (Inv( x` * x ) * x` * y);
			yhat = x * b;
			sse = Sum( (y - yhat) ^ 2 );
			(sst-sse) / sst;
		,
			Empty()
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can select the part of this script that is within the parentheses after the Formula argument and past that expression into a new column formula in your data table, then change the column names to match your X and Y data columns.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 20:41:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/228409#M45316</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2019-10-07T20:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Moving R2</title>
      <link>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/229197#M45457</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/958"&gt;@ron_horne&lt;/a&gt;&amp;nbsp;. This was very helpful!!&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 21:27:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Calculate-Moving-R2/m-p/229197#M45457</guid>
      <dc:creator>shasheminassab</dc:creator>
      <dc:date>2019-10-13T21:27:12Z</dc:date>
    </item>
  </channel>
</rss>

