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

Post on 17-Jun-2019

256 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Kriging dan CokrigingPraktikum 6 | Statistika Spasial

rahmaanisa@apps.ipb.ac.id

Outline

• Semivariance

• Variogram

• Ordinary Kriging

• Cokriging

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(

Meuse River Data Set

library(sp)

class(meuse)

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

class(meuse)

str(meuse)

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

data(meuse.riv)

lines(meuse.riv)

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)

Compute the number of point-pairs

meuse$logZn<-log10(meuse$zinc)

n <- length(meuse$logZn)

n * (n - 1)/2

[1] 11935

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

Plot the experimental variogram of the log-Zn concentrations

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

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.

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.

Display the variogram model forms which can be used in gstat

print(show.vgms())

Fit a spherical variogram model

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

range = 850,

nugget = 0.01)

print(plot(v, pl = T,

model = vm))

Adjust the model with gstat automatic fit

Adjust the parameters

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

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]

Display the structure of the kriging prediction object

Display the map of predicted values

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

asp=1, main="OK prediction,

log-ppm Zn"))

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?

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)))

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)))

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

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.

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")

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)

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"))

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?

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

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

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 ")

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)

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

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)")

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.

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).

Kandidat Peubah Penjelas

1. organic matter content (OM)

2. zinc content (Zn)

Tugas 1

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

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?

top related