<?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: Robust reg sse and mse code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Robust-reg-sse-and-mse-code/m-p/789948#M252870</link>
    <description>&lt;P&gt;You can run a robust regression model by using &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_rreg_toc.htm" target="_self"&gt;the ROBUSTREG procedure&lt;/A&gt; in SAS/STAT software.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the METHOD= option on the PROC ROBUSTREG to specify the method, including METHOD=M, METHOD=S, and METHOD=LTS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best place to start is &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_rreg_gettingstarted.htm" target="_self"&gt;the Getting Started examples in the doc&lt;/A&gt;. There is a GS example for M estimation and for LTS estimation.&amp;nbsp; &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_rreg_examples01.htm" target="_self"&gt;Another example shows a comparison between various methods&lt;/A&gt;, including METHOD=S.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you are learning the procedure, I encourage you to &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_rreg_examples05.htm" target="_self"&gt;use the PLOTS=ALL option to visualize your data by using regression diagnostic plots&lt;/A&gt;. The plots will help you to understand which observations in the data are influential in OLS regression but have been downweighted by the robust estimation methods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding the SSE and MSE statistics, those are non-robust statistics so I don't think PROC ROBUSTREG produces them However, you can use the OUTPUT statement to write the residual values to a data set and then compute the SSE and MSE manually. The denominator for the MSE comes from the relevant entries in the ModelInfo table. For example, the following program shows that the model has p=4 vars (three indep vars, plus the intercept) and n=21 valid observations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Getting Started example from PROC ROBUSTREG doc */
data Stack;
   input  x1 x2 x3 y exp $ @@;
   datalines;
80  27   89  42   e1   80  27   88  37   e2
75  25   90  37   e3   62  24   87  28   e4
62  22   87  18   e5   62  23   87  18   e6
62  24   93  19   e7   62  24   93  20   e8
58  23   87  15   e9   58  18   80  14  e10
58  18   89  14  e11   58  17   88  13  e12
58  18   82  11  e13   58  19   93  12  e14
50  18   89   8  e15   50  18   86   7  e16
50  19   72   8  e17   50  19   79   8  e18
50  20   80   9  e19   56  20   82  15  e20
70  20   91  15  e21
;

proc robustreg data=stack method=M;
   model y = x1 x2 x3 / diagnostics leverage;
   id    exp;
   output out=RegOut p=Pred r=Resid;
run;

%let p = 4; /* number of indep variables in model + 1 for intercept */
%let n = 21; /* from the NumObs Table: Number of Observations Read 21 */
data Stats;
retain SSE 0;
set RegOut end=EOF;
SSE + Resid**2;    /* sum of squares of residuals */
MSE = SSE / (&amp;amp;n-&amp;amp;p); /* DF = n - p */
if EOF then output;
run;

proc print data=Stats noobs; 
var SSE MSE;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 13 Jan 2022 11:47:41 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-01-13T11:47:41Z</dc:date>
    <item>
      <title>Robust reg sse and mse code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Robust-reg-sse-and-mse-code/m-p/789939#M252865</link>
      <description>&lt;P&gt;hello all&lt;/P&gt;&lt;P&gt;kindly I have data analysis in robust regression and I want to get SSE and MSE by M-estimation, S-estimation and MM-estimation didn't know what code and I didn't find anything about that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your help&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 10:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Robust-reg-sse-and-mse-code/m-p/789939#M252865</guid>
      <dc:creator>Awa3</dc:creator>
      <dc:date>2022-01-13T10:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Robust reg sse and mse code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Robust-reg-sse-and-mse-code/m-p/789948#M252870</link>
      <description>&lt;P&gt;You can run a robust regression model by using &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_rreg_toc.htm" target="_self"&gt;the ROBUSTREG procedure&lt;/A&gt; in SAS/STAT software.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the METHOD= option on the PROC ROBUSTREG to specify the method, including METHOD=M, METHOD=S, and METHOD=LTS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best place to start is &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_rreg_gettingstarted.htm" target="_self"&gt;the Getting Started examples in the doc&lt;/A&gt;. There is a GS example for M estimation and for LTS estimation.&amp;nbsp; &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_rreg_examples01.htm" target="_self"&gt;Another example shows a comparison between various methods&lt;/A&gt;, including METHOD=S.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you are learning the procedure, I encourage you to &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_021/statug/statug_rreg_examples05.htm" target="_self"&gt;use the PLOTS=ALL option to visualize your data by using regression diagnostic plots&lt;/A&gt;. The plots will help you to understand which observations in the data are influential in OLS regression but have been downweighted by the robust estimation methods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding the SSE and MSE statistics, those are non-robust statistics so I don't think PROC ROBUSTREG produces them However, you can use the OUTPUT statement to write the residual values to a data set and then compute the SSE and MSE manually. The denominator for the MSE comes from the relevant entries in the ModelInfo table. For example, the following program shows that the model has p=4 vars (three indep vars, plus the intercept) and n=21 valid observations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Getting Started example from PROC ROBUSTREG doc */
data Stack;
   input  x1 x2 x3 y exp $ @@;
   datalines;
80  27   89  42   e1   80  27   88  37   e2
75  25   90  37   e3   62  24   87  28   e4
62  22   87  18   e5   62  23   87  18   e6
62  24   93  19   e7   62  24   93  20   e8
58  23   87  15   e9   58  18   80  14  e10
58  18   89  14  e11   58  17   88  13  e12
58  18   82  11  e13   58  19   93  12  e14
50  18   89   8  e15   50  18   86   7  e16
50  19   72   8  e17   50  19   79   8  e18
50  20   80   9  e19   56  20   82  15  e20
70  20   91  15  e21
;

proc robustreg data=stack method=M;
   model y = x1 x2 x3 / diagnostics leverage;
   id    exp;
   output out=RegOut p=Pred r=Resid;
run;

%let p = 4; /* number of indep variables in model + 1 for intercept */
%let n = 21; /* from the NumObs Table: Number of Observations Read 21 */
data Stats;
retain SSE 0;
set RegOut end=EOF;
SSE + Resid**2;    /* sum of squares of residuals */
MSE = SSE / (&amp;amp;n-&amp;amp;p); /* DF = n - p */
if EOF then output;
run;

proc print data=Stats noobs; 
var SSE MSE;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jan 2022 11:47:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Robust-reg-sse-and-mse-code/m-p/789948#M252870</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-01-13T11:47:41Z</dc:date>
    </item>
  </channel>
</rss>

