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.