<?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: calculating the marginal effect for logistic regression with proc genmod in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582244#M28569</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data are 18,000+ observations, should I attach the csv here? I use the geesubject option because schools are nested within cities and suburbs.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2019 19:58:53 GMT</pubDate>
    <dc:creator>AXR</dc:creator>
    <dc:date>2019-08-19T19:58:53Z</dc:date>
    <item>
      <title>calculating the marginal effect for logistic regression with proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/581867#M28552</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm running a logistic regression in proc genmod for proportion data. I am regressing the share of white students in a school on whether the school is in a city or a suburb. How do I calculate the marginal effects for the city variable? I can't use the margins macro because I'm using the events/trial syntax for proportion data.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=dat;
class city;
model n_white/total_students = city/dist=bin link=logit;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;n_white = number of white students&lt;/P&gt;&lt;P&gt;total_students = number of students in the school&lt;/P&gt;&lt;P&gt;city = indicator for whether a school is in a city or suburb&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 21:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/581867#M28552</guid>
      <dc:creator>AXR</dc:creator>
      <dc:date>2019-08-16T21:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: calculating the marginal effect for logistic regression with proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/581914#M28553</link>
      <description>&lt;P&gt;I'm not sure what you mean by "marginal" in this situation where you have one X variable. Could you explain further?&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 10:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/581914#M28553</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-17T10:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: calculating the marginal effect for logistic regression with proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/581917#M28554</link>
      <description>&lt;P&gt;Did you check ESTIMATE and SLICE statement.&lt;/P&gt;
&lt;P&gt;Or you could use EFFECTPLOT to visualize this marginal effect.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 11:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/581917#M28554</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-08-17T11:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: calculating the marginal effect for logistic regression with proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582160#M28555</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are a number of other covariates also in the model, sorry! For example, income inequality ("gini", continuous), charter school ("charter", categorical), urbanicity ("urban", categorical), among many others.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The updated code could look like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=dat;
class city;
model n_white/total_students = city gini charter urban/dist=bin link=logit;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 16:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582160#M28555</guid>
      <dc:creator>AXR</dc:creator>
      <dc:date>2019-08-19T16:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: calculating the marginal effect for logistic regression with proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582204#M28565</link>
      <description>&lt;P&gt;You can use the Margins macro... just modify your aggregated (events/trials) data to create one observation with count for events and one observation with count for nonevents. Then, as mentioned in the Limitations section of the macro documentation, use the FREQ= option in the macro. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data drug;
   input drug$ x r n @@;
   y=1; f=r; output;
   y=0; f=n-r; output;
   datalines;
A  .1   1  10   A  .23  2  12   A  .67  1   9
B  .2   3  13   B  .3   4  15   B  .45  5  16   B  .78  5  13
C  .04  0  10   C  .15  0  11   C  .56  1  12   C  .7   2  12
D  .34  5  10   D  .6   5   9   D  .7   8  10
E  .2  12  20   E  .34 15  20   E  .56 13  15   E  .8  17  20
;
%Margins(data     = drug,
         class    = drug,
         response = y,
         roptions = event='1',
         freq     = f,
         dist     = binomial,
         model    = drug x,
         margins  = drug, 
         options  = diff cl )
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 18:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582204#M28565</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2019-08-19T18:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: calculating the marginal effect for logistic regression with proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582240#M28567</link>
      <description>&lt;P&gt;Interesting, I tried your method but got the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   ERROR: A cluster has been detected with the frequency counts specified
          by the FREQ statement unequal within the cluster. The frequency counts
          must be equal within clusters.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 19:49:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582240#M28567</guid>
      <dc:creator>AXR</dc:creator>
      <dc:date>2019-08-19T19:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: calculating the marginal effect for logistic regression with proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582241#M28568</link>
      <description>&lt;P&gt;That sounds like a message you could get if you use the GEESUBJECT= option. It would help if you showed your DATA step code and your macro call.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 19:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582241#M28568</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2019-08-19T19:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: calculating the marginal effect for logistic regression with proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582244#M28569</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data are 18,000+ observations, should I attach the csv here? I use the geesubject option because schools are nested within cities and suburbs.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 19:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582244#M28569</guid>
      <dc:creator>AXR</dc:creator>
      <dc:date>2019-08-19T19:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: calculating the marginal effect for logistic regression with proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582280#M28571</link>
      <description>&lt;P&gt;In that case, you will need to fully expand your aggregated data so that one observation represents a single individual and not use the FREQ= option. For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data drug;
   input drug$ x r n @@;
   do i=1 to r; y=1; output; end;
   do i=1 to n-r; y=0; output; end;
   datalines;
A  .1   1  10   A  .23  2  12   A  .67  1   9
B  .2   3  13   B  .3   4  15   B  .45  5  16   B  .78  5  13
C  .04  0  10   C  .15  0  11   C  .56  1  12   C  .7   2  12
D  .34  5  10   D  .6   5   9   D  .7   8  10
E  .2  12  20   E  .34 15  20   E  .56 13  15   E  .8  17  20
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Aug 2019 22:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/582280#M28571</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2019-08-19T22:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: calculating the marginal effect for logistic regression with proc genmod</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/583210#M28600</link>
      <description>&lt;P&gt;I am hesitant to do it this way because my unit of analysis is the aggregated data (schools) not the individual student data. Is there a way to calculate the average marginal effect without using the margins macro for proc genmod?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 14:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/calculating-the-marginal-effect-for-logistic-regression-with/m-p/583210#M28600</guid>
      <dc:creator>AXR</dc:creator>
      <dc:date>2019-08-22T14:56:21Z</dc:date>
    </item>
  </channel>
</rss>

