6 views

Uploaded by faiq

berhubungan dengan autokorelasi spasial

- Matlab Coding -- First Slopes
- Homework 1 AMATH 301 UW
- rr311403-finite-element-method
- A New Approach to the Modeling of Distributed Structures for Control Meirovitch
- Crack Idenitification
- Paper a Bon Illo
- Image Analysis Matlab
- Chapter 8 - Two Dimensional Arrays
- 9783642036460-c1 (3)
- (Meentemeyer) Geographical Perspectives of Space, Time, And Scale
- Alcohol Outlet Density and Violence
- giscience
- Anselin - 1999 - The Future of Spatial Analysis in the Social Sciences the Future of Spatial Analysis in the Social Sciences
- Geo Dina Mik
- The impact of GIS application in the tourism development of Elbasan region
- 18 Matrix Math
- ECON 262-Mathematical Applications in Economics-Kiran Arooj
- Linear Algebra
- Introductio
- Lab 5 Tasks (1)

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)

- Matlab Coding -- First SlopesUploaded byTheodor Munteanu
- Homework 1 AMATH 301 UWUploaded byargo82
- rr311403-finite-element-methodUploaded bySRINIVASA RAO GANTA
- A New Approach to the Modeling of Distributed Structures for Control MeirovitchUploaded byhmalikn7581
- Crack IdenitificationUploaded byAnonymous 2HXuAe
- Paper a Bon IlloUploaded byAlex Bonillo
- Image Analysis MatlabUploaded bysumit2301
- Chapter 8 - Two Dimensional ArraysUploaded byAhmadali
- 9783642036460-c1 (3)Uploaded bymichael17ph2003
- (Meentemeyer) Geographical Perspectives of Space, Time, And ScaleUploaded byIaraMarques
- Alcohol Outlet Density and ViolenceUploaded bystochos
- giscienceUploaded byxixihaha05
- Anselin - 1999 - The Future of Spatial Analysis in the Social Sciences the Future of Spatial Analysis in the Social SciencesUploaded byMatt Tenney
- Geo Dina MikUploaded byEmanuel Banggut
- The impact of GIS application in the tourism development of Elbasan regionUploaded byMoldovan Petre
- 18 Matrix MathUploaded byRoberto Enrique Sanchez Aleman
- ECON 262-Mathematical Applications in Economics-Kiran AroojUploaded byHaris Ali
- Linear AlgebraUploaded byHLCPhantom
- IntroductioUploaded byyogesh sharma
- Lab 5 Tasks (1)Uploaded bymonkeemai
- 120214Uploaded bygamersam
- CT5440 Syllabus FD Modeling in Matlab_090315Uploaded byOmar Omario
- Data Portfolio PythonUploaded byKaka Kaka
- Math MatrixUploaded byAlaul Asif
- Fault Isolability Conditions for Linear Systems With Additive FaultsUploaded byEzeldeen Agory
- Matlab for Financial Application.docxUploaded byduc anh
- Modeling and Numerical Instability ProblemsUploaded bySunil Pandey
- Building Machine Learning Systems with Python - Second Edition - Sample ChapterUploaded byPackt Publishing
- 2aplfile Oct2aplfile AdmissionFormMBABBA17!2!17Uploaded bysarath kumar
- ASSIGNMENTUploaded byIswarya Purushothaman

- T2 Hotelling PadaUploaded byfaiq
- Jurnal Uji Kesejajaran GarisUploaded byfaiq
- Paper Proceedings Nast 2014Uploaded byfaiq
- T2-Hotelling_pada.pdfUploaded byfaiq
- AUTOKORELASI SPASIAL PPTUploaded byfaiq
- AUTOKORELASI SPASIAL PPTUploaded byfaiq
- proposalUploaded byfaiq
- Penerapan Metode Taguchi Untuk Meningkatkan Kualitas Kain TenunUploaded byfaiq

- Safety - Main Page - Natural Gas MSDS.pdfUploaded byRajesh Dubey
- Microsoft PowerPoint - Electric Motors.pptxUploaded byKAKASHIE Arwa
- 5.EOR.pptUploaded byMas Kuncrit
- 3Com 7750 User Guide ConfigUploaded byFranklin Miranda Robles
- LEVEL II - Cockpit_ Avionic & Equipment BaysUploaded bywagdi
- UT Dallas Syllabus for mkt6332.501 05s taught by Abhijit Biswas (axb019100)Uploaded byUT Dallas Provost's Technology Group
- Datasheet Schuetz Ecobulk Mx EnUploaded bykiller120
- 226455034 API 570 Part 1 Pipe ComponentsUploaded byAli Ahmed
- W417 E1 01+CS1W CIF31+User Manual OmronUploaded byAby Alexander Jacobo Medal
- Project EstimationUploaded bynanapopo
- Median ElevatorUploaded byAsgar Ali
- Question C12Uploaded byapi-26399985
- Report on AIMA Workshop on Recent Advances in Research MethodsUploaded byAbhishek Jain
- PMT02 - Multinational Multicultural Teams in Offshore IT ProjectsUploaded bySuhail Iqbal
- An Electricity Market for Germany’s Energy TransitionUploaded bylupoderi
- Valve types and symbols.pdfUploaded byHassan Albrehawy
- Energy DetectionUploaded byAvinash Avuthu
- Presion Capilary Historia de La SaturacionUploaded byJhonny Vacaflores Jimenez
- Instructions Fritz 11Uploaded byMakis Haritos
- IACS NDT ForginsUploaded byflore73
- IPR II FD (Manjusha Tiwari)Uploaded byVidit Harsulkar
- Thermal Physics - Rod in CylinderUploaded byLUIS HUMBERTO MARTINEZ PALMETH
- Cautions for Using Aluminum Electrolytic CapacitorsUploaded byFrank Gonzalez
- CCR ModellingUploaded byNguyễn Tiến Dũng
- Adams 0rthodontic LabUploaded bySajafe Ep
- Gabinete 1000Uploaded byFer Salgado
- FWIIne V0.4 Manual EngUploaded byAndrew Ryan
- implementation-of-soap-to-jdbc-synchronous-scenario.docUploaded byusha singh
- WinDFT Install and User GuideUploaded byAugusto Benevenuto Machado
- Fault Types That Can Occur on a System Are Placed in Five Error CategoriesUploaded byAdama Moussa Coulibaly