JUNGEUN PARK
JUNGEUN PARK

Reputation: 13

How to perform paired t-test without whole sample data?

I have several data summaries for paired t-test from three difference sources (hospitals), which means I don't have the whole sample data. What I've got to perform the paired t-test is the mean (difference of each paired sample data).
The data looks like the table below (each row is one patient) and I have the mean(diff) and sd(diff).
Is there any function with which I could easily perform paired t-test and get the 95% CI? There is just no way of getting the whole data set, due to patient privacy concerns.

3 months 6 months  diff
  1         3       -2
  2         1        1
  5         9       -4

Upvotes: 1

Views: 578

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226871

A paired t-test is exactly equivalent to a t-test that tests the mean of the differences against a null hypothesis of zero.

diffs <- c(-2,1,-4)
m <- mean(diffs)
s <- sd(diffs)
n <- length(diffs)

Now suppose you don't know diffs, just m, s and n (all three are necessary)

pval <- 2*pt(abs(m/s),lower.tail=FALSE,df=n)
## 0.555
qq <- qt(0.975,df=n)
ci <- m + c(-1,1)*qq*s
## [1] -9.675648  6.342314

Upvotes: 2

Related Questions