title: Fitting logistic regression model to self-grouped data
body: <p>I initally had a data set of ungrouped data which I converted in to catergorical(on the column Occupation) i would now like to fit a logistic regression model to the data i created with "success's" being denoted by the number of people who died in each Occupation catergory.</p>
  
  <p><strong>DATA USED AND GROUPING OF DATA</strong></p>
  
  <p>My initial data set before any grouping looks like this:</p>
  
  <pre><code> Occupation Education Age Died
  1  household Secondary  39   no
  2    farming   primary  83  yes
  3    farming   primary  60  yes
  4    farming   primary  73  yes
  5    farming Secondary  51   no
  6    farming iliterate  62  yes
  </code></pre>
  
  <p>Then i grouped data using:</p>
  
  <pre><code>occu %&gt;% group_by(Occupation, Died) %&gt;% count()##use this to group on the occupation of the suicide victimrs
  </code></pre>
  
  <p>which leads to the following output:</p>
  
  <pre><code>Occupation       Died      n
     &lt;fct&gt;            &lt;fct&gt; &lt;int&gt;
   1 business/service no       12
   2 business/service yes       9
   3 farming          no      939
   4 farming          yes    1093
   5 household        no      154
   6 household        yes      94
   7 others           yes       3
   8 others/unknown   no      146
   9 others/unknown   yes      10
  10 professional     no       11
  11 professional     yes      26
  12 retiree          no        3
  13 student          no       27
  14 student          yes       8
  15 unemployed       no       23
  16 unemployed       yes       7
  17 worker           yes       6
  </code></pre>
  
  <p>i grouped the above into a table so i use the values using the following:</p>
  
  <pre><code>dt %&gt;% group_by(Occupation) %&gt;% 
    mutate(total=sum(n), prop=n/total)
  </code></pre>
  
  <p>which gives output:</p>
  
  <pre><code> ccupation       Died      n total   prop
     &lt;fct&gt;            &lt;fct&gt; &lt;int&gt; &lt;int&gt;  &lt;dbl&gt;
   1 business/service no       12    21 0.571 
   2 business/service yes       9    21 0.429 
   3 farming          no      939  2032 0.462 
   4 farming          yes    1093  2032 0.538 
   5 household        no      154   248 0.621 
   6 household        yes      94   248 0.379 
   7 others           yes       3     3 1     
   8 others/unknown   no      146   156 0.936 
   9 others/unknown   yes      10   156 0.0641
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>My question is no how can i run a logistic regression model to this grouped data with Died = yes being a success and = no being a failure using all three of the predictors in the original model (Education, Age, Grouped Occupation).</p>