Skip to content

Regression kriging - error not found when ordinary kriging

4 messages · Jordan Chetcuti, Ashton Shortridge

#
Hello, I was wondering if anyone has encountered this issue?


This line works:
                      TotalKrige <- krige(Total~1, locations=bd,
newdata=blank, model=fit_Total)

This line does not:
                     TotalRegKrige <-
krige(Total~m5005CVOL+n50010CVOL+n50015CVOL+DTM, locations=bd,
newdata=blank, model=fit_r)

Message:
                     Error in eval(expr, envir, enclos) : object
'm5005CVOL' not found

I have emailed the author of the library "gstat", he very helpfully
offered some advice and that I post here. I have also included my
intial email exchange with Prof. Pebesma.

I have included a description of my two datsets below and the
libraries I have loaded.

data = locations (therefore it isn't necessary to have "data"
specified (in the way it is in a linear model lm() )
newdata = the locations to krige

I have also tried among other things:

TotalRegKrige <-
krige(Total~bd$m5005CVOL+bd$n50010CVOL+bd$n50015CVOL+bd$DTM,
locations=bd, newdata=blank, model=fit_r)

Giveing:

Error in gstat.formula.predict(d$formula, newdata, na.action = na.action,  :
  NROW(locs) != NROW(X): this should not occur
In addition: Warning messages:
1: 'newdata' had 26026 rows but variables found have 83 rows
2: 'newdata' had 26026 rows but variables found have 83 rows

This would lead me to think there is an error in the ascii grid,
except that it worked perfectly in the ordinary kriging example.

Any help anyone can give would be greatly appreciated.

Regards

Jordan Chetcuti

p.s. see descriptions of data and libraries below, and conversation
with Prof. Pebesma.


Dataset "bd"
Object of class SpatialPointsDataFrame
Coordinates:
      min     max
X  228112  232468
Y 2190072 2195810
Is projected: NA
proj4string : [NA]
Number of points: 83
Data attributes:
   StationID       m1K10CrnR       m1K10TrHT       m1K10CVOL (only
first few, contains many).

Dataset "blank"
Object of class SpatialGridDataFrame
Coordinates:
         min     max
[1,]  226693  233843
[2,] 2187940 2197040
Is projected: NA
proj4string : [NA]
Grid attributes:
  cellcentre.offset cellsize cells.dim
1            226718       50       143
2           2187965       50       182
Data attributes:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
      1       1       1       1       1       1


Libraries
1. geoR
2. gstat
3. sp
4. lattice
2 days later
#
Hi Jordan,

I always use the 'data' parameter when kriging. Here's how I'd do it:

class(bd)   # This should be a SpatialPointsDataFrame
names(bd) #  all the variables in the model (Total, m5005CVOL, etc)

class(blank) # This should be a SpatialPointsDataFrame
names(blank) # all the variables in the model except for Total

TotalRegKrige <- krige(Total~m5005CVOL+n50010CVOL+n50015CVOL+DTM, bd, blank, 
model=fit_r)


Hope this helps.

Ashton
On Friday, November 15, 2013 10:10:30 AM Jordan Chetcuti wrote:
-----
Ashton Shortridge
Associate Professor			ashton at msu.edu
Dept of Geography			http://www.msu.edu/~ashton
235 Geography Building		ph (517) 432-3561
Michigan State University		fx (517) 432-1671
1 day later
#
hi Jordan,

(off-list) 

it sounds like your problem is not a good candidate for regression kriging. RK 
(or the similar kriging with external drift, KED) require that you have 
collocated dependent and independent variables so that you can actually run a 
regression.

You could use cokriging, though in my experience (limited!) cokriging with 
more than one secondary variable becomes a real pain to model. This is because 
the cross-variogram models all have to meet certain requirements.

I have some lecture notes that might (or might not) be helpful:
https://www.msu.edu/~ashton/classes/866/notes/lect18/index.html

Yours,

Ashton
On Tuesday, November 19, 2013 05:05:41 PM Jordan Chetcuti wrote:
-----
Ashton Shortridge
Associate Professor			ashton at msu.edu
Dept of Geography			http://www.msu.edu/~ashton
235 Geography Building		ph (517) 432-3561
Michigan State University		fx (517) 432-1671