[R] Hessian Matrix Issue

Paul Hiemstra paul.hiemstra at knmi.nl
Tue Sep 6 13:23:32 CEST 2011


 On 09/03/2011 08:22 PM, dave fournier wrote:
>
> I wonder if your code is correct?
>
> I ran your script until an error was reported. the data set
> of 30 obs was
>
>
> [1]  0  0  1  3  3  3  4  4  4  4  5  5  5  5  5  7  7  7  7  7  7  8 
> 9 10 11
> [26] 12 12 12 15 16
>
> I created a tiny AD Model Builder program to do MLE on it.
>
> DATA_SECTION
>   init_int nobs
>   init_vector y(1,nobs)
> PARAMETER_SECTION
>   init_number log_mu
>   init_number log_alpha
>   sdreport_number mu
>   sdreport_number tau
>   objective_function_value f
> PROCEDURE_SECTION
>   mu=exp(log_mu);
>   tau=1.0+exp(log_alpha);
>   for (int i=1;i<=nobs;i++)
>   {
>     f-=log_negbinomial_density(y(i),mu,tau);
>   }
> It converged quickly and
>
> The eigenvalues of the Hessian were
>
>     4.711089774    78.27632341
>
> and the estimates and std devs of the parameters mu and tau were
>
> index   name       value      std dev
>
>      3   mu         6.6000e+00 7.7318e-01
>      4   tau        2.7173e+00 7.8944e-01
>
> where tau is the variance divided by the mean.
>
> This was all so simple that I suspect your (rather difficult to read)
> R code is wrong, otherwise R must really suck at this kind of problem.

I'd put my money on R!

Paul

>
>       Dave
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770



More information about the R-help mailing list