<font face="trebuchet ms,sans-serif">Augusto,<br><br>Você deve crias os contrastes de Tukey. Não há função para isso. Você deve criar exatamente da maneira como você quer comparar, ou seja, pelas suas explicações, comparar níveis de B (pairwise) fixando níveis de A. Combinando as funções que o R possui (combn, apply, contrast, multcomp) a tarefa fica simples.<br>
<br><span style="font-family: courier new,monospace;">da <- expand.grid(A=gl(3,1), B=gl(4,4))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">da$y <- rnorm(nrow(da))</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">require(nlme)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">m0 <- gls(y~A*B, da)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">anova(m0)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># comparar níveis (pairwise) de B fixando nível de A (contrastes de Tukey)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">choose(nlevels(da$B), 2) # número de comparações</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">cpr <- combn(nlevels(da$B), 2); cpr # as comparações</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Blev <- levels(da$B)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Alev <- levels(da$A)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">cpr.names <- paste("B", cpr[1,], "-", "B", cpr[2,], sep="")</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">require(contrast)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">cpr.list <- lapply(cpr.list, t)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">cpr.list # matriz de contrastes de Tukey entre B fixando A</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">c0 <- apply(cpr, 2,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> function(i){</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> c1 <- contrast(m0, list(A=Alev[1], B=Blev[i[1]]),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> list(A=Alev[1], B=Blev[i[2]]))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> c1$X</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> })</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">colnames(c0) <- paste("A", Alev[1], "/", cpr.names, sep="")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">c0</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">require(multcomp)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">glht(m0, linfct=t(c0)) # repetir para os demais níveis de A</span><br style="font-family: courier new,monospace;"><br>À disposição.<br>Walmes.<br><br clear="all"></font><span style="font-family:trebuchet ms,sans-serif">==========================================================================</span><br style="font-family:trebuchet ms,sans-serif">
<span style="font-family:trebuchet ms,sans-serif">Walmes Marques Zeviani</span><br style="font-family:trebuchet ms,sans-serif"><span style="font-family:trebuchet ms,sans-serif">LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)</span><br style="font-family:trebuchet ms,sans-serif">
<span style="font-family:trebuchet ms,sans-serif">Departamento de Estatística - Universidade Federal do Paraná</span><br style="font-family:trebuchet ms,sans-serif"><span style="font-family:trebuchet ms,sans-serif">fone: (+55) 41 3361 3573</span><br style="font-family:trebuchet ms,sans-serif">
<span style="font-family:trebuchet ms,sans-serif">VoIP: (3361 3600) 1053 1173</span><br style="font-family:trebuchet ms,sans-serif"><span style="font-family:trebuchet ms,sans-serif">e-mail: <a href="mailto:walmes@ufpr.br" target="_blank">walmes@ufpr.br</a></span><br style="font-family:trebuchet ms,sans-serif">
<span style="font-family:trebuchet ms,sans-serif">twitter: @walmeszeviani</span><br style="font-family:trebuchet ms,sans-serif"><span style="font-family:trebuchet ms,sans-serif">homepage: <a href="http://www.leg.ufpr.br/%7Ewalmes" target="_blank">http://www.leg.ufpr.br/~walmes</a></span><br style="font-family:trebuchet ms,sans-serif">
<span style="font-family:trebuchet ms,sans-serif">linux user number: 531218</span><br style="font-family:trebuchet ms,sans-serif"><span style="font-family:trebuchet ms,sans-serif">==========================================================================</span><br>