gstat error: singular matrix in function LDLfactor()
karl.sommer at dpi.vic.gov.au wrote:
When performing ordinary kriging under gstat in R I received the following error after the program had stopped. ---R output vert.ok <- krige(vert~1, em38a, SPDF, model=vert.fit) [using ordinary kriging] "chfactor.c", line 130: singular matrix in function LDLfactor() gstat caught an error that occurred in the matrix library, the reason for it was: singular matrix HINT: Read the manual at http://www.gstat.org/ ; look for: Trouble shooting -> Error messages -> From meschach "chfactor.c", line 130: singular matrix in function LDLfactor() Error in predict.gstat(g, newdata = newdata, block = block, nsim = nsim, : matrix library error: gstat: matrix library error: singular matrix ---end R output after consulting the gstat manual I found the following reference: "These two error messages may occur (a) during simulation, when an observation falls almost exactly at a simulation location (b) when two observations occur at identical location occur and noaverage was defined in its data definition. Solution to (a): increase the value of zero, to (b): remove the noaverage. Read also the next section." My input file was converted from lat/long to UTM using spTransform. The sampling density is quite high and it is possible that after conversion from latlong to UTM because of rounding some measurements fall on identical coordinates. Is this a possible explanation for the error?
Yes. Also near-identical locations in combination with variograms without a nugget effect may caus it.
The GSTAT online manual suggests to remove "noaverage" or increase "zero" to overcome the problem. However, I have not figured out how to do this when running gstat under R.
Either package gstat, but more likely package sp has a function zerodist which will find point pairs with (nearly) zero distances. You may use the indexes it returns to do something with these points (e.g. remove one of them).
Should I use only a subset of the orignial data or are there other alternatives to overcome the problem?
Yes. An alternative would be to average observations, if they are scalar data. -- Edzer
Regards Karl
_________________________________ Karl J Sommer, Department of Primary Industries, Catchment & Agriculture Services, PO Box 905 Mildura, VIC, Australia 3502 Tel: +61 (0)3 5051 4390 Fax +61 (0)3 5051 4534 Email: karl.sommer at dpi.vic.gov.au _______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo