1

I started to create a script for a PERMANOVA contrasts by combination of levels using adonis function, but doesn't seem to be working a combination of levels matrix with adonis object created, my code was:

Packages

require(vegan)
require(doBy)
require(wzRfun)
require(multcomp)

Data set

data(mite)
A = c(rep(c(0), 30), rep(c(1), 30))
B = rep(c(rep(c(0), 15), rep(c(1), 15)), 2) 

Create data frame

A <- as.factor(A)
B <- as.factor(B)
species <- mite[1:60,]

PERMANOVA with Jaccard index

man.com<-adonis(species ~ A * B, method = "jaccard",permutations=999)
man.com

Two-Way PERMANOVA Contrasts

Interaction

A_B<- interaction(A, B)
levels(A_B)
do.call(rbind, strsplit(levels(A_B), "\\."))


g0 <- adonis(species ~ A * B, method = "jaccard",permutations=999)
g1 <- adonis(species ~ A_B, method = "jaccard",permutations=999)

M <- LSmatrix(g0, effect=c("A","B"))

Mean estimation

data.frame(g0=M%*%coef(g0), g1=coef(g1))

Combination of levels

str(M)
grid <- attr(M, "grid")

Matrix of contrasts between levels of treatement

B <- "b"
A <- "a"
spl <- interaction(grid[,2])
i <- 1:nrow(grid)
l <- split(i, f=spl)
contr <- lapply(l,
                function(row){
                    ## Contrast matrix parwise
                    a <- apc(M[row,], lev=levels(d[,2]))
                    rownames(a) <- paste(spl[row[1]],
                                         rownames(a), sep="/")
                    return(a)
                })
contr <- do.call(rbind, contr)
contr

Constrasts

summary(glht(g0, linfct=contr),
        test=adjusted(type="fdr"))

Could somebody please help me,

Thanks in advance,

Dave
  • 434
  • 5
  • 22
Leprechault
  • 1,531
  • 12
  • 28
  • can you explain what is not working for you? you can definitely get more help –  Feb 11 '16 at 15:20
  • In mean estimation the script dont create LSmatrix – Leprechault Feb 11 '16 at 15:26
  • FWIW, this question was cross-posed to the R-sig-eco mail list today as well: https://stat.ethz.ch/pipermail/r-sig-ecology/2016-February/005283.html – Richard Erickson Feb 11 '16 at 16:04
  • Richard Erickson please post your answer here or in R-sig-eco mail, no problem! – Leprechault Feb 11 '16 at 19:02
  • Obviously `LSmatrix` does not know `adonis` objects. What made you believe it would? – Jari Oksanen Feb 12 '16 at 13:12
  • What an honor Jari Oksanen, thank for you answer. Give you another solution for me? – Leprechault Feb 12 '16 at 13:19
  • `LSmatrix` was the first problem, but actually the smallest one. The procedures your try to apply are all for parametric models, and you would need things like *t*-values, `vcov` (variance-covariance matrices of parameters) etc. that do not exist in `adonis`. We do not use parametric tests with `adonis` but only permutation tests. You should build your procedure around those permutation tests. – Jari Oksanen Feb 12 '16 at 17:10
  • Kay Cichini has written about test designs in `adonis`. Here one entry, but there are others http://www.r-bloggers.com/two-way-permanova-with-vegan-function-adonis-using-customized-contrasts/ – Jari Oksanen Feb 12 '16 at 17:13
  • Thanks Jari Oksanen, I will read a Kay posts!!! – Leprechault Feb 12 '16 at 18:03
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/103329/discussion-between-leprechault-and-jari-oksanen). – Leprechault Feb 12 '16 at 19:02

0 Answers0