[R-sig-Geo] about ST kriging

Edzer Pebesma edzer.pebesma at uni-muenster.de
Fri Oct 7 10:40:38 CEST 2011


I looked at your data and scripts (off-list), and found the following:

You're trying to use krigeST with an STSDF object. krigeST was
designed to exploit separability of spatio-temporal covariance
models. This implies that the space-time layout needs to be
full, i.e. STFDF. When looking at the space-time layout of your
observations (I tried plot(w at index) for this), you are not very
close to a full layout, so that may not be feasible.

You're running out of memory because of your size of newdata
(prediction locations), which has 1.2M nodes. krigeST computes
the covariance of all observations with prediction nodes, so
that is a 5364 x 1217697 matrix, which would require 49 Gb.
The fact that krigeST does not warn you for any of this is an
omission on my side, I will change that.

The options then are:
1. use krige0, which does global kriging; this will need to solve
a system of 5364 x 5364, which might work out fine; demo(wind) has,
AFAICR, an example of doing this for the Irish wind data and a
separable covariance. If you run into memory problems try to not
pass the full prediction grid at once, but in smaller pieces;
demo(wind) also does this.
2. use krige, possibly with a local search neighbourhood, and a
metric ("3D space/time") variogram; if you use local neighbourhoods,
it makes sens to rescale time such that space and time have the
same range (in numeric values).

I hope to write these things down more clearly, in a vignette
containing examples, soon.

On 09/22/2011 02:39 PM, Pınar Aslantas Bostan wrote:
> Edzer, I have 256 meteorological station and 39 year value.
>
>> dim(w)
> [1] 256  39   1
>
> Before I tried only spatial kriging and I did not get memory.size error. Just a moment ago, I used another computer (64-bit Windows and 6 GB RAM), again I got the same error.
>
> -----Original Message-----
> From: Edzer Pebesma [mailto:edzer.pebesma at uni-muenster.de]
> Sent: Thursday, September 22, 2011 2:47 PM
> To: Pınar Aslantas Bostan
> Cc: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] about ST kriging
>
> Pinar, what are the dimensions (space and time) of your data, i.e. what
> does dim(w) return?
>
> Have you tried kriging with a (spatial and/or temporal) subset?
>
> On 09/22/2011 01:38 PM, Pınar Aslantas Bostan wrote:
>> Hi Edzer,
>>
>> Thank you very much for your mail. I found two records have identical location, but it is not my fault because I checked the original source data and it is erroneous.
>>
>> Now I have another problem; R gives another error message:
>> Error: cannot allocate vector of size 95.4 Mb
>>
>> My computer includes 32-bit Windows and  3,5 GB RAM. I am not sure if I install 64-bit Windows, then the problem is solved? Or maybe I should minimize the data. Do you have any idea about it?
>>
>> Best wishes,
>> Pinar
>>
>> -----Original Message-----
>> From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of Edzer Pebesma
>> Sent: Wednesday, September 21, 2011 3:46 PM
>> To: r-sig-geo at r-project.org
>> Subject: Re: [R-sig-Geo] about ST kriging
>>
>> Hi Pinar,
>>
>> it is not clear which variogram model you pass, or how your data are
>> laid out in space and time.
>>
>> Possible causes for a non-positive definite covariance matrix include:
>>
>> - a variogram model with (nearly) perfect correlation
>> - duplicate observations (observations having identical location AND time)
>> - an invalid variogram model
>>
>> A small, reproducible example (data + script) would help identify the
>> problem.
>>
>> Best regards,
>> --
>> Edzer
>>
>> On 09/20/2011 11:15 AM, Pınar Aslantas Bostan wrote:
>>> Dear all,
>>>
>>> I am working about space-time kriging. Before I asked again about ST kriging
>>> but now the problem is
>>> different and I could not overcome it!
>>>
>>> During kriging operation I got this error:
>>>
>>>> pred = krigeST(prec~1, w, STS(grid,time,index), v)
>>> Error in chol.default(A$Sm, LINPACK = TRUE) :
>>>    non-positive definite matrix in 'chol'
>>>
>>> I explained the data set below:
>>>
>>> # prec is annual precipitation measured from 257 meteorological stations
>>>
>>> # w is STSDF object
>>>> summary(w)
>>> Object of class STSDF
>>> [[Spatial:]]
>>> Object of class SpatialPoints
>>> Coordinates:
>>>           min     max
>>> Xnew  140556 1730472
>>> Ynew 4309064 4971309
>>> Is projected: NA
>>> proj4string : [NA]
>>> Number of points: 257
>>> [[Temporal:]]
>>>       Index                      object at time
>>>   Min.   :1970-01-01 12:00:00   Min.   : 1.0
>>>   1st Qu.:1979-07-03 00:00:00   1st Qu.:10.5
>>>   Median :1989-01-01 12:00:00   Median :20.0
>>>   Mean   :1989-01-01 02:46:09   Mean   :20.0
>>>   3rd Qu.:1998-07-03 00:00:00   3rd Qu.:29.5
>>>   Max.   :2008-01-01 12:00:00   Max.   :39.0
>>> [[Data attributes:]]
>>>     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
>>>    114.5   413.7   533.6   633.0   735.6  3332.0
>>>
>>> # I used grid to obtain predictions over it. It has 25 km spatial resolution
>>>
>>> # time is temporal entity of study. It contains 39 annual observation.
>>>
>>> # index is required for STSDF, and I used this code to create index.
>>>> index<- cbind(as.integer(as.factor(data$Station)),
>>> as.integer(as.factor(data$Year)))
>>>
>>> # v is space-time variogram
>>>
>>> How can I solve the problem?
>>> Thank you in advance!
>>>
>>>
>>> Pinar Aslantas Bostan
>>> Research Assistant
>>> Department of Geodetic and
>>> Geographic Information Technologies (GGIT) Middle East Technical University
>>> 06531 Ankara/TURKEY
>>> aslantas at metu.edu.tr
>>>
>>> _______________________________________________
>>> 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
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list