Search code examples
rspatialr-spgstat

Whats the difference between z~1 and z~LON+LAT in plotting variogram in R?


library(sp)
data(meuse)
coordinates(meuse)<-~x+y
v<-variogram(log(zinc)~1,meuse)
v
         np       dist     gamma dir.hor dir.ver   id
    1   57   79.29244 0.1234479       0       0 var1
    2  299  163.97367 0.2162185       0       0 var1
    3  419  267.36483 0.3027859       0       0 var1
    4  457  372.73542 0.4121448       0       0 var1
    .
    .

v1<-variogram(log(zinc)~x+y,meuse)
v1
            np       dist     gamma dir.hor dir.ver   id
        1   57   79.29244 0.1060834       0       0 var1
        2  299  163.97367 0.1829983       0       0 var1
        3  419  267.36483 0.2264256       0       0 var1
        4  457  372.73542 0.2847192       0       0 var1
        .
        .

From above following code and output I can found that log(zinc)~1 and log(zinc)~x+y returns the different gamma value for v and v1. What's the basic difference between these two operation?

help(variogram) told me that "formula defining the response vector and (possible) regressors, in case of absence of regressors, use e.g. z~1;".But,I didn't understand clearly these sentence! could anyone please tell me in details that when should I use z~1 or when should I use z~LON+LAT?


Solution

  • The first argument to variogram defines the model for the mean structure. in case of a constant mean, the model contains only an intercept, hence log(zinc)~1. If the mean is modelled as a linear regression model in x and y, then use log(zinc)~x+y. In that case, ordinary least squares residuals are computed as the basis for the semivariogram values, instead of measured log(zinc) values.