Nicolle Salamanca
Ejercicio Materia Orgánica
set.seed(12345)
MO=rnorm(n = 176,mean = 3,sd = 0.5)
xy=expand.grid(x=seq(0,10),y=seq(0,15))
plot(xy,col=MO,pch=19)
df<-data.frame(MO)
mo.matrix<-as.matrix(dist(cbind(xy$x,xy$y)))
dim(mo.matrix)
[1] 176 176
mo.matrix.inv<- 1/mo.matrix
diag(mo.matrix.inv)<-0
mo.matrix.inv[1:5, 1:5]
1 2 3 4 5
1 0.0000000 1.0000000 0.5 0.3333333 0.2500000
2 1.0000000 0.0000000 1.0 0.5000000 0.3333333
3 0.5000000 1.0000000 0.0 1.0000000 0.5000000
4 0.3333333 0.5000000 1.0 0.0000000 1.0000000
5 0.2500000 0.3333333 0.5 1.0000000 0.0000000
library(ape)
Moran.I(MO, mo.matrix.inv)
$observed
[1] -0.005975151
$expected
[1] -0.005714286
$sd
[1] 0.006731909
$p.value
[1] 0.9690892