if (FALSE) {
data(dataEP05A2_2)
ub.dat <- dataEP05A2_2[-c(11,12,23,32,40,41,42),]
fit1 <- anovaMM(y~day/(run), ub.dat)
fit2 <- remlMM(y~day/(run), ub.dat)
lsm1 <- lsmeans(fit1)
lsm2 <- lsmeans(fit2)
lsm1
lsm2
lc.mat <- getL(fit1, c("day1-day2", "day3-day6"), "lsm")
lc.mat[1,c(1,2)] <- c(1,-1)
lc.mat[2,c(3,6)] <- c(1,-1)
lc.mat
test.lsmeans(fit1, lc.mat)
test.lsmeans(fit2, lc.mat)
# fit mixed model from the 'nlme' package
library(nlme)
data(Orthodont)
fit.lme <- lme(distance~Sex*I(age-11), random=~I(age-11)|Subject, Orthodont)
# re-organize data for using 'anovaMM'
Ortho <- Orthodont
Ortho$age2 <- Ortho$age - 11
Ortho$Subject <- factor(as.character(Ortho$Subject))
# model without intercept
fit.anovaMM <- anovaMM(distance~Sex+Sex:age2+(Subject)+(Subject):age2-1, Ortho)
fit.remlMM1 <- remlMM( distance~Sex+Sex:age2+(Subject)+(Subject):age2-1, Ortho)
fit.remlMM2 <- remlMM( distance~Sex+Sex:age2+(Subject)+(Subject):age2-1, Ortho, cov=FALSE)
lsm0 <- lsmeans(fit.anovaMM)
lsm1 <- lsmeans(fit.remlMM1)
lsm2 <- lsmeans(fit.remlMM2)
lsm0
lsm1
lsm2
lc.mat <- matrix(c(1,-1), nrow=1, dimnames=list("int.Male-int.Female", c("SexMale", "SexFemale")))
lc.mat
test.lsmeans(fit.anovaMM, lc.mat)
test.lsmeans(fit.remlMM1, lc.mat)
test.lsmeans(fit.remlMM2, lc.mat)
}
Run the code above in your browser using DataLab