[R-sig-eco] Help PCNM analysis

Jari Oksanen jari.oksanen at oulu.fi
Wed Oct 5 12:46:25 CEST 2011


On Wed, 2011-10-05 at 10:25 +0200, Emma Gothe wrote:
> Dear list members!
> 
> I am trying to perform a PCNM analysis with function PCNM() (binary package provided by the provided by project Spatial ecological data analysis with R). I recently ran into a problem. I have a triangular distance matrix based on the shortest distance between my sampling points which I am using in the PCNM function instead of geographic coordinates. When I tried to perform the analysis on this distance matrix I got an error message (see below) that says I have "empty neighbor sites". I have used the same code and the exactly same type of distance matrices before and I did not have any problem. I have also searched my distance matrix for ev. missing values/other obvious errors and tried to search for a solution online but without any luck.
> 
> The file "Eucl stream order1.txt" is attached and my code is:
> 
> > dist.matr <- read.delim("Eucl stream order1.txt",row.names=1)
> > dist <- as.dist(dist.matr)
> > PCNM.auto=PCNM(dist)
> Truncation level = 1092.48
> Error in as.matrix(listw2sn(nb2listw(nb))[, 1:2]) :
>   error in evaluating the argument 'x' in selecting a method for function 'as.matrix': Error in nb2listw(nb) : Empty neighbour sets found
> Timing stopped at: 0.01 0 0.02
> 
> If anyone could help me to figure this out, and have suggestions for a solution I would be very greatful!
> 
Emma,

I don't know about the PCNM package, but the matrix goes smoothly true
vegan::pcnm:

> library(vegan)
Loading required package: permute
This is vegan 2.0-0
> dist.matr <- read.delim("Eucl stream order1.txt",row.names=1)
> dist <- as.dist(dist.matr)
> p <- pcnm(dist)
> str(p)
List of 4
 $ vectors  : num [1:30, 1:19] -0.2245 -0.2239 -0.2249 -0.2907
-0.0212 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:30] "A2" "A3" "A4" "A5" ...
  .. ..$ : chr [1:19] "PCNM1" "PCNM2" "PCNM3" "PCNM4" ...
 $ values   : num [1:29] 71640230 66080002 58129580 29179643
16447538 ...
 $ weights  : num [1:30] 1 1 1 1 1 1 1 1 1 1 ...
 $ threshold: num 1092
 - attr(*, "class")= chr "pcnm"

Cheers, Jari Oksanen



More information about the R-sig-ecology mailing list