kriging dan cokriging - stat.ipb.ac.id spatial statistics/p6 - kriging dan cokriging.pdf ·...

37
Kriging dan Cokriging Praktikum 6 | Statistika Spasial [email protected]

Upload: doanh

Post on 17-Jun-2019

266 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Kriging dan CokrigingPraktikum 6 | Statistika Spasial

[email protected]

Page 2: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Outline

• Semivariance

• Variogram

• Ordinary Kriging

• Cokriging

Page 3: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Semivariance

Regionalized variable theory uses a related property called the

semivariance to express the degree of relationship

between points on a surface.

The semivariance is simply half the variance of the

differences between all possible points spaced a constant distance apart.

Semivariance is a measure of the degree of spatial dependence between samples (elevation(

Page 4: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Meuse River Data Set

library(sp)

class(meuse)

coordinates(meuse) <- c("x", "y")

class(meuse)

str(meuse)

Page 5: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

plot(meuse, asp = 1, pch = 1)

data(meuse.riv)

lines(meuse.riv)

Page 6: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Display a postplot of the untransformed Zn values, that is, plotthe sample locations (as above) and represent the data value bythe size of the symbol.

plot(meuse, asp = 1,

cex = 4*meuse$zinc/max(meuse$zinc), pch = 1)

lines(meuse.riv)

Page 7: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Compute the number of point-pairs

meuse$logZn<-log10(meuse$zinc)

n <- length(meuse$logZn)

n * (n - 1)/2

[1] 11935

Page 8: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Compute the distance and semivariancebetween the first two points in the data setdim(coordinates(meuse))

[1] 155 2

coordinates(meuse)[1, ]

x y

181072 333611

coordinates(meuse)[2, ]

x y

181025 333558

(sep <- dist(coordinates(meuse)[1:2, ]))

1

2 70.838

(gamma <- 0.5 * (meuse$logZn[1] - meuse$logZn[2])^2)

[1] 0.0011441

Page 9: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Plot the experimental variogram of the log-Zn concentrations

(v <- variogram(logZn ~ 1, meuse, cutoff = 1300, width = 90))

Page 10: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Plot the experimental variogram of the log-Zn concentrationsprint(plot(v, plot.numbers = T))

The trend in decreasing

semivariance with decreasing

separation seems to intersect the y-

axis (i.e., at 0 separation) at about

0.01 log(mg kg-1)2; this is thenugget.

Page 11: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Variogram

The semivariance at a distance d = 0 should be zero, because there are no differences between points that are compared to themselves.

However, as points are compared to increasingly distant points, the semivariance increases.

Page 12: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Display the variogram model forms which can be used in gstat

print(show.vgms())

Page 13: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Fit a spherical variogram model

vm <- vgm(psill = 0.12, model = "Sph",

range = 850,

nugget = 0.01)

print(plot(v, pl = T,

model = vm))

Page 14: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Adjust the model with gstat automatic fit

Adjust the parameters

Page 15: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Theory of Ordinary Kriging

• The theory of regionalised variables leads to an ”optimal“ prediction method, in the sense that the kriging variance is minimized.

What is so special about kriging?

• Predicts at any point as the weighted average of the values at sampled points

• Weights given to each sample point are optimal, given the spatial covariance structure as revealed by the variogram model (in this sense it is “best”)

• The kriging variance at each point is automatically generated as part of the process of computing the weights

Page 16: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Ordinary kriging on a regular grid

> data(meuse.grid)

> coordinates(meuse.grid) <- c("x", "y")

> gridded(meuse.grid) <- T

Predict the attribute value at all grid points using Ordinary Kriging

Load the 40 m x 40 m interpolation grid covering the sample area and convert it to a spatial object

> k40 <- krige(logZn ~ 1, locations = meuse, newdata = meuse.grid, model = vmf)

[using ordinary kriging]

Page 17: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Display the structure of the kriging prediction object

Page 18: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Display the map of predicted values

print(spplot(k40, "var1.pred",

asp=1, main="OK prediction,

log-ppm Zn"))

Page 19: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Display the map of kriging prediction variances

print(spplot(k40, "var1.var",

col.regions=cm.colors(64),

asp=1,

main="OK prediction variance,

log-ppm Zn^2"))

Describe the variances map:

1. Where is the prediction variance lowest?

2. Does this depend on the data value?

Page 20: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Show the post-plot: value proportional to circle size

pts.s <- list("sp.points", meuse, col="white",

pch=1, cex=4*meuse$zinc/max(meuse$zinc))

print(spplot(k40, "var1.pred", asp=1, col.regions=bpy.colors(64),

main="OK prediction, log-ppm Zn",

sp.layout = list(pts.s)))

Page 21: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

show the observation locations on the kriggingprediction variance

pts.s <- list("sp.points", meuse, col="black", pch=20)

print(spplot(k40, zcol="var1.var", col.regions=cm.colors(64), asp=1,main="OK prediction variance, log-ppm Zn^2",sp.layout = list(pts.s)))

Page 22: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Evaluating the model

zn.okcv<-krige.cv(log(zinc)~1, meuse, meuse.grid, model = vmf)

RMSE.ok<-sqrt(sum(zn.okcv$residual^2)/length(zn.okcv$residual))

[1] 0.3973315

Page 23: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Co-Kriging

• Co-kriging allows samples of an auxiliary variable (also called the covariable),besides the target value of interest, to be used when predicting the target valueat unsampled locations. The co-variable may be measured at the same points asthe target (co-located samples), at other points, or both.

• The most common application of co-kriging is when the co-variable is cheaper tomeasure, and so has been more densely sampled, than the target variable.

Page 24: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Eksplorasi Data

data(meuse.riv)# outline of the river

meuse.lst <- list(Polygons(list(Polygon(meuse.riv)), "meuse.riv"))

meuse.sr <- SpatialPolygons(meuse.lst)

image(meuse.grid["dist"])# one of the variables in meuse.grid

plot(meuse.sr, add=TRUE)

title("distance to river")

Page 25: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Eksplorasi Data

par(mfrow=c(1,2))

plot(zinc ~ dist, meuse)

plot(log10(zinc) ~ sqrt(dist), meuse)

abline(lm(log10(zinc) ~ sqrt(dist), meuse),col=2)

Page 26: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Eksplorasi Data

zn.lm <- lm(log10(zinc) ~ sqrt(dist), meuse)

meuse$fitted.s <- predict(zn.lm,meuse)

-mean(predict(zn.lm,meuse))

meuse$residuals <- residuals(zn.lm)

spplot(meuse,c("fitted.s","residuals"))

Page 27: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Generate a new kriged surface with the covariate - distance to rivervm.ck <- variogram(log10(zinc)~sqrt(dist), meuse)

plot(vm.ck, plot.numbers = TRUE, pch = "+")

Secara visual, berapakah nilai sill, range, dannugget berdasarkan variogram di samping?

Page 28: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

m.ck <- fit.variogram(vm.ck,vgm(.3, "Sph", 800,.06))

plot(vm.ck, model=m.ck)

Page 29: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

ko.ck <- krige(log(zinc)~ sqrt(dist), meuse, meuse.grid,model=m.ck)

pts <- list("sp.points",meuse,pch=3,col="black")

meuse.layout <- list(pts)

spplot(ko.ck["var1.pred"], sp.layout=meuse.layout, main="co-kriging predictions-Zn/distance river ")

Page 30: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

ko.ck$sek <- sqrt(ko.ck$var1.var)

spplot(ko.ck,zcol='sek', sp.layout=meuse.layout, main = "co-kriging se-Zn(covariate)")

summary(ko.ck)

Page 31: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Evaluasi

zn.ckcv<-krige.cv(log(zinc)~ sqrt(dist), meuse,meuse.grid,model=m.ck)

RMSE.ck<-sqrt(sum(zn.ckcv$residual^2)/length(zn.ckcv$residual))

[1] 0.3752694

Page 32: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Back Transform

ko.ck$predt <- 10^(ko.ck$var1.pred)

spplot(ko.ck["predt"], sp.layout=meuse.layout, main = "Co-Kriging predictions-Meuse zinc log/backtrans(Zn)")

Page 33: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Target Variable

• We select lead (abbreviation “Pb”) as the target variable, i.e. the one we want to map. This metal is aserious human health hazard.

• It can be inhaled as dust from disturbed soil or taken up by plants and ingested.

• The critical value for Pb in agricultural soils, according to the Berlin Digital Environmental Atlas2, is600 mg kg-1 for agricultural fields: above this level grain crops can not be grown for humanconsumption.

Page 34: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Selecting the co-variables

Candidates for co-variables must have:

1. a feature-space correlation with the target variable;

2. a spatial structure (i.e. be modelled as a regional variable);

3. a spatial co-variance with the target variable.

Two main ways to select a co-variable:

1) theoretically, from knowledge of the spatial process that caused the observed spatial (co-)distribution;

2) empirically, by examining the feature-space correlations (scatterplots) and then the spatial co-variance (cross-correlograms or crossvariograms).

Page 35: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Kandidat Peubah Penjelas

1. organic matter content (OM)

2. zinc content (Zn)

Page 36: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Tugas 1

Lakukan prediksi Pb dengan menyertakan co-variables (OM atau Zn), diskusikan hasil yang Anda peroleh.

Page 37: Kriging dan Cokriging - stat.ipb.ac.id Spatial Statistics/P6 - Kriging dan Cokriging.pdf · •Co-kriging allows samples of an auxiliary variable (also called the covariable), besides

Tugas 2

• Perhatikan data yg tersedia pada alamat berikut:

https://raw.githubusercontent.com/raoy/Spatial-Statistics/master/database_Nickel.csv

• Keterangan variabel:• XCOLLAR: Longitude

• YCOLLAR: Latitude

• ZCOLLAR: Kedalaman

• Ni: Kandungan Nikel

Coba lakukan interpolasi dengan beberapametode yang telah Anda pelajari, bandingkanhasilnya, manakah interpolasi yang palingbaik menurut Anda?