[R] dlm package and Log Likelihoods

From: <Joseph.Smith_at_noaa.gov>
Date: Wed, 23 Jun 2010 15:54:33 -0400


Hello,

For this project I have been tasked with emulating an old Dynamic Linear Modelling paper's results in the R programming language with the same data. The majority of the work (creating the model, filtering, smoothing, forecasting, etc.) has been done via the dlm package, and I have been successful in at least mimicking the old project's plot and coming within reasonable range on the Mean Squared Errors and Median Absolute Deviations (for goodness of fit testing, etc...).

The strange thing has been in calculating the Log Likelihood. Running it through the dlm package's dlmLL method spits out an unusually large number compared with the old projects results (which was run on this Bayesian Analysis of Time Series (BATS) program). This is specifically for a second order polynomial DLM (linear trend model), whose filtered values were produced from a method dlmFilterDF (DF = discount factor) written by Giovanni Petris.

A constant trend model will return values much closer to what I have expected (100s vs 4000-5000s). Same with the linear trend model if you plug in just the filtered plot values (i.e. if you ran the program, I ran filteredmodel$m[,1] for the Log likelihood).

What I am hoping to do is get an accurate read on the LL, which will then be wrapped in a logLik object and used to calculate the Akaike and Bayesian Information Criterion for further analysis under the stats4 package.

Those who I am working with and a stats professor have told me I might be getting raw LLs, where as the old paper might have neglected to mention a constant they may have applied. Personally I would rather get the measurement correct given the environment.

So in general, if you have played around with the dlm R package, I would like to know if you have ran into this situation and/or what could help in making the LLs a little more reasonable (parameters within the model that need manipulation, perhaps I am using the wrong thing to calculate the LL...).

FWIW: my math background is heavy in calc, decent with linear algebra, introductory stats yet I have learned much in the ways of Bayesian Statistics and parameters that drive the models I am running here for the project, so if you explain something in that latter realm, a small summary of details will suffice.

Many thanks!!!

-Joeseph P. Smith



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. Received on Wed 23 Jun 2010 - 19:56:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jun 2010 - 20:40:44 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive