c173c273_lec7_w11[1]

c173c273_lec7_w11[1] - University of California Los Angeles...

Info iconThis preview shows pages 1–4. 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 Working with gstat - An example We will use the data from the Meuse (Dutch Maas ) river. The actual data set contains many variables but here we will use the x,y coordinates and the concentration of lead and zinc in ppm at each data point. The motivation for this study is to predict the concentration of heavy metals around the banks of the Maas river in the area west of the town Stein in the Netherlands. These heavy metals were accumulated over the years because the river pollution. Here is the area of study: 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
You can access the data at > a <- read.table("http://www.stat.ucla.edu/~nchristo/statistics_c173_c273/soil.txt", header=T) To load the gstat package type > library(gstat) First, we will compute the descriptive statistics of the data set, construct the stem-and-leaf plots, histograms, and boxplots: > stem(a$lead) > boxplot(a$lead) > hist(a$lead) > stem(a$zinc) > boxplot(a$zinc) > hist(a$zinc) > summary(a) Transform the data (logarithm transformation): > log_lead <- log10(a$lead) > log_zinc <- log10(a$zinc) > stem(log_lead) > boxplot(log_lead) > hist(log_lead) > stem(log_zinc) > boxplot(log_zinc) > hist(log_zinc) Create a gstat object: > g <- gstat(id="log_lead", formula = log(lead)~1, locations = ~x+y, data = a) Note: If you have already converted the data frame a into a SpatialPointsDataFrame using: > coordinates(a) <- ~x+y you cannot redefine the coordinates in the gstat object. Instead you can use: > g <- gstat(id="log_lead", formula = log(lead)~1, data = a) 2
Background image of page 2
Type variogram(g) to see: > variogram(g) np dist gamma dir.hor dir.ver id 1 57 79.29244 0.1046520 0 0 log_lead 2 299 163.97367 0.1965929 0 0 log_lead 3 419 267.36483 0.2507668 0 0 log_lead 4 457 372.73542 0.3330690 0 0 log_lead 5 547 478.47670 0.3875716 0 0 log_lead 6 533 585.34058 0.4817750 0
Background image of page 3

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

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

This note was uploaded on 02/11/2012 for the course STATS c173/c273 taught by Professor Nicolaschristou during the Spring '11 term at UCLA.

Page1 / 8

c173c273_lec7_w11[1] - University of California Los Angeles...

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

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