I am using Kalman Filter to estimate my state variables for a time series data. But all my parameters in KF are unknown.

S(t) = A*S(t-1) + B*X(t) + Q   ----------Sate process    
Z(t) = H*S(t)   + W*D(t) + R   ----------Measurement process where, 

T: the total number of time slots in the time series data    
N: number of state variable    
M: number of measurement variable    
S: state variable, N*T dimension matrix    
Z: measurement variable, M*T dimension matrix    
Q: state process noise    
R: measurement process noise    
X: input in state process 
L dimension for a time slot    
D: input in measurement process, I dimension for a time slot    
A, B and H: parameter matrix 

I want to solve

 1. Best A, B, and H matrix for the KF. All parameters in the model are constrained.
 2. Estimate all state variables after getting best A, B and H.

One example I want to solve is to estimate sales effect from different media channels and media synergy effects.

 Z(t) is the sales number for each week 
 S(t) is the sales effect from each media channle and media synergy effect; a sales effect from a media channel will be a state variable.
 X(t) is the media spending
 D(t) are seasonality, macro-economy factor and other extra independent varialbes to the model

I have checked some R packages. It seems that some of them have specific KF formulation. Which R packages can I use to solve the two problems listed above? Do I need to call optim() together with those R packages in order to solve problem 1?



You can use several R packages for Kalman filtering. You have to code, though, any constrains you may have in matrices A, B. H, etc.

Among the outputs of the Kalman filter, most packages will give you the likelihood, for given values of the parameters. You then have to invoke optim() or an alternative function to maximize that likelihood. Or, if you use package dlm, you can simply invoke dlmMLE (which in fact is a wrap function for optim()). You have one example in this answer to another query.

| cite | improve this answer | |

Is DLM appropriate for your purposes?

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.