How to calculate AIC, BIC and likelihoods of a fitted kalman filter using the DSE function in R

564 views Asked by At

I would like to test the suitability of the dynamic linear model which I have fitted to a problem set of data. I have done this using the SS() function in the dse package in R. Are there any ways of testing the fit of the model in R using likelihoods and information tests?

For illustrative purposes, assume that my model is a random walk. The theoretical form of the random walk being X(t) = X(t-1) + e(t)~N(0,1) for state evolution Y(t) = X(t) + w(t)~N(0,1). The code in R being defined by:

kalman.filter=dse::SS(F = matrix(1,1,1), 
              Q = matrix(1,1,1),
              H = matrix(1,1,1),
              R = matrix(1,1,1),
              z0 = matrix(0,1,1),
              P0 = matrix(0,1,1)
              )

Assume that the actual observations were then:

simulate.kalman.filter=simulate(kalman.filter, start = 1, freq = 1, sampleT = 100)

Then assume we fit a model called "test":

test=l(kalman.filter, simulate.kalman.filter)

How can I test the fit of the data (simulate.kalman.filter) to the model theoretical model in R? I am looking for function such as the likelihood and the Bayesian Information Criterion.

1

There are 1 answers

0
user5211911 On BEST ANSWER

I have figured out the answer to the question.

The function for doing this is called informationTests() in the same package of dse. It will return the AIC, BIC, and negative log-likelihood of the fitted model to the data. In the example above, this is done by:

informationTests(test)

Remember that a model with a lower BIC is considered better. You can also compare two models (assume that you had a second model fitted to the data called test2) by adding the second model as a parameter:

informationTests(test, test2)

This tabulates the AIC, BIC and likelihoods against one another.