l.p <- c("georob", "ggplot2", "gstat", "rgl", "sf", "sp")
install.packages(l.p)5 Lab: 1. steps of geostatistical analysis
For the following exercises, use the R code of the lecture slides on the introduction to spatial data and the analysis of the Wolfcamp aquifer dataset as template.
5.1 Install required software
If you have done the computer practical of chapter 3 those packages are already installed and you can skip this step.
5.2 Exploratory analysis
We are now going to have a closer look into the elevation data contained in the package georob:
library(georob)
data(elevation)Plot height against the x- and y-coordinates. Consider adding a smooth LOESS curve to the scatterplots.
Create a “bubble plot” to explore the spatial distribution of the response variable. For the bubble plot, choose the size of the symbols such that their area depends linearly on height.
Explore the spatial distributions of height further by the dynamic graphics of the package rgl.
Does height show some large-scale trend? If yes, how would you build a regression model to model this trend?
5.3 Fitting a trend model
Fit the trend model that you found in the previous problem now by ordinary least squares.
Use customary residual diagnostics to see if the model can be improved.
Create a bubble plot of the residuals to see if the residuals show spatial auto-correlation.
5.4 Exploring and modelling auto-correlation
Using the function hscat() of the package gstat, create lag-scatter plots of the regression residuals. To use hscat() you have to convert the dataframe elevation to a spatial object with st_as_sf() (package sf).
Compute the sample variogram of the residuals and estimate the size of the nugget, total sill and range from the plot of the sample variogram.
Fit a “spherical” variogram function to the sample variogram. Use your guess estimates of the variogram parameters as initial values for model fitting.
Do the fitted parameter values differ much from your guesses?