<?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: Understanding R square in PROC GLM with weight variable in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320036#M16916</link>
    <description>&lt;P&gt;If you post your code (PROC REG + DATA step), someone might be able to assist.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Dec 2016 21:02:22 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2016-12-19T21:02:22Z</dc:date>
    <item>
      <title>Understanding R square in PROC GLM with weight variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320017#M16913</link>
      <description>&lt;P&gt;I tried to use PROC GLM to fit a model without an intercept term, yet with a weight variable. The SAS lines would read like such: PROC GLM; Model _dependent variable_ = list of independent variables/noint; weight _weight variable_. From the model fitting output, I can see the usual statistics, SSE, MSE, and R square. Then I tried to calculate&amp;nbsp;R square after outputing the actuals and&amp;nbsp;fitted values. But I got a different R square value from the straightforward SAS output. To calculate R square, I used the simple formula: R square = 1 - (residual sum of squares/total sum of squares). Since there was a weight variable, for each observation, both squared terms were weighted by the weight variable before summing up, i.e., weight*(actual-fitted)^2&amp;nbsp;and weight*(actual - average of actuals)^2. Was there anything incorrect about the manual derivation for R square? Could anyone help clear it up? Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 19:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320017#M16913</guid>
      <dc:creator>essence_0</dc:creator>
      <dc:date>2016-12-19T19:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding R square in PROC GLM with weight variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320021#M16914</link>
      <description>&lt;P&gt;There is no need to guess. The SAS documentation includes a chapter that shows &lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_introreg_sect030.htm" target="_self"&gt;the&amp;nbsp;basic statistics that are computed in regression procedures.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your formulas for R-squared and &amp;nbsp;SSE seem to match the formulas in the documentation. For the total sum of squares, did you use the weighted mean?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 19:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320021#M16914</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-12-19T19:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding R square in PROC GLM with weight variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320033#M16915</link>
      <description>&lt;P&gt;just tried to replace the average of the actuals with the average of the weighted actuals in the total sum of squares calculation. This time R square becomes much smaller and further away from the R square by SAS output.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 20:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320033#M16915</guid>
      <dc:creator>essence_0</dc:creator>
      <dc:date>2016-12-19T20:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding R square in PROC GLM with weight variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320036#M16916</link>
      <description>&lt;P&gt;If you post your code (PROC REG + DATA step), someone might be able to assist.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2016 21:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320036#M16916</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-12-19T21:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding R square in PROC GLM with weight variable</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320221#M16918</link>
      <description>&lt;P&gt;Here is how to reproduce the numbers. Since you didn't provide data, I will use the following model:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm data=sashelp.class plots=none;
weight weight;
model height = age;
output out=Out Residual=Resid;
ods select OverallAnova FitStatistics;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you say, the R-squared value should be formed by the values in the "Sum of Squares" column in the OverallANOVA table. The following DATA _NULL_ step verifies the calculation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
SS_Total = 43699.97089;
SS_Error = 16000.45958;
RSquared = 1 - SS_Error / SS_Total;
put RSquared=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;OK, so we know that R-squared is correct. How can we verify the SS_Total and SS_Error calculation? Well, SS_Total doesn't even use the model, it is just the corrected sum of squares for the response variable. Calling PROC MEANS reproduces the SS_Total:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=Sashelp.class CSS;
weight weight;
var height;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What about the SS_Error? Well, that's just the weighted sum of the residuals. I output the residuals into the OUT dataset. The following PROC MEANS verifies the SS_Error as the (uncorrected) weighted SS of the residuals:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=Out USS;
weight weight;
var Resid;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Dec 2016 13:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Understanding-R-square-in-PROC-GLM-with-weight-variable/m-p/320221#M16918</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-12-20T13:57:07Z</dc:date>
    </item>
  </channel>
</rss>

