The procedure return a GeoFit object associated to the estimated residuals. For a random field Y defined on the real line (Gaussian, Skew Gaussian, Tukeyh etcc) they are computed as (Y-m)/sqrt(v) where m and v are the estimated mean and variance respectively. For a random field Y defined on the positive real line (Gamma, Weibull, Log-Gaussian) they are computed as Y/m where m is the estimated mean. In the first case residuals have zero mean and unut variance with a specific distribution defined on the real line. In the second case residuals have unit mean with a specific distribution defined on the positive real line. When the function is coupled with the functions GeoQQ and GeoCovariogram, it is useful as diagnostic tool (See examples).
UTF-8
library(GeoModels)##############################Example 1: Residuals using a Gaussian RF###########################set.seed(211)model="Gaussian";N=700# number of location sites# Set the coordinates of the points:x = runif(N,0,1)y = runif(N,0,1)coords=cbind(x,y)# regression parametersmean =5mean1=0.8X=cbind(rep(1,N),runif(N))# correlation parameters:corrmodel ="Wend0"sill =1nugget =0scale =0.3power2=4param=list(mean=mean,mean1=mean1, sill=sill, nugget=nugget, scale=scale,power2=power2)# Simulation of the Gaussian RF:data = GeoSim(coordx=coords, corrmodel=corrmodel, X=X,model=model,param=param)$data
start=list(mean=mean,mean1=mean1, scale=scale,sill=sill)fixed=list(nugget=nugget,power2=power2)# Maximum composite-likelihood fitting fit = GeoFit(data,coordx=coords, corrmodel=corrmodel,model=model,X=X, likelihood="Conditional",type='Pairwise',start=start, fixed=fixed,neighb=3)res=GeoResiduals(fit)mean(res$data)# should be approx 0var(res$data)# should be approx 1# checking goodness of fit marginal modelGeoQQ(res);GeoQQ(res,type="D",col="red",ylim=c(0,0.5),breaks=20);# Empirical estimation of the variogram for the residuals:vario = GeoVariogram(res$data,coordx=coords,maxdist=0.5)# Comparison between empirical amd estimated semivariogram for the residualsGeoCovariogram(res, show.vario=TRUE, vario=vario,pch=20)##############################Example 2: Residuals using a Weibull RF###########################model="Weibull";shape=4N=700# number of location sites# Set the coordinates of the points:x = runif(N,0,1)y = runif(N,0,1)coords=cbind(x,y)# regression parametersmean =5mean1=0.8X=cbind(rep(1,N),runif(N))# correlation parameters:corrmodel ="Wend0"sill =1nugget =0scale =0.3power2=4param=list(mean=mean,mean1=mean1, sill=sill, nugget=nugget, scale=scale,shape=shape,power2=power2)# Simulation of the Gaussian RF:data = GeoSim(coordx=coords, corrmodel=corrmodel, X=X,model=model,param=param)$data
I=Infstart=list(mean=mean,mean1=mean1, scale=scale,shape=shape)lower=list(mean=-I,mean1=-I, scale=0,shape=0)upper=list(mean= I,mean1= I, scale=I,shape=I)fixed=list(nugget=nugget,sill=sill,power2=power2)# Maximum composite-likelihood fitting fit = GeoFit(data,coordx=coords, corrmodel=corrmodel,model=model,X=X, likelihood="Conditional",type='Pairwise',start=start, optimizer="nlminb", lower=lower,upper=upper, fixed=fixed,neighb=3)res=GeoResiduals(fit)mean(res$data)# should be approx 1# checking goodness of fit marginal modelGeoQQ(res);GeoQQ(res,type="D",col="red",ylim=c(0,1.7),breaks=20);# Empirical estimation of the variogram for the residuals:vario = GeoVariogram(res$data,coordx=coords,maxdist=0.5)# Comparison between empirical amd estimated semivariogram for the residualsGeoCovariogram(res, show.vario=TRUE, vario=vario,pch=20)