title: R: meta-analysis for repeated measures / random effects model
body: <pre><code>mydat &lt;- data.frame(stage1 = c(4, 3, 2, 1), n1 = c(10, 40, 30, 20))
  mydat
    stage1 n1
  1      4 10
  2      3 40
  3      2 30
  4      1 20
  </code></pre>
  
  <p>I have a simple data set with 4 studies (1 per row) and I have the number of events (stage1) and the sample size (n1) from each study. At stage1 of the study, 4 out of 10 people from study #1 have the disease. In comparison, only 3/40 people from study #2 have the disease, etc. </p>
  
  <pre><code>library(meta)
  metaprop(mydat$stage1, mydat$n1)
  </code></pre>
  
  <p>I use the <code>metaprop</code> function to perform a meta-analysis of the single proportions from the 4 studies. However, suppose each study reports other effect estimates at a later stage. </p>
  
  <pre><code>mydat2 = data.frame(stage1 = c(4, 3, 2, 1), n1 = c(10, 20, 30, 40), stage2 = c(7, 5, 3, 4), n2 = c(10, 20, 30, 40))
  mydat2
    stage1 n1 stage2 n2
  1      4 10      7 10
  2      3 20      5 20
  3      2 30      3 30
  4      1 40      4 40
  </code></pre>
  
  <p>So here, at stage2, a total of 7 people out of 10 possible people now have the disease from study #1. How exactly would I take that into account so that the correlation is adjusted correctly? Should I make stage and study indicators in my data.frame: </p>
  
  <pre><code>&gt; mydat3 = data.frame(event = c(mydat2$stage1, mydat2$stage2), n = c(mydat2$n1, mydat2$n2), stage = c(rep(1, 4), rep(2, 4)), study = c(rep(c(1, 2, 3, 4), 2)))
  &gt; mydat3
    event  n stage study
  1     4 10     1     1
  2     3 20     1     2
  3     2 30     1     3
  4     1 40     1     4
  5     7 10     2     1
  6     5 20     2     2
  7     3 30     2     3
  8     4 40     2     4
  </code></pre>
  
  <p>But how would I include that in my <code>metaprop</code> function call? I'm also open to using other functions (not just <code>metaprop</code>).</p>