title: Inverse probability weights in r
body: <p>I'm trying to apply inverse probability weights to a regression, but <code>lm()</code> only uses analytic weights.  This is part of a replication I'm working on where the original author is using <code>pweight</code> in Stata, but I'm trying to replicate it in R.  The analytic weights are providing lower standard errors which is causing problems with some of my variable being significance.</p>
  
  <p>I've tried looking at the <code>survey</code> package, but am not sure how to prepare a survey object for use with <code>svyglm()</code>.  Is this the approach I want, or is there an easier way to apply inverse probability weights?    </p>
  
  <p>dput :</p>
  
  <pre><code>data &lt;- structure(list(lexptot = c(9.1595012302023, 9.86330744180814, 
  8.92372556833205, 8.58202430280175, 10.1133857229336), progvillm = c(1L, 
  1L, 1L, 1L, 0L), sexhead = c(1L, 1L, 0L, 1L, 1L), agehead = c(79L, 
  43L, 52L, 48L, 35L), weight = c(1.04273509979248, 1.01139605045319, 
  1.01139605045319, 1.01139605045319, 0.76305216550827)), .Names = c("lexptot", 
  "progvillm", "sexhead", "agehead", "weight"), class = c("tbl_df", 
  "tbl", "data.frame"), row.names = c(NA, -5L))
  </code></pre>
  
  <p>Linear Model (using analytic weights)</p>
  
  <pre><code>prog.lm &lt;- lm(lexptot ~ progvillm + sexhead + agehead, data = data, weight = weight)
  summary(prog.lm)
  </code></pre>