0% found this document useful (0 votes)
157 views2 pages

Ordinary Kriging in R

1) The document describes performing ordinary kriging in R to predict air pollution (PM2.5) levels at unobserved locations based on observed data, using an exponential covariance model. 2) Maximum likelihood is used to estimate the parameters of the covariance model, which are then used in ordinary kriging to make predictions on a grid of unobserved locations and calculate associated variances. 3) The predicted values and associated standard errors are plotted over the region along with the observed data points and county borders.

Uploaded by

Paulo Brasil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
157 views2 pages

Ordinary Kriging in R

1) The document describes performing ordinary kriging in R to predict air pollution (PM2.5) levels at unobserved locations based on observed data, using an exponential covariance model. 2) Maximum likelihood is used to estimate the parameters of the covariance model, which are then used in ordinary kriging to make predictions on a grid of unobserved locations and calculate associated variances. 3) The predicted values and associated standard errors are plotted over the region along with the observed data points and county borders.

Uploaded by

Paulo Brasil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Ordinary Kriging in R

library(geoR);library(fields);library(maps)

#You will need to change the directory to load these files:


source("...\\plot.field.points.R")
load("...\\PM25.RData")

#Combine the spatial coordinates in a 84x2 matrix


s<-cbind(long,lat)

#Plot the data


plot.field.points(s,PM,map.border="county",cex=1.5)
X11()

#Estimate parameters by maximum likelihood:


ml <- likfit(data=PM,coords=s,
fix.nugget=F,cov.model="exponential",
ini = c(30, 5),nugget=5)
summary(ml)

#Create grid of prediction points:


sp1<-seq(min(s[,1]),max(s[,1]),length=100)
sp2<-seq(min(s[,2]),max(s[,2]),length=100)
sp<-expand.grid(sp1,sp2)
inCA<-map.where("state",x=sp[,1],y=sp[,2])
inCA[is.na(inCA)]<-"NA"
inCA<-inCA=="california"

#Perform ordinary Kriging (value of cov.pars and nugget are copied from mle output):
pred<-krige.conv(data=PM,coords=s,locations=sp,
krige=krige.control(cov.model="exponential",
cov.pars=c(14.73,6.144),
nugget=4.299))
pred$predict[!inCA]<-NA
pred$krige.var[!inCA]<-NA

#Plot the predicted values:


image.plot(sp1,sp2,matrix(pred$predict,100,100),zlim=range(PM))
map("county",add=T)

#Plot the standard errors:


image.plot(sp1,sp2,matrix(sqrt(pred$krige.var),100,100),zlim=c(2,3.5))
map("county",add=T)
points(s)
Output
Raw data: > summary(ml)
Parameters of the mean component (trend):
beta
6.6346
40

16
Parameters of the spatial component:
14
correlation function: exponential
(estimated) partial sill = 14.73
38

12
(estimated) range parameter = 6.144
locs[, 2]

10

Parameter of the error component:


36

8
(estimated) nugget = 4.299
6
34

-124 -122 -120 -118 -116

locs[, 1]

Predicted values Standard deviations


40

40

3.4
16

3.2
14
38

38

3.0
12

2.8
sp2

sp2

10
36

36

2.6
8

6 2.4
34

34

4 2.2

2.0

-124 -122 -120 -118 -116 -124 -122 -120 -118 -116

sp1 sp1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy