The filter routines there have names and should follow calling rules for the par matlab/kalman/likelihood ones but they do not yet take mf and still expect Z matrix of 1s to map system to observables instead and Pinf must not be empty but at least be initialised to a zeros matrix of Pstar size.
The smoother is generic as it was, not suitable for running at all
Best regards
George
----- Original Message ----- From: Stéphane Adjemian To: List for Dynare developers Sent: Wednesday, May 27, 2009 2:46 PM Subject: Re: [DynareDev] Kalman Filter
Hi George
2009/5/27 G. Perendia george@perendia.orangehome.co.uk
Hi
The C++ Kalman dll driver routines in /mex/kalman/matlab are still in development
Sure...
and the code there is still subject to developer testing
... But I'd like to play with it.
and the Makefile there is not yet complete but it should use blas/lapack from Matlab libraries.
Ok. I will adapt your Makefile for my platform.
Best, Stéphane.
Best regards
George Perendia Tel.: 02072815392 Mob: 07951415480 ----- Original Message ----- From: Stéphane Adjemian To: List for Dynare developers Sent: Wednesday, May 27, 2009 2:18 PM Subject: Re: [DynareDev] Kalman Filter
Oui, oui... I never use the presampling option... And with all the examples I have ever considered it takes much more than 10 iterations to get to the steady state kalman filter.
By the way, is there somewhere linux a Makefile for the cc kalman routines? Also, why do we need Atlas (if we also use matlab's lapack/blas libraries)?
Stéphane.
2009/5/27 Michel Juillard michel.juillard@ens.fr
Si le filtre converge a l'etat stationnaire a une date avant start (la date a partir de laquelle on cumule la vraisemblance), alors additionner tous les determinants des iterations dans le filtre stationnaire a la derniere periode fausse le calcul de la constante.
amicalement
Michel
Stéphane Adjemian wrote:
Thanks Michel. Your commit is ok for me. I do not yet understand the problem raised by George. I need to go through his example...
Stéphane.
2009/5/27 Michel Juillard <michel.juillard@ens.fr mailto:michel.juillard@ens.fr>
Thanks Stephane,
I just uploaded a new version of kalman_filter.m Tell me what you think
Best
Michel
Stéphane Adjemian wrote:
Hi all,
I agree, the matlab code is very unclear (even if I had fun writting it this way ;-) and prone to errors if one uses the vector lik (Marco is using it). I would rather prefer to add the constants outside of the loop with a (sub)vector operation, this should be more efficient. I will do it today or tomorrow.
Best, Stéphane.
2009/5/27 Michel Juillard <michel.juillard@ens.fr
mailto:michel.juillard@ens.fr <mailto:michel.juillard@ens.fr
mailto:michel.juillard@ens.fr>>
On closer inspection, I don't think that the expression pointed by George in kalman_filter.m is wrong:
1. reste = smpl-t or the number of periods during which the filter is stationary. This shouldn't be larger than T-start+1
2. it is problematic (see below) but not wrong to add all the determinants at once in the last period of the stationary filter
3. I don't think this explains the difference with the C++ version of the filter and we still have to look for it.
4. it remains that the current code is very unclear and that if LIK is correct the vector lik doesn't have the correct constants on each elements.
5. I would like to simplify the code and add the correct constant to each element of the lik vector. It would be a little bit less efficient in Matlab than the current code, but I doubt it would be noticeable. Stephane, what do you think?
Best
Michel
G. Perendia wrote:
Dear Michel
I think I found an error in Dynare Matlab kalman_filter. suite of utilities which affects the likelihood LIK results with start>1 (i.e. presampling>0):
the calculation speed-up construct which relies on converged covariance matrix
lik(t) = lik(t) + reste*log(dF);
adds reste * log(dF) to the last-1 (i.e. the smpl) member of lik (the last, the lik(smpl+1) one contains smpl*pp*log(2*pi)) but reste is usually larger than T-start+1 so that
LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl)
has much more log(dF)s added than required since they are all concentrated in the last-1 (the T) member
For example, if I change the above construct to lik(t) = lik(t) + min(reste,(smpl-start+1))*log(dF);
the reported likelihood for presample=40 from Matlab KF is 1640935.5855267849 which is nearly the same as that from C++ KF below: 1640935.5854489324
Shall I make changes to kalman/likelihood/ KFs and upload the .m files? This problem affects also the older versions of DiffuseLikelihood**.m too.
Best regards
George artilogica@btconnect.com mailto:artilogica@btconnect.com
<mailto:artilogica@btconnect.com
mailto:artilogica@btconnect.com>
----- Original Message ----- From: "Michel Juillard" <michel.juillard@ens.fr mailto:michel.juillard@ens.fr
<mailto:michel.juillard@ens.fr mailto:michel.juillard@ens.fr>>
To: "G. Perendia" <george@perendia.orangehome.co.uk mailto:george@perendia.orangehome.co.uk <mailto:george@perendia.orangehome.co.uk mailto:george@perendia.orangehome.co.uk>>
Sent: Tuesday, May 26, 2009 10:32 AM Subject: Re: Kalman Filter+PS
Hi George,
Re 1) below: I modified C++ KF so that it reports log-likelihood for given start/preampling in same/similar manner as the Matlab KFs do and I am getting approximately close results, e.g.
ll= -1640935.5854489324 for C++ and (-) 1640482.4179242959 for Matlab KF (for start=41, i.e. presample=40). whilst they appear same for presample=0 (e.g.2.5906e+006), i.e. -2590556.989730841 vs 2590556.989778722
Are those results acceptably close or should I investigate further where the above difference may come form?
This indicates a problem . The difference should be the same with and without presample. It may come from the computation of the likelihood constant. This is done in a very obscure manner in Dynare Matlab.
_______________________________________________ Dev mailing list Dev@dynare.org mailto:Dev@dynare.org
<mailto:Dev@dynare.org mailto:Dev@dynare.org>
http://www.dynare.org/cgi-bin/mailman/listinfo/dev
-- Stéphane Adjemian CEPREMAP & Université du Maine
Tel: (33)1-43-13-62-39 ------------------------------------------------------------------------
_______________________________________________ Dev mailing list Dev@dynare.org mailto:Dev@dynare.org http://www.dynare.org/cgi-bin/mailman/listinfo/dev
_______________________________________________ Dev mailing list Dev@dynare.org mailto:Dev@dynare.org http://www.dynare.org/cgi-bin/mailman/listinfo/dev
-- Stéphane Adjemian CEPREMAP & Université du Maine
Tel: (33)1-43-13-62-39 ------------------------------------------------------------------------
_______________________________________________ Dev mailing list Dev@dynare.org http://www.dynare.org/cgi-bin/mailman/listinfo/dev
_______________________________________________ Dev mailing list Dev@dynare.org http://www.dynare.org/cgi-bin/mailman/listinfo/dev
-- Stéphane Adjemian CEPREMAP & Université du Maine
Tel: (33)1-43-13-62-39
--------------------------------------------------------------------------
_______________________________________________ Dev mailing list Dev@dynare.org http://www.dynare.org/cgi-bin/mailman/listinfo/dev
_______________________________________________ Dev mailing list Dev@dynare.org http://www.dynare.org/cgi-bin/mailman/listinfo/dev
-- Stéphane Adjemian CEPREMAP & Université du Maine
Tel: (33)1-43-13-62-39
------------------------------------------------------------------------------
_______________________________________________ Dev mailing list Dev@dynare.org http://www.dynare.org/cgi-bin/mailman/listinfo/dev