berhubungan dengan autokorelasi spasial

© All Rights Reserved

6 views

berhubungan dengan autokorelasi spasial

© All Rights Reserved

- B Stat Courses
- Software Vendor Comparison Matrix (v0801)
- Dstr Assignment Question
- Midterm 2009
- Using GIS in human impact analysis of mangroves B Davis NJ Quinn 2004
- Safety in Numbers: Are Major Cities the Safest Places in the United States?
- tcs2
- Lecture 2
- Bachelor of Computer Science
- 3507[12-02-12]LASS XII -AG-9
- MATLAB Workshop Lecture 2
- GWR Presentation
- MOCK MME Sem-II-13
- Persian Character Recognition Using New
- matricea prioritizarii
- DA_CLP_05.pdf
- Information to Help You Start Your Research for Assignment1
- 3rdgrademod1vocabprocessgrid
- Dsp Lab Final
- Present Spatial Group New

You are on page 1of 35

rrahmaanisa@apps.ipb.ac.id

Autokorelasi temporal

set.seed(0)

d <- sample(100, 10)

d

a <- d[-length(d)]

b <- d[-1]

plot(a, b, xlab='t', ylab='t-1')

cor(a, b)

d <- sort(d)

d

a <- d[-length(d)]

b <- d[-1]

plot(a, b, xlab='t', ylab='t-1')

acf(d)

Autokorelasi

Spasial

??

Contoh Data Spasial

library(raster)

p <- shapefile(system.file("external/lux.shp", package="raster"))

p <- p[p$NAME_1=="Diekirch", ]

p$value <- c(10, 6, 4, 11, 6)

data.frame(p)

par(mai=c(0,0,0,0))

plot(p, col=2:7)

xy <- coordinates(p)

points(xy, cex=6, pch=20, col='white')

text(p, 'ID_2', cex=1.5)

Steps in determining the extent of spatial

autocorrelation in your data :

• Which areas are linked?

2. Assign weights to the areas that are linked

• Create a spatial weights matrix

3. Run statistical test to examine spatial autocorrelation

Step 1:

Choose a neighborhood criterion

Spatial weights matrices

• Neighborhoods can be defined in a number of ways

• Contiguity (common boundary)

• What is a “shared” boundary?

• Distance (distance band, K-nearest neighbors)

• How many “neighbors” to include, what distance do we use?

• General weights (social distance, distance decay)

Contiguity based neighbors

• Areas sharing any boundary point (QUEEN) are taken as neighbors, using the poly2nb function,

which accepts a SpatialPolygonsDataFrame

> library(spdep)

> w<-poly2nb(p)

• If contiguity is defined as areas sharing more than one boundary point (ROOK), the queen= argument

is set to FALSE

> w.rook<-poly2nb(p, queen=FALSE)

> coords<-coordinates(p)

> plot(p)

> plot(w, coords, add=T)

Queen contiguity Rook contiguity

Distance based neighbors

k nearest neighbors

• Can also choose the k nearest points as neighbors

> coords<-coordinates(p)

> IDs<-row.names(as(p, "data.frame"))

> p_kn2<-knn2nb(knearneigh(coords, k=2), row.names=IDs)

k=2

> p_kn4<-knn2nb(knearneigh(coords, k=4), row.names=IDs)

k=1

k=3

> plot(p)

> plot(p_kn2, coords, add=T)

k=1 k=2 k=4

Distance based neighbors : Specified distance

• Can also assign neighbors based on a specified distance

> summary(dist)

Min. 1st Qu. Median Mean 3rd Qu. Max.

0.07316 0.07316 0.14159 0.11832 0.14159 0.16213

> max_k1<-max(dist)

dist=1*max_k1

> p_kd2<-dnearneigh(coords, d1=0, d2=1*max_k1, row.names=IDs)

> p_kd3<-dnearneigh(coords, d1=0, d2=1.5*max_k1, row.names=IDs)

> p_ran1<-dnearneigh(coords, d1=0, d2=0.16123, row.names=IDs)

Distance=0.75*max_k1 Distance=1*max_k1 Distance=1.5*max_k1

Step 2:

Assign weights to the areas that are linked

Creating spatial weights matrices using neighborhood lists

Spatial weights matrices

• Once our list of neighbors has been created, we assign spatial weights

to each relationship

• Can be binary or variable

• Even when the values are binary 0/1, the issue of what to do with no-

neighbor observations arises

neighboring features and 0 to all other features

• Used with fixed distance, k nearest neighbors, and contiguity

Row-standardized weights matrix

> p_nbq_w<- nb2listw(w) • Row standardization is used to create

proportional weights in cases where

> p_nbq_w

features have an unequal number of

neighbors

• Divide each neighbor weight for a

feature by the sum of all neighbor

weights

• Obs i has 3 neighbors, each has a weight

of 1/3

• Obs j has 2 neighbors, each has a weight

of 1/2

parameters across different data sets

with different connectivity structures

Binary weights

> w_nbq_wb<-nb2listw(w, style="B") • Row-standardised weights increase

> w_nbq_wb the influence of links from

observations with few neighbours

• Binary weights vary the influence of

observations

• Those with many neighbours are up-

weighted compared to those with few

Binary vs. row-standardized

• A binary weights matrix looks like: 0 1 0 0

0 0 1 1

1 1 0 0

0 1 1 1

0 0 .5 .5

.5 .5 0 0

0 .33 .33 .33

Style Options

Code Description

B basic binary coding

W row standardised (sums over all links to n)

C globally standardised (sums over all links to n)

U equal to C divided by the number of neighbours (sums over all

links to unity)

Regions with no neighbors

• If you ever get the following error:

Step 3:

Examine spatial autocorrelation

Using spatial weights matrices, run statistical tests of spatial autocorrelation

Spatial autocorrelation

• Test for the presence of spatial autocorrelation

• Global

• Moran’s I

• Geary’s C

• Local (LISA – Local Indicators of Spatial Autocorrelation)

• Local Moran’s I and Getis Gi*

Autokorelasi Spasial

library(spdep)

w <- poly2nb(p, row.names=p$Id)

class(w)

summary(w)

str(w)

plot(p, col='gray', border='blue', lwd=2)

plot(w, xy, col='red', lwd=2, add=TRUE)

wm <- nb2mat(w, style='B')

wm

Autokorelasi Spasial

???

???

Menghitung Indeks Moran (1)

#compute Moran's Index pm <- matrix(yiyj, ncol=n)

pmw <- pm * wm

n <- length(p) pmw

y <- p$value spmw <- sum(pmw)

ybar <- mean(y) spmw

x smw <- sum(wm)

#####1st method sw <- spmw / smw

dy <- y - ybar vr <- n / sum(dy^2)

g <- expand.grid(dy, dy) MI <- vr * sw

yiyj <- g[,1] * g[,2] MI

EI <- -1/(n-1)

#####2nd method EI

yi <- rep(dy, each=n)

yj <- rep(dy)

yiyj <- yi * yj

Menghitung Indeks Moran (2)

#compute moran's using spdep function

ww <- nb2listw(w, style='B')

ww

#Note that

Szero(ww)

# is the same as

pmw

Moran’s I in R

> moran.test(p$value, listw=ww, randomisation=FALSE, alternative=‘less’)

“two.sided” → HA: I ≠ I0

“greater” → HA: I > I0

Diagram Pencar Moran

n <- length(p) reg <- lm(ams[,2] ~ ams[,1])

ms <- cbind(id=rep(1:n, each=n), abline(reg, lwd=2)

y=rep(y, each=n), abline(h=mean(ams[,2]), lt=2)

value=as.vector(wm * y))

abline(v=ybar, lt=2)

ms <- ms[ms[,3] > 0, ]

coefficients(reg)[2]

ams <- aggregate(ms[,2:3], list(ms[,1]),

FUN=mean) rwm <- mat2listw(wm, style='W')

ams <- ams[,-1] # Checking if rows add up to 1

colnames(ams) <- c('y', 'spatially lagged y') mat <- listw2mat(rwm)

head(ams) apply(mat, 1, sum)[1:15]

plot(ams) moran.plot(y, rwm)

Moran Scatter Plot

rwm <- mat2listw(wm, style='W')

mat <- listw2mat(rwm)

apply(mat, 1, sum)

moran.plot(y, rwm)

Moran Scatter Plot

Latihan

• Input data berikut:

kemiskinan<-read.csv("http://bit.ly/dataKemiskinan",sep=',',header=T)

bobot<-read.csv("http://bit.ly/bobot_kemiskinan",sep=',',header=F)

Latihan

• Mengubah data bobot ke dalam bentuk matriks

bot<-as.matrix(bobot)

w=mat2listw(bot)

moran(kemiskinan$Y, listw=w, n=112, S0=Szero(w))

Latihan

• Menghitung indeks moran lokal

localmoran(kemiskinan$Y, w)

moran.plot(kemiskinan$Y, mat2listw(bot,style='W'),

labels=kemiskinan$Nama.Kabupaten)

- B Stat CoursesUploaded byMirza Ahad Baig
- Software Vendor Comparison Matrix (v0801)Uploaded bydkuperman
- Dstr Assignment QuestionUploaded byJia Wei
- Midterm 2009Uploaded byRabiah
- Safety in Numbers: Are Major Cities the Safest Places in the United States?Uploaded bynextSTL.com
- Using GIS in human impact analysis of mangroves B Davis NJ Quinn 2004Uploaded byJacque C Diver
- tcs2Uploaded byRam Kumar
- Lecture 2Uploaded byBarış Biçer
- Bachelor of Computer ScienceUploaded bygayatri07
- 3507[12-02-12]LASS XII -AG-9Uploaded byparidhi_1095
- MATLAB Workshop Lecture 2Uploaded byMuhammad Waqas
- GWR PresentationUploaded byzibunans
- MOCK MME Sem-II-13Uploaded byTeddy Jain
- Persian Character Recognition Using NewUploaded byAnonymous F1whTR
- matricea prioritizariiUploaded byAndrei Enache
- DA_CLP_05.pdfUploaded byaguilas,blancas
- Information to Help You Start Your Research for Assignment1Uploaded byIan Dominic Gonsalves
- 3rdgrademod1vocabprocessgridUploaded byapi-261399250
- Dsp Lab FinalUploaded byAnonymous V7P5fNQI
- Present Spatial Group NewUploaded byNur Farzana Muhamad Ismail
- power doman scan chain allocaiton and re-orderingUploaded byBaluvu Jagadish
- AbaqusStandard+1.1.22+UELUploaded byMohit1234zxt
- The Spatial Dimension of Human Development Index in IndonesiaUploaded byikutmilis
- 1er Articulo TesisUploaded byAnonymous ljsBzy
- AICTE Syllabus 2018-19 -Common.pdfUploaded bySonuSingh
- Anjard95-ManagementAndPlanningToolsUploaded byMega Inayati Rif'ah
- FEM bits (1)Uploaded byDarbhalaPavanKumar
- Lecture 1428551057Uploaded byVinayaga Moorthy
- downloadUploaded byravi
- IDKUploaded byAhmad Faraz Khan

- lec25Uploaded byAbani
- Visual GansUploaded byDeepika Naryani
- Data Acquisition Analysis Using the Fourier TransformUploaded byssener
- Arabic Speech Recognition SystemsUploaded byAbdelkbir Ws
- Offline text document authorization on the basis SIFT and SURFUploaded byIJSTE
- mid point circleUploaded byejaz123456
- Comparison of Mamdani-Type and Sugeno-Type Fuzzy Inference Systems for Air Conditioning SystemUploaded bySugeng Murdowo
- Computational Beauty of NatureUploaded byDaitsu Nagasaki
- Ct6 SyllabusUploaded byMeher Shiva
- eikonal.pdfUploaded bynewgate05
- ebt410_l11_2007Uploaded byrameshsme
- Stochastic Open Pit Design NFA JvanEldertUploaded byFrancisco Javier Villaseca Ahumada
- COMPUSOFT, 3(7), 1024-1029.pdfUploaded byIjact Editor
- TOC_Questions_012210030237_1Uploaded byPrabhu Dhandapani
- Structural vs FunctionalUploaded byAzan Momin
- repet 1Uploaded byees_bis
- QB-CFDUploaded byAbhishek Ajansondkar
- Uncertainty Quantification of an Aeroelastic System using Polynomial Chaos Expansion.pdfUploaded byVenkatesh Iyer
- IITK-DS--CS210-2012Uploaded byS Sai Krishna Prasad
- Assignment#3 Report .PDFUploaded byseraj ibramem
- Quiz Machine LearningUploaded byMatt
- Association Analysis Basic Concepts and AlgorithmsUploaded byAshoka Vanjare
- 2016 CSE 259 LPAA Lec2 a AnalysisUploaded bychyon
- 2013Uploaded byArpita Paul
- DspUploaded byBineilKcThapa
- Exam 2013 SolutionUploaded byRen Yang Yap
- Add Maths 2016Uploaded byYuvaraj Tan Hong Leong
- Smith WatermanUploaded byjincy
- Power Systems Engineering syllabusUploaded byvinodlife
- ciancone tuning methodUploaded byNazif Jaafar