# NOT RUN {
data(toydata)
# Bivariate 2-level model.
# Classroom as the clusters.
# Only an intercept is in the fixed part of the model.
# Test based on 200 permutations
mvctm(fixed=cbind(y1,y2)~1,cluster=c("classroom"),
data=toydata,leveltested=1,npermut=200)
# Same as above but The two covariates are in the fixed part of the model.
# Test based on 1000 permutations (default).
# }
# NOT RUN {
mvctm(fixed=cbind(y1,y2)~x1+x2,cluster=c("classroom"),
data=toydata,leveltested=1)
# }
# NOT RUN {
# Same as above but the rank scores are used.
# }
# NOT RUN {
mvctm(fixed=cbind(y1,y2)~x1+x2,cluster=c("classroom"),
data=toydata,leveltested=1, method="rank")
# }
# NOT RUN {
# Univariate 4-level model.
# Classrooms, nested within schools, nested within regions.
# The variance component at the region level is tested.
# The fixed effects are estimated with a linear mixed model.
# }
# NOT RUN {
mvctm(fixed=y1~x1+x2,cluster=c("region","school","classroom"),
data=toydata,leveltested=1,method="mixed")
# }
# NOT RUN {
# Same as above but the variance component at the school level is tested.
# }
# NOT RUN {
mvctm(fixed=y1~x1+x2,cluster=c("region","school","classroom"),
data=toydata,leveltested=2,method="mixed")
# }
# NOT RUN {
# Same as above but the variance component at the classroom level is tested.
# }
# NOT RUN {
mvctm(fixed=y1~x1+x2,cluster=c("region","school","classroom"),
data=toydata,leveltested=3,method="mixed")
# }
# NOT RUN {
# Univariate 3-level model.
# The variance component at the classroom level is tested.
# The fixed effects are removed with an M-estimator with the rlm function
# in the MASS package.
# Then the residuals from this fit are used to perform the test.
# The ~0 in the formula tells mvctm to use mresid directly to perform
# the test without any centering or transformation.
# }
# NOT RUN {
library("MASS")
toydata[,"mresid"]=rlm(y1~x1+x2,data=toydata)$residuals
mvctm(fixed=mresid~0,cluster=c("school","classroom"),
data=toydata,leveltested=2)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab