[R-sig-Geo] Fitting variogram model using NLS function in R

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Sep 4 12:40:32 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

did you read the documentation of argument fit.method in function
gstat::fit.variogram?


On 09/04/2013 02:00 AM, Moshood Agba Bakare wrote:
> 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]]
> 
> _______________________________________________ R-sig-Geo mailing
> list R-sig-Geo at r-project.org 
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

- -- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251
83 33081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSJw4gAAoJEM1OCHCtOnfxjeMH/0CmRhzIYBhS44vTS4617G7G
h8E/owvIS9wWMBEDe85qRhnnDSHOu8NRpcsO0QFNIYjzGtzf6Crporf9RAvAbdkO
0m+3ZDQgqIOmwmDp+svQ41f9HvxDcszJWv/ijuSjIrFG5cRG6PzgYKwamwTw5miR
iVTUV2Syhxzpb72Or3TuadcBLF2JFEMMt/r3CMGZ2CszdIKSddMZDPf5ki0co3V3
nyR0pYNfq4dJdKzvTH8u0R9C6pCnTlYRoUFHfss3SSQfgbVEwZinVt2nBoUE4m41
ZSrYWLFkUVBOEHHbfGWb+WOc9Moz1ApCygmX5GYnPR9HZuPKHHcSgU2ErLRD30w=
=Bd64
-----END PGP SIGNATURE-----



More information about the R-sig-Geo mailing list