<?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 area under the curve by integration then populate the result in a new column. in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/calculate-area-under-the-curve-by-integration-then-populate-the/m-p/615040#M81485</link>
    <description>&lt;P&gt;Try checking out how the formula JMP generates does look like, it will most likely replace your time with :time so use different name for the variable and inside expression than columns in your data table (and possibly wrap it inside As Constant())&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;As Constant(
	resp = Expr(a * a);
	area = Integrate(resp, a, Col Min(:time), Col Max(:time));
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 21 Mar 2023 17:18:23 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-03-21T17:18:23Z</dc:date>
    <item>
      <title>calculate area under the curve by integration then populate the result in a new column.</title>
      <link>https://community.jmp.com/t5/Discussions/calculate-area-under-the-curve-by-integration-then-populate-the/m-p/615023#M81484</link>
      <description>&lt;P&gt;In this example datatable, response is defined by fomula:&amp;nbsp; response = time*time&lt;/P&gt;&lt;P&gt;I would like to calculate "area under the curve" (AUC) by integration using the fomula defined in the response column and the time range defined in the :time column,&amp;nbsp;then populate the result in a new column in the datatable (by "populate" I mean all rows have the value of the calculated AUC).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I can use the following script to calculate the AUC, and the result of area is 41333.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;resp = Expr (time * time);

area = Integrate (resp, time, 10, 50);

show (area);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, when I tried to populate the AUC result (all rows have the value of 41333)&lt;SPAN&gt;&amp;nbsp;in the :Integrate column&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;by using formula:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Integrate( :response, :time, Col Maximum( :time ), Col Minimum( :time ) )&lt;/P&gt;&lt;P&gt;instead of populating the result 41333 , the formula calculated the result based on the defined&amp;nbsp;value of : time in each row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the correct way to write the formula so that the :Integrate column is populated with the result 41333?&lt;/P&gt;&lt;P&gt;I know I could use JSL to create a new datatable and then join the result but would prefer to do this within the same datatable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&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="GroupSquareWolf_0-1679416641928.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/51343i47B15125FBF81FE5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GroupSquareWolf_0-1679416641928.png" alt="GroupSquareWolf_0-1679416641928.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:59:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/calculate-area-under-the-curve-by-integration-then-populate-the/m-p/615023#M81484</guid>
      <dc:creator>GroupSquareWolf</dc:creator>
      <dc:date>2023-06-10T23:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: calculate area under the curve by integration then populate the result in a new column.</title>
      <link>https://community.jmp.com/t5/Discussions/calculate-area-under-the-curve-by-integration-then-populate-the/m-p/615040#M81485</link>
      <description>&lt;P&gt;Try checking out how the formula JMP generates does look like, it will most likely replace your time with :time so use different name for the variable and inside expression than columns in your data table (and possibly wrap it inside As Constant())&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;As Constant(
	resp = Expr(a * a);
	area = Integrate(resp, a, Col Min(:time), Col Max(:time));
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Mar 2023 17:18:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/calculate-area-under-the-curve-by-integration-then-populate-the/m-p/615040#M81485</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-03-21T17:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: calculate area under the curve by integration then populate the result in a new column.</title>
      <link>https://community.jmp.com/t5/Discussions/calculate-area-under-the-curve-by-integration-then-populate-the/m-p/615213#M81498</link>
      <description>&lt;P&gt;What if the expression used by Integrate needs to be extracted from the formula in a column, for example to Integrate using a formula from a polynomial fit.&lt;/P&gt;&lt;P&gt;In the table below, the formula in the predictor column would use&amp;nbsp;&amp;nbsp;:time and :response. Is there a quick syntax to replace the column names with new variables?&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="GroupSquareWolf_0-1679436129378.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/51369iE64A7D6BF48830D5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GroupSquareWolf_0-1679436129378.png" alt="GroupSquareWolf_0-1679436129378.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 22:06:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/calculate-area-under-the-curve-by-integration-then-populate-the/m-p/615213#M81498</guid>
      <dc:creator>GroupSquareWolf</dc:creator>
      <dc:date>2023-03-21T22:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: calculate area under the curve by integration then populate the result in a new column.</title>
      <link>https://community.jmp.com/t5/Discussions/calculate-area-under-the-curve-by-integration-then-populate-the/m-p/615282#M81502</link>
      <description>&lt;P&gt;I wouldn't use formulas if you just want to replicate same value to each row (in most cases it is better to use &amp;lt;&amp;lt; Set Each Value in cases like this).&lt;/P&gt;
&lt;P&gt;I'm not sure if there is any quick syntax to replace column names with new variables, but char+substitute+parse+expressions is one option&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(4),
	Compress File When Saved(1),
	New Column("t", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4])),
	New Column("r", Numeric, "Continuous", Format("Best", 12), Formula(:t ^ 2))
);

dt &amp;lt;&amp;lt; New Column("i", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(
	f = Eval Expr(Expr(Parse(Substitute(Char(Column(dt, "r") &amp;lt;&amp;lt; get formula), ":", ""))));
	Integrate(f, t, Col Min(:t), Col Max(:t));
));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2023 06:34:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/calculate-area-under-the-curve-by-integration-then-populate-the/m-p/615282#M81502</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-03-22T06:34:40Z</dc:date>
    </item>
  </channel>
</rss>

