<?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 Logistic regression Pearson residuals in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Logistic-regression-Pearson-residuals/m-p/234511#M54946</link>
    <description>&lt;P&gt;I am trying to understand SAS Pearson residuals for logistic regression. &amp;nbsp;I am using single-trial syntax. &amp;nbsp;The SAS User's Guide defines the Pearson residuals as&lt;/P&gt;&lt;TABLE cellspacing="0" cellpadding="7"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;IMG src="http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/images/statug_logistic0617.png" border="0" alt="" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;where r_j is 1 (for a successful response) and n_j is 1 for single-trial syntax. &amp;nbsp;Then the weights w_j account for the multiple successes that occurred in this binomial trial.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I would like SAS to let n_j be the total number of trials in that binomial trial. &amp;nbsp;How can I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a minimal example. &amp;nbsp;Suppose my data can be cross-classified (Y is the response) as:&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Success &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Failure&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;------------------------------------&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;1 | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;X &amp;nbsp;---|---------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;2 | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;&amp;nbsp; &amp;nbsp; -------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
input x y count;
datalines;
1 1 2
1 0 1
2 1 6
2 0 1
;

proc logistic data=example descending;
	model y = / influence;
	weight count;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In cell (1,1) there are two counts, and since I am fitting the independence model, the predicted probability for that (and every other) cell is 8/10. &amp;nbsp;If row 1 is a binomial trial, there are 2 succeseses out of 3 and so the residual (in my mind) should be negative to account for the fact that we would expect 3*8/10=2.4 successes. &amp;nbsp;But SAS' residual is positive because we had 2 successes and we expected 2*8/10=1.6 successes. &amp;nbsp;In other words, I want SAS to know that I am thinking of the whole first row as a binomial trial, not just the first cell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the only answer to my question ends up being "Use events/trials syntax", I can live with that, but then my question is how to get &lt;EM&gt;all&lt;/EM&gt; the Pearson residuals for my table. &amp;nbsp;The following code only gives me the Pearson residuals for the first column of my contingency table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
input x successes total;
datalines;
1 2 3
2 6 7
;

proc logistic data=example descending;
	model successes / total = / influence;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 12 Nov 2015 21:54:50 GMT</pubDate>
    <dc:creator>sdg238</dc:creator>
    <dc:date>2015-11-12T21:54:50Z</dc:date>
    <item>
      <title>Logistic regression Pearson residuals</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Logistic-regression-Pearson-residuals/m-p/234511#M54946</link>
      <description>&lt;P&gt;I am trying to understand SAS Pearson residuals for logistic regression. &amp;nbsp;I am using single-trial syntax. &amp;nbsp;The SAS User's Guide defines the Pearson residuals as&lt;/P&gt;&lt;TABLE cellspacing="0" cellpadding="7"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;IMG src="http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/images/statug_logistic0617.png" border="0" alt="" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;where r_j is 1 (for a successful response) and n_j is 1 for single-trial syntax. &amp;nbsp;Then the weights w_j account for the multiple successes that occurred in this binomial trial.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I would like SAS to let n_j be the total number of trials in that binomial trial. &amp;nbsp;How can I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a minimal example. &amp;nbsp;Suppose my data can be cross-classified (Y is the response) as:&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Success &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Failure&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;------------------------------------&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;1 | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;X &amp;nbsp;---|---------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;2 | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;&amp;nbsp; &amp;nbsp; -------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
input x y count;
datalines;
1 1 2
1 0 1
2 1 6
2 0 1
;

proc logistic data=example descending;
	model y = / influence;
	weight count;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In cell (1,1) there are two counts, and since I am fitting the independence model, the predicted probability for that (and every other) cell is 8/10. &amp;nbsp;If row 1 is a binomial trial, there are 2 succeseses out of 3 and so the residual (in my mind) should be negative to account for the fact that we would expect 3*8/10=2.4 successes. &amp;nbsp;But SAS' residual is positive because we had 2 successes and we expected 2*8/10=1.6 successes. &amp;nbsp;In other words, I want SAS to know that I am thinking of the whole first row as a binomial trial, not just the first cell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the only answer to my question ends up being "Use events/trials syntax", I can live with that, but then my question is how to get &lt;EM&gt;all&lt;/EM&gt; the Pearson residuals for my table. &amp;nbsp;The following code only gives me the Pearson residuals for the first column of my contingency table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
input x successes total;
datalines;
1 2 3
2 6 7
;

proc logistic data=example descending;
	model successes / total = / influence;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Nov 2015 21:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Logistic-regression-Pearson-residuals/m-p/234511#M54946</guid>
      <dc:creator>sdg238</dc:creator>
      <dc:date>2015-11-12T21:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Logistic regression Pearson residuals</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Logistic-regression-Pearson-residuals/m-p/234701#M54967</link>
      <description>&lt;P&gt;I might be way off-base, but since no one else has answered, I'll suggest that you explore using PROC FREQ.&amp;nbsp; It can output Pearson residuals (PEARSONRES option) and you can use the CROSSLIST option on the TABLES statement to make each cell of the 2x2 table appear on its own row.&lt;/P&gt;
&lt;P&gt;Here is a &lt;A href="http://support.sas.com/documentation/cdl/en/procstat/68142/HTML/default/viewer.htm#procstat_freq_details08.htm" target="_self"&gt;link to the doc.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2015 20:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Logistic-regression-Pearson-residuals/m-p/234701#M54967</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-11-13T20:33:30Z</dc:date>
    </item>
  </channel>
</rss>

