<?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: how do I identify points on the curve?:  where is the slope=0? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/646064#M35993</link>
    <description>&lt;P&gt;The link in my response requires only SAS/STAT and the DATA step. Check out the link.&lt;/P&gt;</description>
    <pubDate>Thu, 07 May 2020 23:25:05 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2020-05-07T23:25:05Z</dc:date>
    <item>
      <title>how do I identify points on the curve?:  where is the slope=0?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/645431#M35977</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have time series data of daily observations for an event.&amp;nbsp; There is one observation per day, and it is always &amp;gt;=0.&lt;/P&gt;&lt;P&gt;I am using proc loess ad/or proc sgplot with a penalised b spline to fit a smooth curve.&lt;/P&gt;&lt;P&gt;I want to identify the points where the curve turns.&amp;nbsp; Ideally, I need to see where the slope=0 and where the slope becomes negative.&lt;/P&gt;&lt;P&gt;Any help greatly appreciated!&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 22:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/645431#M35977</guid>
      <dc:creator>drshashlik</dc:creator>
      <dc:date>2020-05-05T22:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: how do I identify points on the curve?:  where is the slope=0?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/645545#M35982</link>
      <description>&lt;P&gt;Check the current point and previous point, next point 's slope .&lt;/P&gt;
&lt;P&gt;If&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Yt-Yt-1)/(t- t-1)&amp;nbsp; &amp;nbsp; and&amp;nbsp; (Yt+1-Yt)/(t+1 - t)&lt;/P&gt;
&lt;P&gt;have different sign (+ or -) , then t is the point which have 0 slope .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;wrote a blog about it before.&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 11:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/645545#M35982</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-05-06T11:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: how do I identify points on the curve?:  where is the slope=0?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/645546#M35983</link>
      <description>&lt;P&gt;You can use finite-difference approximations to estimate the slope of a nonparametric regression model. See the discussion and example in the article &lt;A href="https://blogs.sas.com/content/iml/2018/07/05/derivatives-nonparametric-regression.html" target="_self"&gt;"Compute derivatives for nonparametric regression models."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 11:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/645546#M35983</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-05-06T11:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: how do I identify points on the curve?:  where is the slope=0?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/645747#M35984</link>
      <description>&lt;P&gt;Here is an example using &lt;STRONG&gt;proc loess&lt;/STRONG&gt; and &lt;STRONG&gt;proc expand&lt;/STRONG&gt; to process consecutive time series observations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc loess data=sashelp.ENSO plots=none;
   model Pressure=Month;
   score ;
   ods output ScoreResults=sr;
run;

proc expand data=sr out=srd;
convert p_pressure=y / transformout=(dif sign movsum 2 = 0 + 1 lead);
run;
&lt;BR /&gt;/* Show the locations of the slope changes (where y = 1) on a graph */
data graph;
set srd;
if y then pp_pressure = p_pressure;
run;

title "Slope changes";
proc sgplot data=graph noautolegend;
scatter x=month y=pressure;
series x=month y=p_pressure;
scatter x=month y=pp_pressure / markerattrs=(symbol=circlefilled color=red);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 644px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39141i57C5B866CFEC77C4/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 22:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/645747#M35984</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-05-06T22:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: how do I identify points on the curve?:  where is the slope=0?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/646053#M35992</link>
      <description>Thank you, i think this looks exactly like what I want. BUT, I don't have access to proc expand. (I'm using EG, but even though proc expand comes up in the options, i get the error message that the procedure was not found.&lt;BR /&gt;Is there a workaround for this problem?&lt;BR /&gt;thanks again!</description>
      <pubDate>Thu, 07 May 2020 22:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/646053#M35992</guid>
      <dc:creator>drshashlik</dc:creator>
      <dc:date>2020-05-07T22:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: how do I identify points on the curve?:  where is the slope=0?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/646064#M35993</link>
      <description>&lt;P&gt;The link in my response requires only SAS/STAT and the DATA step. Check out the link.&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 23:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/646064#M35993</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-05-07T23:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: how do I identify points on the curve?:  where is the slope=0?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/646077#M35994</link>
      <description>Thank you Rick_SAS. I am working through your method, and get this error from this step:&lt;BR /&gt;/* score the model at each time point */&lt;BR /&gt;proc plm restore=SplineModel noprint;&lt;BR /&gt;score data=ScoreData out=ScoreOut; /* Predicted column contains f(x+h) and f(x-h) */&lt;BR /&gt;run;&lt;BR /&gt;WARNING: At least one variable used in the model is not present or has incompatible type in the WORK.SCOREDATA score data set. All computed score variables are set to missing in WORK.SCOREOUT.&lt;BR /&gt;I can't figure out which step has caused this issue.</description>
      <pubDate>Fri, 08 May 2020 01:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/646077#M35994</guid>
      <dc:creator>drshashlik</dc:creator>
      <dc:date>2020-05-08T01:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: how do I identify points on the curve?:  where is the slope=0?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/646155#M35995</link>
      <description>&lt;P&gt;Sorry for the confusion. All I meant is that you don't need to use PROC EXPAND to compute the locations where the derivative of the smoother is zero. I intended for you to use PGStats program, but use a DATA step to compute the derivative. Like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
set Sashelp.Enso;
x = Month;
y = Pressure;
run;

/* Put min and max into macro variables */
proc sql noprint;
  select min(x), max(x) into :min_x, :max_x 
  from Have;
quit;

/* compute derivatives at specified points in interval [min(x), max(x)] */
data ScoreData;
do x = &amp;amp;min_x to &amp;amp;max_x by 0.05;   /* choose the step size wisely */
   output;
end;
run;

ods select none;
proc loess data=Have plots=none;
    model y = x;
    score data=ScoreData;
    ods output ScoreResults=ScoreOut;
run;
ods select all;

/* compute first derivative by using finite difference formula.
  Output locations where the derivative is approximately zero  */
data Deriv0;
set ScoreOut;
Slope = dif(p_y) / dif(x);  /* [f(x) - f(x-dx)] / dx */
SlopePrev = lag(Slope);
if n(SlopePrev) AND sign(SlopePrev) ^= sign(Slope) then output; 
run;

data Combine;
merge Have
      ScoreOut(rename=(x=t p_y=p_t))
      Deriv0(rename=(x=xx p_y=yy));
run;

title "Loess Smoother";
title2 "Values with Zero Derivatives Are Marked";
proc sgplot data=Combine noautolegend;
   scatter x=x y=y;
   series x=t y=P_t / lineattrs=GraphData2;
   scatter x=xx y=yy / markerattrs=(symbol=circlefilled color=red);
   yaxis grid; 
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 May 2020 11:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/646155#M35995</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-05-08T11:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: how do I identify points on the curve?:  where is the slope=0?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/647895#M36030</link>
      <description>&lt;P&gt;For more on this topic, including a complete example, see&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2020/05/13/regression-curve-zero-slope.html" target="_self"&gt;"Find points where a regression curve has zero slope."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2020 18:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-do-I-identify-points-on-the-curve-where-is-the-slope-0/m-p/647895#M36030</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-05-14T18:17:06Z</dc:date>
    </item>
  </channel>
</rss>

