[R-sig-Geo] Fwd: dimensions do not match

mathieu grelier greliermathieu at gmail.com
Thu Apr 10 09:21:01 CEST 2008


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>:
> The following worked for me, although I didn't understand the result:
>
>  > zd = zerodist(sitesR)
>  > kriging_result = krige(valeur~1, sitesR[-zd[,1],], mask_SG, vgm(1, "Exp",
> 300), nmax = 30)
>
>  of course arbitrarily throwing away the first of each location-paired
> point, choosing an nmax, and some nonsense variogram.
>
>  Please keep r-sig-geo in the mail loop.
>
>  --
>  Edzer
>
>  mathieu grelier wrote:
>
> > Ok,
> > I've just tried to use zerodist before calling the autoKrige function
> > but the error remains the same (memory_c...).
> > Did you manage to perform the local kriging? You said there was still an
> error.
> >
> > I forward this message to the author of automap.
> > I don't know if automap can handle this situation.
> > Paul, please could you give us an answer about last question from edzer?
> >
> > Thanks
> > Mathieu
> >
> > ---------- Forwarded message ----------
> > From: Edzer Pebesma <edzer.pebesma at uni-muenster.de>
> > Date: 7 avr. 2008 12:42
> > Subject: Re: [R-sig-Geo] dimensions do not match
> > To: mathieu grelier <greliermathieu at gmail.com>,
> r-sig-geo at stat.math.ethz.ch
> >
> >
> > Thanks Mathieu, for sending me the data off-line.
> >
> >  If you have a massive data set, you should use kriging within a local
> > neighbourhood to prevent forming and inverting a covariance matrix of
> > 4.3 Gb (24067 records, squared, times 8 bytes per double). You may try
> > to convince the author of automap to take care of this, automatically.
> >
> >  When applying local kriging to your data set, I get the error message:
> >
> >  > k = krige(valeur~1,sitesR,mask_SG,vgm(1, "Exp",300),
> nmax=30)
> >  [using ordinary kriging]
> >
> >  "chfactor.c", line 130: singular matrix in function LDLfactor()
> >  Error in predict.gstat(g, newdata = newdata, block = block, nsim = nsim,
> :
> >  LDLfactor
> >
> >  which is usually, and in this case as well, due to duplicate
> observations, try
> >
> >  > zerodist(sitesR)
> >
> >  Does automap take care of them, and if yes how?
> >  --
> >  Edzer
> >
> >
> >
> >
> >  mathieu grelier wrote:
> >
> >
> >
> > > Ok, this is the data I use and the commands.
> > > It is really weird because I use R CMD within grass and I can't
> > > reproduce exactly the same error message when I follow the commands
> > > directly in R.
> > > This is the message I get now :
> > >
> > > "memory.c", line 57: can't allocate memory in function m_get()
> > > Error in predict.gstat(g, newdata = newdata, block = block, nsim = nsim,
>  :
> > >       m_get
> > >
> > > But, I already had this memory error when working on big datasets.
> > > In the same way, I looked on the archives to see if this memory
> > > problem could be solved and I didn't find anything.
> > >
> > > Do you know it?
> > > Thanks.
> > >
> > > Mathieu
> > >
> > >
> > > 2008/4/6, Edzer Pebesma <edzer.pebesma at uni-muenster.de>:
> > >
> > >
> > >
> > >
> > > > Please send me the data as a .RData R data file, along with the steps
> that
> > > > led to the error message.
> > > >  --
> > > >  Edzer
> > > >
> > > >  mathieu grelier wrote:
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > > A question about a problem already described in this list (
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> https://stat.ethz.ch/pipermail/r-sig-geo/2006-July/001160.html),
> > > > but I
> > > >
> > > >
> > > >
> > > >
> > > > > didn't find any answer.
> > > > > I am trying to achieve ordinary kriging using gstat (via the
> autokrige
> > > > > package) in GRASS with a big dataset (24067 points).
> > > > >
> > > > > After the program removes duplicate data, I get the following same
> error :
> > > > > "Error : dimensions do not match: locations 39916 and data 24067"
> > > > > I don't have any NAs apparently.
> > > > > Checking logfile, I could see that the error is occurring in the
> krige
> > > > > function.
> > > > >
> > > > > Is there a known way to fix this problem?
> > > > > Maybe I can send my data, but I don't send it for now to the list as
> its
> > > > > weight is ~1Mo.
> > > > >
> > > > > Thanks
> > > > > Mathieu
> > > > >
> > > > >      [[alternative HTML version deleted]]
> > > > >
> > > > > _______________________________________________
> > > > > R-sig-Geo mailing list
> > > > > R-sig-Geo at stat.math.ethz.ch
> > > > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
>
>




More information about the R-sig-Geo mailing list