<?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: Change of slope in a curve in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/902772#M44751</link>
    <description>Rick,&lt;BR /&gt;Agree. &lt;BR /&gt;It is all depend on OP .&lt;BR /&gt;If OP were not required too much , I think it is more than suffice .</description>
    <pubDate>Mon, 13 Nov 2023 11:43:33 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-11-13T11:43:33Z</dc:date>
    <item>
      <title>Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/900999#M44658</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I have a clustered count data where I have counts and denominator within each cluster for a period of 80 months. In order to examine the effect of month on the rate I fitted a random intercept Poisson model. However, the relationship is very non-linear as shown in the plot of raw rates below. &lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BayzidurRahman_0-1698813709402.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89291iEF1C55656B82F83A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BayzidurRahman_0-1698813709402.png" alt="BayzidurRahman_0-1698813709402.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Can you please suggest how can I identify the time points at which the slope of the curve is changing (turning points)?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 04:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/900999#M44658</guid>
      <dc:creator>BayzidurRahman</dc:creator>
      <dc:date>2023-11-01T04:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901050#M44662</link>
      <description>&lt;A href="https://blogs.sas.com/content/iml/2013/08/28/finite-diff-estimate-maxi.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2013/08/28/finite-diff-estimate-maxi.html&lt;/A&gt;</description>
      <pubDate>Wed, 01 Nov 2023 12:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901050#M44662</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-11-01T12:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901061#M44663</link>
      <description>&lt;P&gt;I don't have a suggestion, but I think your question might be slightly different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your question really "how can I fit a model to this sort of data?".&amp;nbsp; &amp;nbsp;Meaning if you could fit a model to it that you liked, then it would be straight forward to find the points where the slope of the model changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As shown in the blog post linked by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;, there are model-free ways to find local maxima and minima.&amp;nbsp; I think in that context for this sort of data with some noise in it, you would need to think about how to empirically define the point of a slope change aka local min/max aka vertex (?).&amp;nbsp; For example, perhaps think about how many "slope change" points you see on the plot, and then think backwards to a reasonable rule that would help identify those points.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 12:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901061#M44663</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-01T12:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901114#M44669</link>
      <description>&lt;P&gt;By "turning point" do you mean "inflection point" ?&amp;nbsp; &lt;A href="https://en.wikipedia.org/wiki/Inflection_point" target="_blank"&gt;https://en.wikipedia.org/wiki/Inflection_point&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Inflection point has a standard usage but I am afraid "turning point" means nothing to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if "month" is the desired "effect" on rate , not "month of year", then perhaps you need to look at things differently. And if the topic is "month" why does the graph use week for tick marks???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Several of the Timeseries related procedures deal with "seasonality" such as month in different years. Perhaps that is where you need to look.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 16:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901114#M44669</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-11-01T16:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901127#M44670</link>
      <description>&lt;P&gt;Perhaps I misunderstood, but I was interpreting "turning point" as being a local minimum or maximum, where the sign of the slope changes.&amp;nbsp; &amp;nbsp;I haven't heard this term before, but an image on the wikipedia page you linked to uses "turning point" as a label for local minima and maxima.&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="curve.png" style="width: 701px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89315iCBF7B13BA3E56940/image-size/large?v=v2&amp;amp;px=999" role="button" title="curve.png" alt="curve.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&amp;nbsp; I found a wikipedia page with a definition for turning point, consistent with my guess: "&lt;SPAN&gt;A&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;turning point&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;is a point at which the derivative changes sign."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Stationary_point" target="_blank"&gt;https://en.wikipedia.org/wiki/Stationary_point&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 18:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901127#M44670</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-01T18:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901148#M44671</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;The term "turning point" may not be statistically appropriate. It should be "Change in trend". It is not only month but month of the year. I analysed data with both weekly and monthly resolution and by mistake I put the weekly graph. The monthly graph is given below.&lt;BR /&gt;During the period between 2018 and 2022 few intervention happened, whose exact timing is unclear, and they are supposed affect the trend of the rate of medication use. I need to identify those time points. &lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BayzidurRahman_0-1698865105635.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89317i7F488EAF03B6C61B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BayzidurRahman_0-1698865105635.png" alt="BayzidurRahman_0-1698865105635.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 19:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901148#M44671</guid>
      <dc:creator>BayzidurRahman</dc:creator>
      <dc:date>2023-11-01T19:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901151#M44672</link>
      <description>&lt;P&gt;Can you highlight on the plot the points you would want to identify as "change in trend"?&amp;nbsp; Just by eyeballing.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 19:13:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901151#M44672</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-01T19:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901156#M44673</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BayzidurRahman_1-1698868005908.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89319i8B4D9D833E425BB2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BayzidurRahman_1-1698868005908.png" alt="BayzidurRahman_1-1698868005908.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>Wed, 01 Nov 2023 19:46:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901156#M44673</guid>
      <dc:creator>BayzidurRahman</dc:creator>
      <dc:date>2023-11-01T19:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901392#M44677</link>
      <description>&lt;P&gt;One possible solution is to define a piecewise linear regression model.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know the time at which the change occurs, you can solve the problem by using a piecewise linear spline and setting the "knot locations" to be the known times. See&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2017/04/05/nonsmooth-models-spline-effects.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/04/05/nonsmooth-models-spline-effects.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do not know the change points, then you have to solve for them. These are known as segmented regression models. For an example of a single change point, see&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2020/12/14/segmented-regression-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2020/12/14/segmented-regression-sas.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 13:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901392#M44677</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-03T13:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901396#M44678</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I do not know the time points when the changes occur and there are multiple of this. Is it possible to fit a Generalised Additive Model (GAM) to determine the smooth function and then find out the maximas and minimas by taking the derivatives?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 13:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901396#M44678</guid>
      <dc:creator>BayzidurRahman</dc:creator>
      <dc:date>2023-11-03T13:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901434#M44679</link>
      <description>&lt;UL class="lia-list-style-type-square"&gt;
&lt;LI&gt;Paper SAS456-2017&lt;BR /&gt;Detecting and Adjusting Structural Breaks in Time Series and Panel Data&lt;BR /&gt;Using the SSM Procedure&lt;BR /&gt;Rajesh Selukar, SAS Institute Inc.&lt;BR /&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings17/SAS0456-2017.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings17/SAS0456-2017.pdf&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=7Mrmj-ERrM0" target="_blank"&gt;https://www.youtube.com/watch?v=7Mrmj-ERrM0&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;The above paper also includes a brief review of the structural break detection facilities of other SAS/ETS procedures, such as the ARIMA, AUTOREG, and UCM.&lt;/LI&gt;
&lt;LI&gt;SAS/ETS Examples&lt;BR /&gt;Chow Test for Structural Breaks&lt;BR /&gt;&lt;A href="https://support.sas.com/rnd/app/ets/examples/chow/index.htm" target="_blank"&gt;https://support.sas.com/rnd/app/ets/examples/chow/index.htm&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://en.wikipedia.org/wiki/Chow_test" target="_blank"&gt;https://en.wikipedia.org/wiki/Chow_test&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;SAS/ETS® 15.1 User’s Guide&lt;BR /&gt;The UCM Procedure&lt;BR /&gt;&lt;A href="https://support.sas.com/documentation/onlinedoc/ets/151/ucm.pdf" target="_blank"&gt;https://support.sas.com/documentation/onlinedoc/ets/151/ucm.pdf&lt;/A&gt;&amp;nbsp;(search term : CHECKBREAK)&lt;/LI&gt;
&lt;LI&gt;Applying Data Science&amp;nbsp;&lt;BR /&gt;by Gerhard Svolba&lt;BR /&gt;Chapter 6: Detecting Structural Changes in Longitudinal Data&lt;BR /&gt;Chapter 7 – Detecting Outliers and Level Shifts in Longitudinal Data&lt;BR /&gt;&lt;A href="https://www.sas.com/storefront/aux/en/spba/63165_excerpt.pdf" target="_blank"&gt;https://www.sas.com/storefront/aux/en/spba/63165_excerpt.pdf&lt;/A&gt;&lt;BR /&gt;I like using&amp;nbsp;the ADAPTIVEREG Procedure for detecting breakpoints and structural breaks (see 6.3 !)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Br, Koen&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 16:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901434#M44679</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-11-03T16:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901442#M44680</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;Is it possible to fit a GAM to determine the smooth function and then find out the maximas and minimas by taking the derivatives?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Yes, it is possible, if that is what you want to do. If you evaluate any model (GAM, loess, spline, MARS,...) at points on a fine, evenly&amp;nbsp;spaced grid for the independent variable, then you can use numerical differentiation to estimate the extrema. See&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2020/05/13/regression-curve-zero-slope.html" target="_blank"&gt;Find points where a regression curve has zero slope - The DO Loop (sas.com)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 16:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901442#M44680</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-03T16:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901443#M44681</link>
      <description>&lt;P&gt;Rajesh gave an excellent presentation to BASUG last year on PROC SSM and PRO UCM.&amp;nbsp; Slides and recording are in our archives:&amp;nbsp;&lt;A href="https://www.basug.org/archives" target="_blank"&gt;https://www.basug.org/archives&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 16:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901443#M44681</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-11-03T16:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901469#M44683</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;Thanks for the link. Can we find the confidence interval of the identified points?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 19:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901469#M44683</guid>
      <dc:creator>BayzidurRahman</dc:creator>
      <dc:date>2023-11-03T19:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901478#M44684</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;Can we find a confidence interval of the identified points?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;You could if you use a segmented regression model or some other rigorous statistical model. But if you fit some smoother to the data and find places where the derivative of the smoother is 0, I don't think you can get a CI automatically from the regression. For one thing, different smoothers will give you different result s. (For example, think about a loess smoother with different smoothing parameters!)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the fit-a-smoother-and-take-derivative method is a heuristic method that doesn't have much statistical theory behind it. If you want something like a confidence interval, you need a parameter in a statistical model.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 19:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901478#M44684</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-03T19:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901485#M44685</link>
      <description>&lt;P&gt;What if we fit a Poisson model with fractional polynomial or spline to generate the smooth function from predicted values? There is an implementation is Stata &lt;A href="https://minerva-access.unimelb.edu.au/items/862e275d-600b-529e-a7e8-4cf7239c1740" target="_blank"&gt;https://minerva-access.unimelb.edu.au/items/862e275d-600b-529e-a7e8-4cf7239c1740&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 19:59:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901485#M44685</guid>
      <dc:creator>BayzidurRahman</dc:creator>
      <dc:date>2023-11-03T19:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901489#M44687</link>
      <description>&lt;P&gt;Again, you could do that. It is just a different kind of smoother. But I don't think any model will enable you get CIs for the turning points.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you might want to discuss the problem with your colleagues or a local statistician. If this is something that you will want to publish or that has clinical implications, you would be wise to think carefully about the scientific validity of the statistical method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you decide on a method and program it in SAS, we can help if you run into coding difficulties.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 20:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/901489#M44687</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-03T20:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/902740#M44747</link>
      <description>&lt;P&gt;You could use A Time Series Decomposition to get TREND component and using Rick blog's DIFF skill to get those special kinks .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input y @@;
x+1;
cards;
5447 5412 5215 4697 4344 5426
5173 4857 4658 4470 4268 4116
4675 4845 4512 4174 3799 4847
4550 4208 4165 3763 4056 4058
5008 5140 4755 4301 4144 5380
5260 4885 5202 5044 5685 6106
8180 8309 8359 7820 7623 8569
8209 7696 7522 7244 7231 7195
8174 8033 7525 6890 6304 7655
7577 7322 7026 6833 7095 7022
7848 8109 7556 6568 6151 7453
6941 6757 6437 6221 6346 5880
;
proc iml;
use have;
read all var {y};
close ;
mdel = 0; trade = 0; year = 0;
period= 0; log = 0; maxit = 100;
update = .; /* use default update method */
line = .; /* use default line search method */
sigmax = 0; /* no upper bound for variances */
back = 100;
opt = mdel || trade || year || period || log || maxit ||
update || line || sigmax || back;
call tsdecomp(cmp,coef,aic) data=y order=2 sorder=0 nar=2
npred=5 opt=opt icmp={1 3} print=1;

trend=cmp[,1];

slope = dif(trend);
sgn = sign(slope);
difSgn = dif(sgn);

create trend var{trend difSgn};
append;
close;
quit;
data want;
merge have trend;
if difSgn in (-2 2) then kink=trend;
run;
proc sgplot data=want;
series x=x y=y/lineattrs=(color=blue);
series x=x y=trend/lineattrs=(color=red);
scatter x=x y=kink/markerattrs=(color=green size=20 symbol=starfilled);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1699854168541.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89694i7DA7A8F9032292A5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1699854168541.png" alt="Ksharp_0-1699854168541.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 05:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/902740#M44747</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-11-13T05:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/902742#M44748</link>
      <description>&lt;P&gt;Here is another function to get TREND component of time series decomposition.&lt;/P&gt;
&lt;P&gt;Try both to see which one is better to fit your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
 set sashelp.stocks(keep=stock date close rename=(close=y));
 if stock='IBM';
run;



proc iml;
use have;
read all var {y};
close ;
call tsbaysea(trend,season,series,adj,abic)
data=y order=2 sorder=1 npred=12 print=2;

slope = dif(trend);
sgn = sign(slope);
difSgn = dif(sgn);

create trend var{trend difSgn};
append;
close;
quit;
data want;
merge have trend;
if difSgn in (-2 2) then kink=trend;
run;
proc sgplot data=want;
series x=date y=y/lineattrs=(color=blue);
series x=date y=trend/lineattrs=(color=red);
scatter x=date y=kink/markerattrs=(color=green size=14 symbol=starfilled);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1699855016946.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89695i9070D493D9F4F712/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1699855016946.png" alt="Ksharp_0-1699855016946.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 05:57:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/902742#M44748</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-11-13T05:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Change of slope in a curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/902771#M44750</link>
      <description>&lt;P&gt;KSharp: Your two examples show the point I was trying to make: the problem is not well-defined if you define the turning points by using a smoother. As you showed, choosing different smoothers will usually result in a different number and location of the turning points.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 11:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-of-slope-in-a-curve/m-p/902771#M44750</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-11-13T11:34:42Z</dc:date>
    </item>
  </channel>
</rss>

