[R-sig-Geo] How to locate local minima points on a Krige-fitted surface?

Paul Hiemstra p.hiemstra at geo.uu.nl
Sat Jun 12 11:41:39 CEST 2010


On 06/12/2010 09:11 AM, v v wrote:
> Hi, Paul,
>  
> Thank you for the reply. 
>  
> I have attempted to write some code to test out what you've suggested but ran into some errors.
>  
> library(fields)
> k <- Krig(ozone$x, ozone$y, theta=20)
>  
> # define objective function 
> kfunc <- function(para,k) {
>   xcoord=para[1]
>   ycoord=para[2]
>  
>   minimum <- NULL
>   
The command above is not needed.
>   testpoint <- c(xcoord, ycoord)
>   minimum <- predict(k, testpoint)
>   
btw, this predict command fails. I have no experience with Fields and no
time right now to find out why.
>   return(minimum)
> }
>  
> initialpar <- c(max(ozone$x), max(ozone$y))
> initialpar 
>  
> # optimization
> best <- optim(initialpar, kfunc, NULL, method = "BFGS", hessian=TRUE)
>   
The costfunction for optim needs k as an input, which you didn't pass
on. This passes on k:

best <- optim(initialpar, kfunc, NULL, k = k, method = "BFGS", hessian=TRUE)

But as I mentioned above, the predict for Fields still does not work.

cheers,
Paul
>  
> # Error in predict(k, testpoint) : argument "k" is missing, with no default
>  
>  
> regards,
> Jeff 
>
> ----------------------------------------
>   
>> Date: Fri, 11 Jun 2010 15:04:32 +0200
>> From: p.hiemstra at geo.uu.nl
>> To: vivacity at hotmail.sg
>> CC: r-sig-geo at stat.math.ethz.ch
>> Subject: Re: [R-sig-Geo] How to locate local minima points on a Krige-fitted surface?
>>
>> Dear Jeff,
>>
>> I think you cannot escape discretizing your kriging surface as there is
>> no mathematical expression that captures the kriging surface. To use
>> optim you could make an objective function that was two inputs, x and y
>> location. The functions calls the fields package to estimate the kriging
>> prediction at this point and returns it. This ofcourse assumes that the
>> variogram model is known. You have to play with the settings of optim to
>> get it working and prevent a local minimum. You could take a look at
>> SANN (simulated anealing) which is part of optim.
>>
>> cheers,
>> Paul
>> 		 	   		  
>>     
> _________________________________________________________________
> Hotmail: Powerful Free email with security by Microsoft.
> https://signup.live.com/signup.aspx?id=60969
>   


-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770



More information about the R-sig-Geo mailing list