library(MASS)
library(nlme)
# simulated a dataset
paired<-mvrnorm(n=30,mu=c(10,10.2),Sigma=matrix(c(5,4,4,5),2,2))
before<-paired[,1]
after<-paired[,2]
# paired t-test
t.test(before,after,paired=TRUE)
### Mixed Models for a paired t-test
# reshape data for mixed models
y<-c(before,after)
id<-rep(c(1:length(before)),2)
time<-c(rep(0,length(before)),rep(1,length(after)))
# fit mixed models
summary(lme(y~time, random=~1|id))
Thursday, December 18, 2008
Paired t-test with Mixed Models
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment