Edzer,

Glad to hear that I wasn't crazy -- thanks so much for looking into this (and so quickly). For now I'll divide by 1000 and use KM which is an easy and reasonable solution. Zev

Edzer Pebesma wrote:
Zev, if you do a

v.fit<-fit.variogram(v, vgm(0.0005, "Sph", 40000, 0.00001),debug.level=32)

you'll see that the X matrix of the Gauss-Newton iteration with the derivatives of the parameters to the error sum of squares is nearly singular. The condition number of this matrix is so large that it makes the problem ill-conditioned. If you add argument fit.ranges=FALSE it will not be singular anymore.

In the end, this problem is similar to e.g. regression of polynomials on coordinates without standardizing the coordinates.

I'll add a warning message to fit.variogram to suggest the two solutions, for this case.
--
Edzer

Zev Ross wrote:
Edzer (and all),

I don't think that it's related to an unrealistic range. I've tried a lot of different realistic and non-realistic values and get singular results each time. If I divide the X and Y coordinates by 10, 100, 1000 or 10000 I don't get singularity. Using Lat and Long works fine. Code is below and I included a link to a workspace with the "pol" data set at the bottom.

Zev

polA<-pol
coordinates(polA)<-~x+y
v<-variogram(pollutant~1, data=polA)
v.fit<-fit.variogram(v, vgm(0.0005, "Sph", 40000, 0.00001))
attributes(v.fit)$singular # TRUE

polB<-pol
polB$x<-polB$x/1000
polB$y<-polB$y/1000
coordinates(polB)<-~x+y
v<-variogram(pollutant~1, data=polB)
v.fit<-fit.variogram(v, vgm(0.0005, "Sph", 40, 0.00001))
attributes(v.fit)$singular #FALSE

polC<-pol
coordinates(polC)<-~longitude+latitude
v<-variogram(pollutant~1, data=polC)
v.fit<-fit.variogram(v, vgm(0.0005, "Sph", .4, 0.00001))
attributes(v.fit)$singular # FALSE

http://www.zevross.com/temp2/singular_or_not.RData

Edzer Pebesma wrote:
Hi Zev, it is hard to see what happens without seeing your data or R commands.

Is it possible that you passed an unrealistic value for the range parameter, as starting value for the variogram model argument of fit.variogram?
--
Edzer

Zev Ross wrote:
Hi All,

I'm fitting variograms in GSTAT with fit.variogram and I was surprised to find that all my fits were singular. I experimented with converting the data to unprojected data (decimal degrees) and with dividing my X and Y coordinates, which are in meters, by 1000 (to get KM). In both cases the fitting procedure worked with no singularity. Based on the numbers of pairs the bins appeared to be about the same so it appears to be a matter of the coordinates themselves.

I'd prefer not to have to convert the coordinates back and forth between meters and KM, any suggestions?

Zev

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo




_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to