[R] partial mantel tests in ecodist with intential NA values.

Nevil Amos nevil.amos at gmail.com
Sat Dec 3 08:26:00 CET 2011


I would like to perform partial mantel tests  on only within group values, with "between group" values assigned to NA.
This is possible in package ncf partial.mantel.test, however this sues a different permutation to that used in ecodist.ecodist will not accept data with NA values, returning a "matrix is not square error.

is it possible to perform this test in ecodist?

many thanks

Nevil Amos

> library(ecodist)
> library(ncf)
> x<-sample(1:1000,20)
> y<-sample(1:1000,20)
> z<-sample(1:1000,20)
> M1<-as.matrix( distance(x))
> M2 <-as.matrix( distance(y ))
> M3<-as.matrix( distance(z ))
> D1<-(lower(M1))
> D2<-(lower(M2))
> D3<-(lower(M3))
> mantel(D1 ~ D2+D3, nperm=1000)
   mantelr      pval1      pval2      pval3  llim.2.5% ulim.97.5% 
0.09014696 0.10300000 0.89800000 0.18400000 0.01857311 0.18468621 
> partial.mantel.test(M1,M2,M3,quiet=T)
$MantelR
        r12         r13         r23       r12.3       r13.2 
 0.08977575  0.02170997 -0.01561346  0.09014696  0.02320821 

$p
[1] 0.09590410 0.30769231 0.47552448 0.09490509 0.30169830

$call
[1] "partial.mantel.test(M1 = M1, M2 = M2, M3 = M3, quiet = T)"

attr(,"class")
[1] "partial.Mantel"
> M1[1:10,11:20]<-NA
> M1[11:20,1:10]<-NA
> D1<-(lower(M1))
> mantel(D1 ~ D2+D3, nperm=1000)
Error in mantel(D1 ~ D2 + D3, nperm = 1000) : Matrix not square.
> partial.mantel.test(M1,M2,M3,quiet=T)
$MantelR
         r12          r13          r23        r12.3        r13.2 
 0.054906562  0.003446670 -0.015613460  0.054967403  0.004310979 

$p
[1] 0.2837163 0.4275724 0.4555445 0.2857143 0.4235764

$call
[1] "partial.mantel.test(M1 = M1, M2 = M2, M3 = M3, quiet = T)"

attr(,"class")
[1] "partial.Mantel"
Warning message:
In partial.mantel.test(M1, M2, M3, quiet = T) :
  Missing values exist; Pairwise deletion will be used


More information about the R-help mailing list