<?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: Linear regression that takes into account only error greater than a specific threshold in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494459#M7353</link>
    <description>&lt;P&gt;Do you really mean observations whose residuals are GREATER THAN 5? This is backwards from the usual robust regression technique in which large residuals are downweighted and small residuals are kept. I am not aware of any papers that&amp;nbsp;recommend excluding observations that have small&amp;nbsp;residuals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;IF YOU MEANT LESS THAN 5:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This analysis is a type of robust regression. In SAS, &lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetVersion=14.3&amp;amp;docsetTarget=statug_rreg_syntax.htm&amp;amp;locale=en" target="_self"&gt;the ROBUSTREG procedure&lt;/A&gt; supports four different robust regression algorithms.&lt;/P&gt;
&lt;P&gt;The process of downweighting large residuals is known as iteratively reweighted least squares, and it is supported by &lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_rreg_details01.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;the M estimation method in PROC ROBUSTREG.&lt;/A&gt;&amp;nbsp;The main idea is to fit a weighted least squares estimate to the data, initially with each observation receiving equal weight. After the initial fit,&amp;nbsp;observations that have large residuals are downweighted&amp;nbsp;by applying a weight function. PROC ROBUSTREG supports 10 weight functions. I suggest you start with the default, but if you really want a "hard" cuttoff&amp;nbsp;(all or nothing weights) then you can choose the WEIGHTFUNCTION=TALWORTH(5) option, which applies zero weights to residuals whose magnitudes that are greater than 5 units.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;IF YOU MEANT&amp;nbsp;GREATER THAN 5:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You can use PROC NLIN in SAS to construct any iteratively reweighted least squares algorithm. &lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_nlin_examples02.htm&amp;amp;docsetVersion=14.2&amp;amp;locale=en" target="_self"&gt;There is an example in the doc&lt;/A&gt;&amp;nbsp;that you can follow. You would modify the statement that sets the weight. It might look something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if abs(resid)&amp;lt;=5 then _weight_=0;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;else _weight_=resid;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have to be frank: it's not clear to me that this model will converge. I think I can construct data for which this process&amp;nbsp;will alternate between two solutions and never converge.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Sep 2018 12:20:12 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2018-09-11T12:20:12Z</dc:date>
    <item>
      <title>Linear regression that takes into account only error greater than a specific threshold</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494275#M7345</link>
      <description>&lt;P&gt;I have a data in the form&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Sales&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Is_Discounted&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create&amp;nbsp; a linear regression such that only error greater than absolute(5) is used to build model that predicts sales. So any error in the range [-5,5] is considered as zero error. Could you please provide the code or reference to do this? Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 19:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494275#M7345</guid>
      <dc:creator>roushankumar</dc:creator>
      <dc:date>2018-09-10T19:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Linear regression that tales into account error greater than a specific threshold</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494283#M7346</link>
      <description>&lt;P&gt;In your data set, change numbers between -5 and +5 to zero.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 19:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494283#M7346</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-10T19:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Linear regression that tales into account error greater than a specific threshold</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494290#M7347</link>
      <description>&lt;P&gt;Thanks! If I set sales between -5 and +5 to zero in my training data would it be the same as finding the best fitting line such that minimal errors are not counted? Please explain.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 19:57:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494290#M7347</guid>
      <dc:creator>roushankumar</dc:creator>
      <dc:date>2018-09-10T19:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Linear regression that tales into account error greater than a specific threshold</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494292#M7348</link>
      <description>&lt;P&gt;They want residuals to be between -5 and 5. Not sure how that affects the regression, except in terms of minimization which means fiddling with the algorithms under the hood, so to speak. I've never heard of this&amp;nbsp;type of regression but it's possible technically. Statistically not sure if it's valid.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;In your data set, change numbers between -5 and +5 to zero.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 20:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494292#M7348</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-10T20:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Linear regression that tales into account error greater than a specific threshold</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494294#M7349</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/231315"&gt;@roushankumar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks! If I set sales between -5 and +5 to zero in my training data would it be the same as finding the best fitting line such that minimal errors are not counted? Please explain.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I didn't read your original problem statement as carefully as I should have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, you'd have to create your own regression algorithm to do this.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 20:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494294#M7349</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-10T20:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Linear regression that tales into account error greater than a specific threshold</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494297#M7350</link>
      <description>&lt;P&gt;I have done this several times in open source platforms but I am new to SAS and haven't been able to find a way here. Such customized models have helped me model cases where 'you want to stabilize your model further' or 'you would rather have your predictions greater than actuals rather than lower'.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 20:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494297#M7350</guid>
      <dc:creator>roushankumar</dc:creator>
      <dc:date>2018-09-10T20:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Linear regression that tales into account error greater than a specific threshold</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494304#M7351</link>
      <description>&lt;P&gt;If you can figure out in your head the proper algorithm, then you can use PROC IML&amp;nbsp;to perform the calculations.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 20:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494304#M7351</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-10T20:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Linear regression that tales into account error greater than a specific threshold</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494310#M7352</link>
      <description>&lt;P&gt;Well, you can call R from SAS IML which may be a good alternative, or for the minimization functions you can try PROC OPTMODEL, for an optimization algorithm, ie fit a non linear model essentially. I don't know enough about those to say if that would work, but a suggestion on where to start looking.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;knows of a better alternative.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 20:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494310#M7352</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-10T20:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Linear regression that takes into account only error greater than a specific threshold</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494459#M7353</link>
      <description>&lt;P&gt;Do you really mean observations whose residuals are GREATER THAN 5? This is backwards from the usual robust regression technique in which large residuals are downweighted and small residuals are kept. I am not aware of any papers that&amp;nbsp;recommend excluding observations that have small&amp;nbsp;residuals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;IF YOU MEANT LESS THAN 5:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This analysis is a type of robust regression. In SAS, &lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetVersion=14.3&amp;amp;docsetTarget=statug_rreg_syntax.htm&amp;amp;locale=en" target="_self"&gt;the ROBUSTREG procedure&lt;/A&gt; supports four different robust regression algorithms.&lt;/P&gt;
&lt;P&gt;The process of downweighting large residuals is known as iteratively reweighted least squares, and it is supported by &lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_rreg_details01.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;the M estimation method in PROC ROBUSTREG.&lt;/A&gt;&amp;nbsp;The main idea is to fit a weighted least squares estimate to the data, initially with each observation receiving equal weight. After the initial fit,&amp;nbsp;observations that have large residuals are downweighted&amp;nbsp;by applying a weight function. PROC ROBUSTREG supports 10 weight functions. I suggest you start with the default, but if you really want a "hard" cuttoff&amp;nbsp;(all or nothing weights) then you can choose the WEIGHTFUNCTION=TALWORTH(5) option, which applies zero weights to residuals whose magnitudes that are greater than 5 units.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;IF YOU MEANT&amp;nbsp;GREATER THAN 5:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You can use PROC NLIN in SAS to construct any iteratively reweighted least squares algorithm. &lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_nlin_examples02.htm&amp;amp;docsetVersion=14.2&amp;amp;locale=en" target="_self"&gt;There is an example in the doc&lt;/A&gt;&amp;nbsp;that you can follow. You would modify the statement that sets the weight. It might look something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if abs(resid)&amp;lt;=5 then _weight_=0;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;else _weight_=resid;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have to be frank: it's not clear to me that this model will converge. I think I can construct data for which this process&amp;nbsp;will alternate between two solutions and never converge.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 12:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/494459#M7353</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-09-11T12:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Linear regression that takes into account only error greater than a specific threshold</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/550348#M7767</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;Could you please help me with the issue here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/proc-hpfengine-fails-to-make-predictions/m-p/550250#M3507" target="_blank"&gt;https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/proc-hpfengine-fails-to-make-predictions/m-p/550250#M3507&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 17:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Linear-regression-that-takes-into-account-only-error-greater/m-p/550348#M7767</guid>
      <dc:creator>roushankumar</dc:creator>
      <dc:date>2019-04-11T17:47:37Z</dc:date>
    </item>
  </channel>
</rss>

