Dear All,
I tried to compare the result obtained by fitting the spherical variogram
model using fit.variogram and nls functions. The large difference in the
results is a great concern for me knowing that the two functions use
Weighted Least Squares (WLS) approach for estimating parameters. The steps
taken are as follows:

## Fit empirical semivariogram using gstat
empvar<-variogram(yield ~ 1,canmod.sp,cutoff= 400,width = 25, Cressie=TRUE)

# Fitting Spherical variogram model to sample variogram

sph.var<- vgm(psill =130, model = "Sph", range = 65, nugget = 180)
sph.mod<-fit.variogram(empvar, model = sph.var)
print(sph.mod)

The result obtain from fitting the spherical model to sample variogram is
sph.mod
  model         psill         range
1   Nug 230.917736411  0.0000000000
2   Sph 108.323055319 87.6889385431

The non-linear least squares (NLS) approach use by default s Gauss-newton
algorithm in an iterative search process. I used the initial values
obtained from the empirical variogram above (psill=130, range=65, and
nugget=180) as starting values for the iterative procedure.

## Define Spherical Variogram functions for NLS

sph.vgram <- function(dist, range, psill, nugget){
  dist <- dist/range
  nugget + psill*ifelse(dist < 1, (1.5 * dist - 0.5 * dist^3),1)
}

## Fitting spherical with NLS

fit.var <- nls(gamma~sph.vgram(dist,range,psill,nugget),data = empvar,
start=list(psill=130, range=65, nugget=180),trace=T)

The result obtained from the nls fitting is

Nonlinear regression model
  model:  gamma ~ sph.vgram(dist, range, psill, nugget)
   data:  empvar
      psill       range      nugget
 90.7071423 342.1025007 278.9542178
 residual sum-of-squares: 1140.67875

Number of iterations to convergence: 18
Achieved convergence tolerance: 9.79837651e-06

Could anyone explain why large difference in the two result? Is the R
script for fitting the NLS right? I am worried for having such disparity.
Thanks while looking forward to reading your suggestion, comments and
advice.
Moshood.

	[[alternative HTML version deleted]]

