<?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: Estimate inflection point for 2 linear lines in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890284#M351776</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442038"&gt;@PamG&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The Hessian matrix is singular so I do not get parameter estimates.&amp;nbsp; I am not sure the code I have written for linear model is correct.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thank you. In the future, key information like this should be in your first message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This discusses the error message that says the Hessian is singular:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/Problem-in-Proc-NLIN-The-approximate-Hessian-is-singular/td-p/136949" target="_blank"&gt;https://communities.sas.com/t5/Statistical-Procedures/Problem-in-Proc-NLIN-The-approximate-Hessian-is-singular/td-p/136949&lt;/A&gt;&amp;nbsp;There may be other similar discussions here in the SAS communities, and you should search for them.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Aug 2023 19:39:29 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-08-21T19:39:29Z</dc:date>
    <item>
      <title>Estimate inflection point for 2 linear lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890268#M351768</link>
      <description>&lt;P&gt;I have&amp;nbsp; a data where the slope changes at&amp;nbsp; a certain point.&amp;nbsp; How do you find that&amp;nbsp; point of inflection for the two linear lines?&amp;nbsp; I think PROC NLIN would work but I can't get it to run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample code is given below as I cannot share my data.&amp;nbsp; The point of inflection is 50.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;DATA data1;
do i=1 to 1000;
x=rand("Integer", 1, 50);
Y=3 + 6*x + rannor(345);
drop i;
OUTPUT;
end;
RUN;

DATA data2;
do i=1 to 1000;
x=rand("Integer", 50, 100);
Y=2 + 8*x + rannor(345);
drop i;
OUTPUT;
end;
RUN;

data full; set data1 data2;run;

proc nlin data=full;
&amp;nbsp; &amp;nbsp;parms alpha1=.45 beta1=.05 alpha2=.45 beta2=.05;
x0=5*beta1/alpha1;
&amp;nbsp;model y = (x &amp;lt;x0)*(alpha1+beta1*x) +
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(x&amp;gt;=x0)*(alpha2+beta2*x);
FILE log;put&amp;nbsp; / x0=&amp;nbsp; ;&amp;nbsp;
output out=b predicted=yp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 21 Aug 2023 19:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890268#M351768</guid>
      <dc:creator>PamG</dc:creator>
      <dc:date>2023-08-21T19:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Estimate inflection point for 2 linear lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890275#M351770</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I think PROC NLIN would work but I can't get it to run.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What is wrong with your code?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 19:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890275#M351770</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-21T19:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Estimate inflection point for 2 linear lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890278#M351772</link>
      <description>&lt;P&gt;The Hessian matrix is singular so I do not get parameter estimates.&amp;nbsp; I am not sure the code I have written for linear model is correct.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 19:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890278#M351772</guid>
      <dc:creator>PamG</dc:creator>
      <dc:date>2023-08-21T19:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Estimate inflection point for 2 linear lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890284#M351776</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442038"&gt;@PamG&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The Hessian matrix is singular so I do not get parameter estimates.&amp;nbsp; I am not sure the code I have written for linear model is correct.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thank you. In the future, key information like this should be in your first message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This discusses the error message that says the Hessian is singular:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/Problem-in-Proc-NLIN-The-approximate-Hessian-is-singular/td-p/136949" target="_blank"&gt;https://communities.sas.com/t5/Statistical-Procedures/Problem-in-Proc-NLIN-The-approximate-Hessian-is-singular/td-p/136949&lt;/A&gt;&amp;nbsp;There may be other similar discussions here in the SAS communities, and you should search for them.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 19:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890284#M351776</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-21T19:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Estimate inflection point for 2 linear lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890286#M351777</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442038"&gt;@PamG&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your only interest is to know about the inflection point ,&lt;/P&gt;
&lt;P&gt;then you can use PROC UCM (SAS/ETS) for structural break detection in a univariate time series.&lt;/P&gt;
&lt;P&gt;I use your variable X as a time indicator. This is possible because in your sample data the X-values are equally spaced (fixed width interval). &lt;BR /&gt;Not sure how close X is to a real time series in your actual data (?).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA data1;
do i=1 to 1000;
x=rand("Integer", 1, 50);
Y=3 + 6*x + rannor(345);
drop i;
OUTPUT;
end;
RUN;

DATA data2;
do i=1 to 1000;
x=rand("Integer", 50, 100);
Y=2 + 8*x + rannor(345);
drop i;
OUTPUT;
end;
RUN;

data full; set data1 data2; run;
proc sort data=full; by x; run;

proc sgplot data=full;
  scatter x=x y=y;
run;

/* Accumulating Transactional Data into Time Series Data   */
/* Goal is to get Only 1 observation per unique value of X */
proc timeseries data=full out=tsfull;
   id x         interval=day
                accumulate=median
                setmiss=0
                ;
   var y;
run;

proc sgplot data=tsfull;
  scatter x=x y=y;
run;

ods trace off;
/* Detection of Level Shift by unobserved components model (UCM).                               */
/* (The UCMs are also called structural models in the time series literature.)                  */
/* You can check for breaks in the level by using the CHECKBREAK option in the LEVEL statement. */ 
/* The following statements fit a simple locally constant level plus constant slope             */
/* plus error model to the series:                                                              */ 
ODS EXCLUDE EstimationSpan ForecastSpan InitialParameters FitSummary
            ParameterEstimates FitStatistics ComponentSignificance
            TrendInformation Forecasts ForecastsOnlyPlot ;
ODS OUTPUT OutlierSummary=work.OutlierSummary;
proc ucm data=tsfull;
   id x interval=day;
   model y;
   irregular;
/* The fitted trend is nearly linear,                                          */ 
/* So I fix fix the level and/or slope variance components to zero             */
/* (via the VARIANCE=0 and NOEST options on the LEVEL and/or SLOPE statements) */
   level variance=0 noest /* plot=smooth */ checkbreak;
   slope variance=0 noest;
  *estimate;
  *forecast plot=decomp;
run;

data _NULL_;
 set work.OutlierSummary;
 file print;
 put 'inflection point is at ' time= 12.;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;BR,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 19:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890286#M351777</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-08-21T19:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Estimate inflection point for 2 linear lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890292#M351779</link>
      <description>&lt;P&gt;On top of PROC UCM post above ,&lt;/P&gt;
&lt;P&gt;see also :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Segmented regression models in SAS &lt;BR /&gt;By Rick Wicklin on The DO Loop December 14, 2020&lt;BR /&gt;&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;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 19:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890292#M351779</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-08-21T19:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Estimate inflection point for 2 linear lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890294#M351781</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442038"&gt;@PamG&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have&amp;nbsp; a data where the slope changes at&amp;nbsp; a certain point.&amp;nbsp; How do you find that&amp;nbsp; point of inflection for the two linear lines? &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;lt;Pendantic mode=on&amp;gt;&lt;/P&gt;
&lt;P&gt;"Linear Lines" have no inflection point where the slope changes. Curves may.&lt;/P&gt;
&lt;P&gt;&amp;lt;Pendatic mode=off&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you assuming both of your curves have inflection points at the same value? That may be pretty broad assumption.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you using a different definition of inflection other than a point on the curve where the slope changes sign?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, if your data is so sensitive that a group of x,y pairs with no other identification causes concerns then perhaps you shouldn't be asking any questions on an open forum.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 20:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890294#M351781</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-21T20:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Estimate inflection point for 2 linear lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890300#M351784</link>
      <description>Thanks Koen. I do not have a time series data and I do not have a jump in the line. I am so sorry but I do not know how to create sample datasets to show continuous lines but with different slopes. I have (y,x) points and I would like to know where the joint point is that has no breaks.</description>
      <pubDate>Mon, 21 Aug 2023 20:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890300#M351784</guid>
      <dc:creator>PamG</dc:creator>
      <dc:date>2023-08-21T20:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Estimate inflection point for 2 linear lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890367#M351809</link>
      <description>&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;&lt;BR /&gt;&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;</description>
      <pubDate>Tue, 22 Aug 2023 11:37:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890367#M351809</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-08-22T11:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: Estimate inflection point for 2 linear lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890454#M351859</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442038"&gt;@PamG&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option: Try &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_fastclus_overview.htm" target="_blank" rel="noopener"&gt;PROC FASTCLUS&lt;/A&gt; to get a first estimate of the point of inflection and then use &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_rreg_overview.htm" target="_blank" rel="noopener"&gt;PROC ROBUSTREG&lt;/A&gt; for fine-tuning (see the proportions of outliers in the "Diagnostic Summary" table of the output) and estimation of the regression coefficients.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fastclus data=full out=clust maxclusters=2 maxiter=100;
var x y;
run;

proc means data=clust;
class cluster;
var x;
run;

proc sort data=clust;
by cluster;
run;

proc robustreg data=clust method=lts seed=2718;
by cluster;
model y=x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Aug 2023 18:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Estimate-inflection-point-for-2-linear-lines/m-p/890454#M351859</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-08-22T18:38:20Z</dc:date>
    </item>
  </channel>
</rss>

