<p>I am learning the R package <a href="http://bioconductor.org/packages/release/bioc/html/limma.html" rel="nofollow noreferrer">limma</a> using its <a href="https://www.bioconductor.org/packages/devel/bioc/vignettes/limma/inst/doc/usersguide.pdf" rel="nofollow noreferrer">user guide</a>. I need help on understanding the difference between the paired t-test, paired t-test-like (empirical Bayesian) and the mixed effect model in the limma.</p>

<p>The paired t test-like example is in the user <em>guide 9.4.1 paired samples</em>. The mixed effect model is in the <em>9.7 Multi-level Experiments</em> (I think this is mixed effect model. Correct me if I'm wrong please).</p>

<p>I understand that paired t-test is a special case of linear mixed-effect modeling. So I suppose that the 9.4.1 and 9.7 should return very similar result and the 9.7 should have an identical result with the paired t-test. However, it is not the case. What am I missing here?</p>

<p>Please see the following small simulation study,</p>

<pre><code>set.seed(20180528)

y = matrix(rnorm(2*10), nrow=2)

treat = factor(rep(c("T1","T2"),5))
subject_id = rep(c("A","B","C","D","E"), each = 2)
design &lt;- model.matrix(~0+treat)
colnames(design) &lt;- levels(treat)
# 1 --- 9.7 Multi-level Experiments
corfit &lt;- duplicateCorrelation(y,design,block=subject_id)
fit &lt;- lmFit(y,design, block = subject_id, correlation = corfit$consensus)
cm &lt;- makeContrasts(
  Diff = T2-T1,
  levels=design)
fit2 &lt;- contrasts.fit(fit, cm)
fit2 &lt;- eBayes(fit2)
topTable(fit2, coef="Diff")
# logFC     AveExpr          t   P.Value adj.P.Val         B
# 1 -0.5173411 -0.08265473 -1.3646790 0.1912401 0.3824802 -4.487867
# 2 -0.1795537 -0.24626262 -0.5743662 0.5737073 0.5737073 -4.785946
# 2  --- 9.4.1 empirical bayesian paired t test
design &lt;- model.matrix(~subject_id+treat)
fit &lt;- lmFit(y, design)
fit &lt;- eBayes(fit)
topTable(fit, coef="treatT2")

# logFC     AveExpr          t   P.Value adj.P.Val         B
# 1 -0.5173411 -0.08265473 -1.5408913 0.1619112 0.3238224 -4.340661
# 2 -0.1795537 -0.24626262 -0.5347977 0.6073295 0.6073295 -4.928314


# 3. -----traditional paired t test
t.test(y[1,]~treat, paired = TRUE)
# t = 1.3815, df = 4, p-value = 0.2393
# being equivalent to  
# ordinary.t &lt;- fit$coef / fit$stdev.unscaled / fit$sigma
# (1 - pt(abs(ordinary.t[1,ncol(ordinary.t)]), 4))*2
</code></pre>

CC BY-SA 4.0
2018-05-29T16:28:20.647Z
You will have better luck posting this on https://support.bioconductor.org or the limma mailing list. Also not clear why would you expect "identical results" for a paired t-test with the one using the eBayes() method
Peter
CC BY-SA 4.0
2018-05-29T16:37:00.060Z
Hi, @Peter, I did post [it](https://support.bioconductor.org/p/109417/#109465). I expect an identical result for a paired t-test with the one in **9.7**, which I think is mixed effect model. I understand that `eBayes()` in 9.4.1 won't have an identical result with the paired t-test.
WCMC
CC BY-SA 4.0
2018-05-30T08:49:35.740Z
There is a great answer on [bioconductor support](https://support.bioconductor.org/p/109417/#109465). Don't understand why you cross post it here...
benn
CC BY-SA 4.0
2018-05-30T16:44:50.803Z
@b.nota. Simple. Because there wasn't one.
WCMC
<r><limma>
Different results between paired t-test, paired t-test-like (empirical Bayesian), and mixed effect model
# Different results between paired t-test, paired t-test-like (empirical Bayesian), and mixed effect model

(Asked by: username_0 on 2018-05-29)

I am learning the R package limma using its user guide. I need help on understanding the difference between the paired t-test, paired t-test-like (empirical Bayesian) and the mixed effect model in the limma.
The paired t test-like example is in the user guide 9.4.1 paired samples. The mixed effect model is in the 9.7 Multi-level Experiments (I think this is mixed effect model. Correct me if I'm wrong please).
I understand that paired t-test is a special case of linear mixed-effect modeling. So I suppose that the 9.4.1 and 9.7 should return very similar result and the 9.7 should have an identical result with the paired t-test. However, it is not the case. What am I missing here?
Please see the following small simulation study,
set.seed(20180528)

y = matrix(rnorm(2*10), nrow=2)

treat = factor(rep(c("T1","T2"),5))
subject_id = rep(c("A","B","C","D","E"), each = 2)
design <- model.matrix(~0+treat)
colnames(design) <- levels(treat)
# 1 --- 9.7 Multi-level Experiments
corfit <- duplicateCorrelation(y,design,block=subject_id)
fit <- lmFit(y,design, block = subject_id, correlation = corfit$consensus)
cm <- makeContrasts(
  Diff = T2-T1,
  levels=design)
fit2 <- contrasts.fit(fit, cm)
fit2 <- eBayes(fit2)
topTable(fit2, coef="Diff")
# logFC     AveExpr          t   P.Value adj.P.Val         B
# 1 -0.5173411 -0.08265473 -1.3646790 0.1912401 0.3824802 -4.487867
# 2 -0.1795537 -0.24626262 -0.5743662 0.5737073 0.5737073 -4.785946
# 2  --- 9.4.1 empirical bayesian paired t test
design <- model.matrix(~subject_id+treat)
fit <- lmFit(y, design)
fit <- eBayes(fit)
topTable(fit, coef="treatT2")

# logFC     AveExpr          t   P.Value adj.P.Val         B
# 1 -0.5173411 -0.08265473 -1.5408913 0.1619112 0.3238224 -4.340661
# 2 -0.1795537 -0.24626262 -0.5347977 0.6073295 0.6073295 -4.928314


# 3. -----traditional paired t test
t.test(y[1,]~treat, paired = TRUE)
# t = 1.3815, df = 4, p-value = 0.2393
# being equivalent to  
# ordinary.t <- fit$coef / fit$stdev.unscaled / fit$sigma
# (1 - pt(abs(ordinary.t[1,ncol(ordinary.t)]), 4))*2

**Tags:** r, limma
> **Comments:**
> **username_1**: You will have better luck posting this on https://support.bioconductor.org or the limma mailing list. Also not clear why would you expect "identical results" for a paired t-test with the one using the eBayes() method  
> **username_0**: Hi, @Peter, I did post [it](https://support.bioconductor.org/p/109417/#109465). I expect an identical result for a paired t-test with the one in **9.7**, which I think is mixed effect model. I understand that `eBayes()` in 9.4.1 won't have an identical result with the paired t-test.  
> **username_2**: There is a great answer on [bioconductor support](https://support.bioconductor.org/p/109417/#109465). Don't understand why you cross post it here...  
> **username_0**: @b.nota. Simple. Because there wasn't one.  

---

## 0 answers

