#install.packages(c("MASS"))
#install.packages(c("multcomp"))
library(multcomp)
library(MASS)
library(nlme)
library(foreign)
library(car)
library(stats)
sem <- read.spss("e:\\POST-HOC FOR ZIPPING\\DEMO POST-HOC\\WITHIN2.sav")
attach(sem)
type2 <- recode(type, "1='A'; 2='B'; 3='C';4='D'")
sem <- data.frame(y,id,type2)
Lme.mod <- lme(y ~ type2, random = ~1 | id/type2, data = sem) 
anova(Lme.mod)
summary(glht(Lme.mod, linfct=mcp(type2="Tukey")))

# OUTPUTTED TUKEY STANDARD ERROR = SQRT[2X(MSE/{N PER GROUP)}] = sqrt[2x (1.05/10)] =0.46