[R] dlm package and Log Likelihoods

Joseph.Smith at noaa.gov Joseph.Smith at noaa.gov
Wed Jun 23 21:54:33 CEST 2010


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



More information about the R-help mailing list