1

アドニス関数を使用してレベルの組み合わせによるPERMANOVAコントラストのスクリプトの作成を開始しましたが、作成されたアドニスオブジェクトとレベルマトリックスの組み合わせが機能していないようです。私のコードは次のとおりです。

パッケージ

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

データセット

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

データ フレームの作成

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

ジャカードインデックス付きPERMANOVA

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

双方向PERMANOVAコントラスト

交流

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"))

平均推定

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

レベルの組み合わせ

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

治療レベル間の対比マトリックス

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

制約

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

誰か助けてくれませんか?

前もって感謝します、

4

0 に答える 0