Skip to content

dimensions do not match

4 messages · mathieu grelier, Paul Hiemstra, Jon Olav Skoien

#
Hi,
Yes, autokrige deals with duplicates.
But I found there were two problems, and the first come from the way
autokrige calls the krige function from gstat.
Edzer, you gave the answer : it was necessary to specify "nmax=30" in the call.
Automap doesn't do it and adding this argument to the call remove the
"memory.c" problem.

The second problem (dimensions do not match) comes from the formula
parameter for the krige function.
If your data column is z, and you want to perform ordinary kriging,
you have to specify z~1.
In my case, I only know the data column name at execution time as it
is a parameter in my script.
And I must admit that I didn't achieve to find the right code to pass
this parameter to the formula argument.
Basically "variable~1" doesn't work and I don't know why exactly.
It was my code that was wrong and if I use hard code to give the
formula argument to the autokrige call, it works fine.

So last question is :
-how can I modify "z~1" in the krige formula to be able to use my data
column parameter??

Thanks
Mathieu





2008/4/7, Edzer Pebesma <edzer.pebesma at uni-muenster.de>:
#
Hi mathieu,

I'm not sure if I understand what your last question is. Why do you want 
to modify "z~1" if z is your data column name? If you want "variable~1" 
to work you need to change your column name to variable.

cheers,
Paul
mathieu grelier wrote:

  
    
#
Hi,

I think Mathieu wanted to know how to create formula strings from 
variable names. The function "as.formula" should be able to do what he 
is looking for.

as.formula(paste(names(meuse)[4],"~",names(meuse)[6]) )

is an alternative way of calling a function with the formula zinc~dist, 
knowing that these are the 4th and 6th column respectively:

library(automap)
data(meuse)
coordinates(meuse) =~ x+y
names(meuse)
v1 = 
autofitVariogram(as.formula(paste(names(meuse)[4],"~",names(meuse)[6]) 
), meuse)
v1
v2 = autofitVariogram(zinc~dist,meuse)
v2

Cheers,
Jon
Paul Hiemstra wrote:
#
Yes that's it.
It works perfectly with my variable "column" for data column name :

as.formula(paste(column,"~",1))

Thank you all.

Mathieu

--------

2008/4/10, Jon Olav Skoien <j.skoien at geo.uu.nl>: