We know that a paired t-test is just a special case of one-way repeated-measures (or within-subject) ANOVA as well as linear mixed-effect model, which can be demonstrated with lme() function the nlme package in R as shown below.
#response data from 10 subjects under two conditions x1<-rnorm(10) x2<-1+rnorm(10) # Now create a dataframe for lme myDat <- data.frame(c(x1,x2), c(rep("x1", 10), rep("x2", 10)), rep(paste("S", seq(1,10), sep=""), 2)) names(myDat) <- c("y", "x", "subj")
When I run the following paired t-test:
t.test(x1, x2, paired = TRUE)
I got this result (you will get a different result because of the random generator):
t = -2.3056, df = 9, p-value = 0.04657
With the ANOVA approach we can get the same result:
summary(aov(y ~ x + Error(subj/x), myDat)) # the F-value below is just the square of the t-value from paired t-test: Df F value Pr(>F) x 1 5.3158 0.04657
Now I can obtain the same result in lme with the following model, assuming a positive-definite symmetrical correlation matrix for the two conditions:
summary(fm1 <- lme(y ~ x, random=list(subj=pdSymm(form=~x-1)), data=myDat)) # the 2nd row in the following agrees with the paired t-test # (Intercept) -0.2488202 0.3142115 9 -0.7918878 0.4488 # xx2 1.3325786 0.5779727 9 2.3056084 0.0466
Or another model, assuming a compound symmetry for the correlation matrix of the two conditions:
summary(fm2 <- lme(y ~ x, random=list(subj=pdCompSymm(form=~x-1)), data=myDat)) # the 2nd row in the following agrees with the paired t-test # (Intercept) -0.2488202 0.4023431 9 -0.618428 0.5516 # xx2 1.3325786 0.5779727 9 2.305608 0.0466
With the paired t-test and one-way repeated-measures ANOVA, I can write down the traditional cell mean model as
Yij = μ + αi + βj + εij, i = 1, 2; j = 1, ..., 10
where i indexes condition, j indexes subject, Yij is the response variable, μ is constant for the fixed effect for overall mean, αi is the fixed effect for condition, βj is the random effect for subject following N(0, σp2) (σp2 is population variance), and εij is residual following N(0, σ2) (σ2 is within-subject variance).
I thought that the cell mean model above would not be appropriate for the lme models, but the trouble is that I can't come up with a reasonable model for the two lme() approaches with the correlation structure assumption. The reason is that the lme model seems to have more parameters for the random components than the cell mean model above offers. At least the lme model provides exactly the same F-value, degrees of freedom, and p-value as well, which gls cannot. More specifically gls gives incorrect DFs due to the fact that it does not account for the fact that each subject has two observations, leading to much inflated DFs. The lme model most likely is overparameterized in specifying the random effects, but I don't know what the model is and what the parameters are. So the issue is still unresolved for me.