[R] geoR : Passing arguments to "optim" when using "likfit"]

Rubén Roa-Ureta rroa at udec.cl
Thu Jun 26 14:48:14 CEST 2008


Mzabalazo Ngwenya wrote:
> Hi everyone !
>  
> I'm am trying to fit a kriging model to a set of data. When I just run 
> the "likfit" command I can obtain the results. However when I try to 
> pass additional arguements to the optimization function "optim" I get 
> errors. That is I want to obtain the hessian matrix so matrix 
> (hessian=TRUE).
>  
> Heres a little example( 1-D). Can anyone shed some light?  Where am I 
> going wrong ?
>  
> -------
>  
>  
>  
>> obs.points 
>> <-matrix(c(0.1,0,0.3666667,0,0.6333334,0,0.9000001,0),byrow=TRUE,nrow=4)
>> MM1.fx <-MM1(obs.points[,1])
>> MM1.fx
>>     
> [1] 0.1111111 0.5789475 1.7272732 9.0000100
> # Creating geoR object
>  
>> MM1.data <-as.geodata(cbind(obs.points,MM1.fx))
>> MM1.data
>>     
> $coords
> [1,] 0.1000000 0
> [2,] 0.3666667 0
> [3,] 0.6333334 0
> [4,] 0.9000001 0
> $data
> [1] 0.1111111 0.5789475 1.7272732 9.0000100
> attr(,"class")
> [1] "geodata"
> # Starting values for MLE
>  
>> sta.vals =expand.grid(seq(1,20),seq(1,20))
>>     
> # Maximum likelihood estimation of covariance parameters
>
> #### HERE IS THE PROBLEM ################
>  
>> MM1.fit 
>> <-likfit(MM1.data,ini.cov.pars=sta.vals,fix.nugget=TRUE,cov.model="gaussian",optim(hessian=TRUE)) 
>>
>>     


MM1.fit 
<-likfit(MM1.data,ini.cov.pars=sta.vals,fix.nugget=TRUE,cov.model="gaussian",hessian=TRUE) 

MM1.fit$info.minimisation.function$hessian
For the observed Fisher information:
solve(MM1.fit$info.minimisatrion.function$hessian)

HTH
Rubén



More information about the R-help mailing list