c173c273_lec17_w11[1]

c173c273_lec17_w11[1] - University of California, Los...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
University of California, Los Angeles Department of Statistics Statistics C173/C273 Instructor: Nicolas Christou Assign \NA values outside the area de
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ned by the observed data points In this document we will discuss how to assign \NA values to the area of the raster map outside the observed data points. We should always try to keep the predictions within the region de
Background image of page 2
ned by the data points. Kriging is an interpolator not extrapolator. We will use again the data from the Maas river at a <-read.table("http://www.stat.ucla.edu/~nchristo/statistics_c173_c273/ soil.txt", header=T) # Save the original image function: image.orig <-image We have also saved the original image function since we will work with the gstat package. The following commands have been discussed in
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
previous documents as well. #Create the grid: x.range <-as.integer(range(a[,1])) y.range <-as.integer(range(a[,2])) grd <-expand.grid(x=seq(from=x.range[1], to=x.range[2], by=50), y=seq(from=y.range[1], to=y.range[2], by=50)) #Create a gstat object: g <-gstat(id="log_lead", formula = log(lead)~1, locations = ~x+y, data =a) plot(variogram(g)) #Fit the variogram: v.fit <-fit.variogram(variogram(g), vgm(0.5,"Sph",1000,0.1)) plot(variogram(g),v.fit) #Perform ordinary kriging predictions: pr_ok <-krige(id="log_lead",log(lead)~1, locations=~x+y,model=v.fit, data=a, newdata=grd) #Collapse the vector of
Background image of page 4
the predicted values into a matrix: qqq <-matrix(pr_ok$log_lead.pred, length(seq(from=x.range[1], to=x.range[2], by=50)), length(seq(from=y.range[1], to=y.range[2], by=50))) #Create a raster map: image.orig(seq(from=x.range[1], to=x.range[2], by=50), seq(from=y.range[1],to=y.range[2], by=50), qqq, xlab="West to East",ylab="South to North", main="Predicted values") 1
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
#Add the observed data points on the raster map: points(a) Thecommandsabovewillcreatetherastermap: 179000179500180000180500181000330000331000332000333000Predicted valuesWest to EastSouth to North l ll l l l ll l l l l l l l l l l l llll l l ll l l l l l l l ll l l l l l ll l l l l l l l l l l l l l
Background image of page 6
l l l l l l l l l l l l l l ll ll ll l l l l l l l l l l l l l l ll l l l l ll l l l l l l l l l l l ll l l ll l l l l l ll l l l l l
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
l l l l l l l l l l ll l ll l l l ll l l l l ll l l We would like now to keep only the part of the raster map which is de
Background image of page 8
ned by the observed data points. We
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 40

c173c273_lec17_w11[1] - University of California, Los...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online