Chapter 4 Exercise 9.5

4.2 Data

This is equivalent to data step in SAS. Here, the data is imported from a file data.csv using the function read_csv. This function will download the file directly from here.

## Parsed with column specification:
## cols(
##   COL = col_double(),
##   ROW = col_double(),
##   YI = col_double()
## )
## # A tibble: 144 x 3
##      COL   ROW    YI
##    <dbl> <dbl> <dbl>
##  1     1     1     2
##  2     2     1     2
##  3     3     1     0
##  4     4     1     3
##  5     5     1     1
##  6     6     1     1
##  7     7     1     1
##  8     8     1     5
##  9     9     1    22
## 10    10     1    13
## # ... with 134 more rows

4.3 Autocorrelation statistics

## # A tibble: 1 x 4
##   `Moran's I` `Expected I` `Z randomization` `P value randomization`
##         <dbl>        <dbl>             <dbl>                   <dbl>
## 1       0.782     -0.00699              13.0                1.28e-38

## 
##  Geary C test under randomisation
## 
## data:  a$YI 
## weights: coords_listw 
## 
## Geary C statistic standard deviate = 8.8657, p-value < 2.2e-16
## alternative hypothesis: two.sided
## sample estimates:
## Geary C statistic       Expectation          Variance 
##       0.235058006       1.000000000       0.007444457

4.6 Variogram model selection

We will use the package gstat and automap for variogram model selection

## $exp_var
##     np     dist    gamma dir.hor dir.ver   id
## 1  264 1.000000 233.2400       0       0 var1
## 2  242 1.414214 388.5222       0       0 var1
## 3  680 2.152750 612.6985       0       0 var1
## 4  812 3.036881 756.8971       0       0 var1
## 5 1066 3.944315 783.1461       0       0 var1
## 6 1364 4.977586 742.6252       0       0 var1
## 
## $var_model
##   model    psill    range
## 1   Nug   0.0000 0.000000
## 2   Sph 782.9935 4.019145
## 
## $sserr
## [1] 1247749
## 
## attr(,"class")
## [1] "autofitVariogram" "list"
##      np      dist    gamma dir.hor dir.ver   id
## 1   506  1.198102 307.5054       0       0 var1
## 2   680  2.152750 612.6985       0       0 var1
## 3   812  3.036881 756.8971       0       0 var1
## 4   552  3.742751 784.3027       0       0 var1
## 5   834  4.280245 782.1560       0       0 var1
## 6  1044  5.132514 730.3844       0       0 var1
## 7  1028  6.012860 693.9058       0       0 var1
## 8   878  6.801676 675.9157       0       0 var1
## 9   836  7.525735 703.4337       0       0 var1
## 10  852  8.302717 728.0099       0       0 var1
## 11  792  9.194510 712.3311       0       0 var1
## 12  542 10.047104 621.2100       0       0 var1
## 13  452 10.826377 554.3985       0       0 var1
## 14  208 11.494850 599.2237       0       0 var1

##   model    psill    range
## 1   Nug   0.0000 0.000000
## 2   Sph 745.8602 3.765221
## Warning in fit.variogram(v_emp, vgm("Gau")): No convergence after 200
## iterations: try different initial values?