title: How to incorporate weights into a likelihood function?
body: <p>I want to incorporate weights into the likelihood to do what the <code>svyglm</code> does with weights.</p>
  
  <p>According to <a href="https://stats.stackexchange.com/q/57107">Jeremy Miles</a> and <a href="https://cran.r-project.org/web/packages/survey/survey.pdf" rel="nofollow noreferrer">elsewhere</a>, <code>svyglm</code> function uses weights to "weight the importance of each case to make them representative (to each other, ...)".</p>
  
  <p>Here is my data:</p>
  
  <pre><code>(dat &lt;- data.frame(
    A = c(1, 1, 0, 0), B = c(1, 0, 1, 0),
    Pass = c(278, 100, 153, 79), Fail = c(743, 581, 1232, 1731), Weights= c(3, 1, 12, 3)
  ))
  </code></pre>
  
  <p>Here is my <code>likelihood</code> function:</p>
  
  <pre><code>ll &lt;- function (b0, b1, b2, b3) {
    odds &lt;- exp(b0) * (1 + b1 * dat$A + b2 * dat$B + b3 * dat$A * dat$B)
    -sum(dbinom(
      x = dat$Pass, size = rowSums(dat[, 3:4]),
      prob = odds / (1 + odds), log = TRUE))
  }
  </code></pre>