> #=========================================================#
> #FIX UJI AUTOKORELASI SPASIAL#
> #=========================================================#
> library(sp)
> library(ape)
> library(geosphere)
> library(pracma)
> library(mvtnorm)
> library(Runuran)
> library(coda)
>
>
> #PANGGILAN
>
> getwd()
[1] "C:/Users/ALLAH/Documents"
> ozone <- read.table("tij 110pb baru mei 2.csv",header=TRUE, sep=";")
> rata <- read.table("rata2 baru mei.csv",header=TRUE, sep=";")
> p <- read.table("length of i each j.csv",header=TRUE, sep=";")
>
> n=length(ozone[-(1:5),])*length(ozone[,1])
> n1=length(ozone[,1])
> n2=length(ozone[-(1:5),])
> n3=365
> n4=sum(p)
>
> datas <- ozone[,-(1:5)]
> data<-list()
> for (f in 1:n1) data[f]=list(datas[f,1:p[f,]])
>
> tj <- NULL
> for (f in 1:n1) tj[f] <- c(datas[f,p[f,]])
> rata2 <- rata$RATA.RATA
> mean.data.wilayah = rata2
> koordinat <- ozone[,2:3]
>
> ozone.dists <- as.matrix(dist(cbind(ozone$Long, ozone$Lat)))
> ozone.dists.inv <- 1/ozone.dists
> diag(ozone.dists.inv) <- 0
> ozone.dists.inv[1:5, 1:5]
1 2 3 4 5
1 0.000000 3.130749 2.868183 5.325525 2.632469
2 3.130749 0.000000 5.847130 3.557764 2.726813
3 2.868183 5.847130 0.000000 4.693390 4.740872
4 5.325525 3.557764 4.693390 0.000000 5.201668
5 2.632469 2.726813 4.740872 5.201668 0.000000
> ozone.dists.bin <- (ozone.dists > 0 & ozone.dists <= .2)
> Moran.I(rata2, ozone.dists.bin)
$observed
[1] 0.1730037
$expected
[1] -0.04761905
$sd
[1] 0.06633233
$p.value
[1] 0.0008809498
No comments:
Post a Comment