Closed:How to get the ordinary t statistic for two paired groups?
2
0
Entering edit mode
fansili2013 ▴ 50
@fansili2013-14404
Last seen 5.9 years ago

Hi,

I understand that to get the ordinary t statistic for independent two groups is using 

fit$coef / fit$stdev.unscaled / fit$sigma

 

I wonder how to get the ordinary t statistic for dependent groups? My simulation study tells me that the above code does not work because the result is different from the t.test(, paired = TRUE).

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)


design <- model.matrix(~subject_id+treat)
fit <- lmFit(y, design)
fit <- eBayes(fit)
topTable(fit, coef="treatT2") # p value from limma

       logFC    AveExpr          t   P.Value adj.P.Val         B
1  0.3365364 -0.5893109  0.3322012 0.7482740 0.9126306 -4.599436
2 -0.1147175 -0.5007840 -0.1132397 0.9126306 0.9126306 -4.599906

(1-pt(abs(fit$coef / fit$stdev.unscaled / fit$sigma),4))*2  # p value from ordinary t statistic

     (Intercept) subject_idB subject_idC subject_idD subject_idE   treatT2
[1,]   0.7485326   0.7275158   0.9835921   0.9614861   0.7787754 0.7892628
[2,]   0.7753628   0.2667974   0.3548992   0.4055479   0.7356786 0.8949580

t.test(y[1,]~treat, paired = TRUE) # p value from paired t test in R. The result does not match with the previous code.


t = -0.28574, df = 4, p-value = 0.7893
limma • 72 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 619 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6