Moran's I for species richness data

Hello,

I am having issues retrieving a Moran's I statistic using the data that I have. I tried following the instructions given in this link

My species data csv was generated through simulation modeling using Netlogo where each cell is a patch (front yard) with corresponding plant species. The end result is a list of species found on each patch. Each patch comes with its own x y coordinates (pxcor, pycor). The max and min of the landscape is 0 to 99, on both sides.

I tried converting my coordinates file into an inverse matrix file which seems to be correct I think (maybe not). I am also having the problem of converting the Species file to a matrix. One thing to note is that a species can appear in more than one patch (location).
I tried to create the species matrix but I keep getting this error when I run both types of functions.

Moran.I(species_matrix, CoordsDF.dist.inv)
Error in Moran.I(species_matrix, CoordsDF.dist.inv) :
'weight' must have as many rows as observations in 'x'

When I use this test then I get this error
moran.test(species_matrix, CoordsDF.dist.inv)
CoordsDF.dist.invis not a listw object

My species file columns look like below, where pxcor = x and pycor = y coordinates

P.xcor P.ycor patch.ID Block.ID Species Number.in.yard
1 48 87 48_87 4302 species16 2
2 48 87 48_87 4302 species297 2
3 48 87 48_87 4302 species323 6

My coordinates file looks like below

pxcor pycor patch.ID block.ID patch.richness
1 56 36 56_36 1802 5
2 68 43 68_43 2103 7
3 50 34 50_34 1702 3

I am assuming not all the columns will be needed. The coordinates file has all the
coordinates for the entire landscape. Which I need to convert to an inverted distance matrix. I assume I did that correctly, with just using the coordinates not the rest of the info. I am not sure how to do the nearest neighbor transformation however (if that has to be done).
For the species file, I am not sure how to do the matrix. I followed the instructions but it is not working. A species can appear in more than one coordinate. I tried aggregating but not sure if I did that correctly.

My end goal is to see if there is spatial correlation (patterns) at different locations. I get confused as to how the coordinates inverted matrix is used with a species matrix to get a moran's I statistic. I'm probably doing it wrong. I tried uploading the csv's and it does not let me. Anything helps. Thank you.

I cannot help with the main question but a handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here between
```

```

I imagine that the length of your objects are different.

Ok I will try to post my data here. I did the dput function and it came out like this below.

structure(list(P.xcor = c(48L, 48L, 48L, 48L, 48L, 48L, 48L, 
48L, 38L, 38L), P.ycor = c(87L, 87L, 87L, 87L, 87L, 87L, 87L, 
87L, 47L, 47L), patch.ID = c("48_87", "48_87", "48_87", "48_87", 
"48_87", "48_87", "48_87", "48_87", "38_47", "38_47"), Block.ID = c(4302L, 
4302L, 4302L, 4302L, 4302L, 4302L, 4302L, 4302L, 2301L, 2301L
), Species = c("species16", "species297", "species323", "species391", 
"species291", "species237", "species166", "species371", "species209", 
"species86"), Number.in.yard = c(2L, 2L, 6L, 8L, 3L, 5L, 2L, 
1L, 9L, 10L)), row.names = c(NA, 10L), class = "data.frame")

Looks fine here. Thanks,

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.