---
title: "Assigment: Spatial Autocorrelation"
author: "A Student 某个学生"
date: "`r Sys.Date()`"
output:
html_document:
toc: TRUE
toc_float: TRUE
theme: "lumen"
code_folding: show
number_section: TRUE
fig_height: 4
fig_width: 6
fig_align: 'center'
---
This exercise continues the "Trend Surfaces" assignment.
You can either use your exercise markdown source or the Model Answers from that exercise.
Task: Load the "Trend Surfaces" exercise answers and execute all the code using the "Run All" toolbar command. This will place all the objects from the "Trend Surfaces" exercise into your workspace. Then save to an R Data file using `save.image`.
Then load here; use the `verbose=TRUE` option to see the objects that are loaded.
Task: load the `sp`, `gstat` and `nlme` packages.
This assignment follows the methods of "Tutorial: Trend surfaces in R", $\S9$ "Spatial Correlation of trend surface residuals" --$\S12$ "GLS-Regression Kriging".
# Spatial correlation of trend surface residuals
Task: Compute the empirical variogram of the 2nd-order trend surface residuals, with the default cutoff.
Q: What is the appoximate range of *local* spatial positive autocorrelation?
A:
Task: Re-compute the empirical variogram of the 2nd-order trend surface residuals, with this range as the cutoff (using the `cutoff` optional argument to the `variogram` function), and plot it.
Q: What are the estimated sill, range, and nugget of this variogram?
A:
# Trend surface analysis by Generalized Least Squares
Task: Compute the coefficients of a full second-order trend, using GLS. Initialize the `gls` correlation structure with the estimated parameters from the previous example.
If you indentified a nugget variance, specify `nugget=TRUE` in the argument to the `corExp` function inside the `gls` function. This must be initialized as a *proportion* of the total sill. So the `value` argument must be a vector (constructed with the `c` function) of the range parameter (recall: for an exponential model, 1/3 the effective range) and the proportional nugget.
Q: What are the range of spatial correlation and the nugget varia of the exponential model, as estimated by `gls`? Recalling that the range parameter in an exponential model is 1/3 of the effective range of spatial dependence, what is that? How do these compare with the estimates from the OLS trend?
A:
Task: Compare the coefficients from the GLS and OLS fits, as absolute differences and as percentages of the OLS fit.
Q: How much change is there between the OLS and GLS trend surface coefficients?
A:
Task: Predict over the grid with the GLS trend. and display the map.
Task: Display this map, alongside the OLS trend surface map, with the same color ramp.
Q: Are there obvious differences in these?
A:
Task: Compute the difference between the OLS and GLS trend surfaces, and map them.
Q: Where are the largest differences between the OLS and GLS trend surfaces? Explain why.
A:
# Local interpolation of the residuals
Task: Display the residuals from the GLS trend surface as a post- plot.
It is easiest to add the residuals as a field to the point observations `SpatialPointsDataFrame` and then display with the `bubble` function.
Q: Do these appear to be spatially autocorrelated?
A:
Task: Compute the empirical variogram model residuals from the GLS trend surface model, and model it with an exponential variogram function.
Q: What are the parameters of the fitted variogram? How well do these match the correlation structure fitted by `gls`?
A:
Task: Predict the residuals over the grid by OK,using the fitted variogram model.
Task: Display the OK predictions and their prediction standard deviations.
Q: Where are the biggest adjustments? Try to explain why.
A: GDD are lowered a lot in the Adirondacks, Green Mountains, Catskills and Allegheny Plateau. These are high elevation. They are also lowered along the Atlantic Coast, due to cooling from the ocean in the summer. They are higher near NYC and Philadelphia due to urban heat effect. Also higher along Lake Ontario and Lake Champlain due to autumn warmth in the lake water.
Task: Display the OK prediction standard deviations.
Q: Where are the largest and smallest prediction standard deviations? Why?
A:
# GLS-Regression Kriging
Task: Add the OK predictions of the GLS residuals to the prediction grid object, and then add this to the GLS trend surface prediction to obtain a final prediction.
Q: Compare the summary of the GLS-RK predictions with those from the GLS trend surface. Which has a wider range? Which has a higher median and mean?
A: