title: R: Clustered robust standard errors using miceadds lm.cluster - error with subset and weights
body: <p>I am trying to use the lm.cluster function in the package miceadds to get robust clustered standard errors for a multiply imputed dataset. </p>
  
  <p>I am able to get the standard version of it to run but I get the following error when I try to add a subset or weights: </p>
  
  <pre><code>Error in eval(substitute(subset), data, env) : 
  ..1 used in an incorrect context, no ... to look in
  </code></pre>
  
  <p>Example that works without subset or weights:</p>
  
  <pre><code>require("mice")
  require("miceadds")
  data(data.ma01)
  # imputation of the dataset: use six imputations
  dat &lt;- data.ma01[ , - c(1:2) ]
  imp &lt;- mice::mice( dat , maxit=3 , m=6 )
  datlist &lt;- miceadds::mids2datlist( imp )
  # linear regression with cluster robust standard errors
  mod &lt;- lapply(datlist, FUN = function(data){miceadds::lm.cluster( data=data ,         
  formula=read ~ paredu+ female ,  cluster = data.ma01$idschool )}  )
  
  # extract parameters and covariance matrix
  betas &lt;- lapply( mod , FUN = function(rr){ coef(rr) } )
  vars &lt;- lapply( mod , FUN = function(rr){ vcov(rr) } )
  # conduct statistical inference
  summary(pool_mi( qhat = betas, u = vars ))
  </code></pre>
  
  <p>Example that breaks with subset:</p>
  
  <pre><code>mod &lt;- lapply(datlist, FUN = function(data){miceadds::lm.cluster( data=data ,         
  formula=read ~ paredu+ female ,  cluster = data.ma01$idschool, subset=
  (data.ma01$urban==1))}  )
  
  Error during wrapup: ..1 used in an incorrect context, no ... to look in
  </code></pre>
  
  <p>Example that breaks with weights:</p>
  
  <pre><code>mod &lt;- lapply(datlist, FUN = function(data){miceadds::lm.cluster( data=data ,         
  formula=read ~ paredu+ female ,  cluster = data.ma01$idschool,
  weights=data.ma01$studwgt)}  )
  
  Error during wrapup: ..1 used in an incorrect context, no ... to look in
  </code></pre>
  
  <p>From searching, I think I am encountering similar issues as others when passing these commands through an lm or glm wrapper (such as: <a href="https://stackoverflow.com/questions/27261232/passing-argument-to-lm-in-r-within-function">Passing Argument to lm in R within Function</a> or <a href="https://stackoverflow.com/questions/10858318/r-pass-argument-to-glm-inside-an-r-function">R : Pass argument to glm inside an R function</a> or <a href="https://stackoverflow.com/questions/27045340/passing-the-weights-argument-to-a-regression-function-inside-an-r-function">Passing the weights argument to a regression function inside an R function</a>)</p>
  
  <p>However, I am not sure how to address the issue with the imputed datasets &amp; existing lm.cluster command.</p>
  
  <p>Thanks</p>